當前位置: 首頁>>代碼示例>>Python>>正文


Python CreateUnit.finish_production_now方法代碼示例

本文整理匯總了Python中horizons.command.unit.CreateUnit.finish_production_now方法的典型用法代碼示例。如果您正苦於以下問題:Python CreateUnit.finish_production_now方法的具體用法?Python CreateUnit.finish_production_now怎麽用?Python CreateUnit.finish_production_now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在horizons.command.unit.CreateUnit的用法示例。


在下文中一共展示了CreateUnit.finish_production_now方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: remove

# 需要導入模塊: from horizons.command.unit import CreateUnit [as 別名]
# 或者: from horizons.command.unit.CreateUnit import finish_production_now [as 別名]
def remove(s, p, before_ticks, after_ticks, tear_index):
	"""
	Place a couple of buildings and tear down one randomly, run a while afterwards.
	Called by test_removal with different parameters.
	"""
	settlement, island = settle(s)
	settlement.branch_office.inventory.adjust_limit(sys.maxint)

	# Plant trees
	for (x, y) in product(range(23, 38), repeat=2):
		if s.random.randint(0, 1) == 1:
			tree = Build(BUILDINGS.TREE_CLASS, x, y, island, settlement=settlement)(p)
			assert tree
			tree.finish_production_now()

	jack = Build(BUILDINGS.LUMBERJACK_CLASS, 25, 30, island, settlement=settlement)(p)
	assert jack
	jack = Build(BUILDINGS.LUMBERJACK_CLASS, 35, 30, island, settlement=settlement)(p)
	assert jack

	# Throw some fish into the water
	for x in (25, 30, 35):
		school = Build(BUILDINGS.FISH_DEPOSIT_CLASS, x, 18, s.world, ownerless=True)(None)
		assert school
		school.finish_production_now()

	fisherman = Build(BUILDINGS.FISHERMAN_CLASS, 25, 20, island, settlement=settlement)(p)
	assert fisherman
	fisherman = Build(BUILDINGS.FISHERMAN_CLASS, 35, 20, island, settlement=settlement)(p)
	assert fisherman

	# Some wild animals in the forest
	for (x_off, y_off) in product([-5, -4, 4, 5], repeat=2):
		x = 30 + x_off
		y = 30 + y_off
		animal = CreateUnit(island.worldid, UNITS.WILD_ANIMAL_CLASS, x, y)(None)
		assert animal
		animal.finish_production_now()

	hunter = Build(BUILDINGS.HUNTER_CLASS, 30, 35, island, settlement=settlement)(p)
	assert hunter

	# Build a farm
	assert Build(BUILDINGS.FARM_CLASS, 26, 33, island, settlement=settlement)(p)
	assert Build(BUILDINGS.PASTURE_CLASS, 22, 33, island, settlement=settlement)(p)
	assert Build(BUILDINGS.PASTURE_CLASS, 26, 37, island, settlement=settlement)(p)

	# Build roads
	for (start, dest) in [(Point(27, 30), Point(30, 23)), (Point(32, 23), Point(35, 30)),
						  (Point(25, 21), Point(30, 23)), (Point(32, 23), Point(35, 21)),
						  (Point(30, 35), Point(32, 25)), (Point(26, 33), Point(27, 30))]:
		path = StaticPather.get_direct_path(island, start, dest)
		assert path
		for (x, y) in path:
			a = Build(BUILDINGS.TRAIL_CLASS, x, y, island, settlement=settlement)(p)

	s.run(seconds=before_ticks)
	# Tear down a random building that is not a trail or tree.
	target = [b for b in settlement.buildings if b.id not in (BUILDINGS.TRAIL_CLASS, BUILDINGS.TREE_CLASS)][tear_index]
	Tear(target)(p)
	s.run(seconds=after_ticks)
開發者ID:mihaibivol,項目名稱:unknown-horizons,代碼行數:63,代碼來源:test_remove_buildings.py


注:本文中的horizons.command.unit.CreateUnit.finish_production_now方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。