本文整理汇总了Python中horizons.ai.aiplayer.productionbuilder.ProductionBuilder类的典型用法代码示例。如果您正苦于以下问题:Python ProductionBuilder类的具体用法?Python ProductionBuilder怎么用?Python ProductionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProductionBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load
def _load(self, db, owner, worldid):
self.owner = owner
super(SettlementManager, self).load(db, worldid)
# load the main part
land_manager_id = db("SELECT land_manager FROM ai_settlement_manager WHERE rowid = ?", worldid)[0][0]
land_manager = WorldObject.get_object_by_id(land_manager_id)
# find the settlement
for settlement in self.owner.session.world.settlements:
if settlement.owner == self.owner and settlement.island == land_manager.island:
land_manager.settlement = settlement
break
assert land_manager.settlement
self.resource_manager = ResourceManager.load(db, self)
self.trade_manager = TradeManager.load(db, self)
self.__init(land_manager)
# load the master builders
self.village_builder = VillageBuilder.load(db, self)
self.production_builder = ProductionBuilder.load(db, self)
self.village_builder.display()
self.production_builder.display()
self.__init_goals()
# the add_building events happen before the settlement manager is loaded so they have to be repeated here
for building in self.settlement.buildings:
self.add_building(building)
示例2: __init__
def __init__(self, owner, land_manager):
super(SettlementManager, self).__init__()
self.owner = owner
self.resource_manager = ResourceManager(self)
self.trade_manager = TradeManager(self)
self.__init(land_manager)
self.village_builder = VillageBuilder(self)
self.production_builder = ProductionBuilder(self)
self.village_builder.display()
self.production_builder.display()
self.__init_goals()
if not self.feeder_island:
self._set_taxes_and_permissions(self.personality.initial_sailor_taxes, self.personality.initial_pioneer_taxes, \
self.personality.initial_settler_taxes, self.personality.initial_sailor_upgrades, self.personality.initial_pioneer_upgrades)
示例3: SettlementManager
class SettlementManager(WorldObject):
"""
This is the main settlement control class.
Important attributes:
* feeder_island: boolean showing whether the island is a feeder island (feeder islands have no village area)
* island: Island instance
* settlement: Settlement instance
* land_manager: LandManager instance
* production_chain: dictionary where the key is a resource id and the value is the ProductionChain instance
* production_builder: ProductionBuilder instance
* village_builder: VillageBuilder instance
* resource_manager: ResourceManager instance
* trade_manager: TradeManager instance
"""
log = logging.getLogger("ai.aiplayer")
def __init__(self, owner, land_manager):
super(SettlementManager, self).__init__()
self.owner = owner
self.resource_manager = ResourceManager(self)
self.trade_manager = TradeManager(self)
self.__init(land_manager)
self.village_builder = VillageBuilder(self)
self.production_builder = ProductionBuilder(self)
self.village_builder.display()
self.production_builder.display()
self.__init_goals()
if not self.feeder_island:
self._set_taxes_and_permissions(self.personality.initial_sailor_taxes, self.personality.initial_pioneer_taxes,
self.personality.initial_citizen_taxes, self.personality.initial_settler_taxes, self.personality.initial_sailor_upgrades, \
self.personality.initial_pioneer_upgrades, self.personality.initial_settler_upgrades)
def __init(self, land_manager):
self.owner = land_manager.owner
self.session = self.owner.session
self.land_manager = land_manager
self.island = self.land_manager.island
self.settlement = self.land_manager.settlement
self.feeder_island = land_manager.feeder_island
self.personality = self.owner.personality_manager.get('SettlementManager')
# create a production chain for every building material, settler consumed resource, and resources that have to be imported from feeder islands
self.production_chain = {}
for resource_id in [RES.COMMUNITY, RES.BOARDS, RES.FOOD, RES.TEXTILE, RES.FAITH,
RES.EDUCATION, RES.GET_TOGETHER, RES.BRICKS, RES.TOOLS, RES.LIQUOR,
RES.TOBACCO_PRODUCTS, RES.SALT]:
self.production_chain[resource_id] = ProductionChain.create(self, resource_id)
# initialize caches
self.__resident_resource_usage_cache = {}
def __init_goals(self):
"""Initialize the list of all the goals the settlement can use."""
self._goals = [] # [SettlementGoal, ...]
self._goals.append(BoardsGoal(self))
self._goals.append(SignalFireGoal(self))
self._goals.append(EnlargeCollectorAreaGoal(self))
self._goals.append(ImproveCollectorCoverageGoal(self))
self._goals.append(BricksGoal(self))
if self.feeder_island:
self._goals.append(StorageSpaceGoal(self))
self._goals.append(FeederFoodGoal(self))
self._goals.append(FeederTextileGoal(self))
self._goals.append(FeederLiquorGoal(self))
self._goals.append(FeederSaltGoal(self))
self._goals.append(FeederTobaccoProductsGoal(self))
else:
self._goals.append(BoatBuilderGoal(self))
self._goals.append(ClayDepositCoverageGoal(self))
self._goals.append(FoundFeederIslandGoal(self))
self._goals.append(MountainCoverageGoal(self))
self._goals.append(FoodGoal(self))
self._goals.append(CommunityGoal(self))
self._goals.append(FaithGoal(self))
self._goals.append(TextileGoal(self))
self._goals.append(EducationGoal(self))
self._goals.append(GetTogetherGoal(self))
self._goals.append(SaltGoal(self))
self._goals.append(TobaccoProductsGoal(self))
self._goals.append(ToolsGoal(self))
self._goals.append(TentGoal(self))
self._goals.append(TradingShipGoal(self))
self._goals.append(CombatShipGoal(self))
self._goals.append(FireStationGoal(self))
def save(self, db):
super(SettlementManager, self).save(db)
db("INSERT INTO ai_settlement_manager(rowid, land_manager) VALUES(?, ?)",
self.worldid, self.land_manager.worldid)
self.village_builder.save(db)
self.production_builder.save(db)
self.resource_manager.save(db)
self.trade_manager.save(db)
#.........这里部分代码省略.........