本文整理汇总了Python中horizons.ai.aiplayer.villagebuilder.VillageBuilder.add_building方法的典型用法代码示例。如果您正苦于以下问题:Python VillageBuilder.add_building方法的具体用法?Python VillageBuilder.add_building怎么用?Python VillageBuilder.add_building使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.ai.aiplayer.villagebuilder.VillageBuilder
的用法示例。
在下文中一共展示了VillageBuilder.add_building方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettlementManager
# 需要导入模块: from horizons.ai.aiplayer.villagebuilder import VillageBuilder [as 别名]
# 或者: from horizons.ai.aiplayer.villagebuilder.VillageBuilder import add_building [as 别名]
#.........这里部分代码省略.........
def load(cls, db, owner, worldid):
self = cls.__new__(cls)
self._load(db, owner, worldid)
return self
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)
def _set_taxes_and_permissions(self, sailor_taxes, pioneer_taxes, settler_taxes, citizen_taxes, sailor_upgrades, pioneer_upgrades, settler_upgrades):
"""Set new tax settings and building permissions."""
if abs(self.settlement.tax_settings[TIER.SAILORS] - sailor_taxes) > 1e-9:
self.log.info("%s set sailors' taxes from %.1f to %.1f", self, self.settlement.tax_settings[TIER.SAILORS], sailor_taxes)
SetTaxSetting(self.settlement, TIER.SAILORS, sailor_taxes).execute(self.land_manager.session)
if abs(self.settlement.tax_settings[TIER.PIONEERS] - pioneer_taxes) > 1e-9:
self.log.info("%s set pioneers' taxes from %.1f to %.1f", self, self.settlement.tax_settings[TIER.PIONEERS], pioneer_taxes)
SetTaxSetting(self.settlement, TIER.PIONEERS, pioneer_taxes).execute(self.land_manager.session)
if abs(self.settlement.tax_settings[TIER.SETTLERS] - settler_taxes) > 1e-9:
self.log.info("%s set settlers' taxes from %.1f to %.1f", self, self.settlement.tax_settings[TIER.SETTLERS], settler_taxes)
SetTaxSetting(self.settlement, TIER.SETTLERS, settler_taxes).execute(self.land_manager.session)
if abs(self.settlement.tax_settings[TIER.CITIZENS] - citizen_taxes) > 1e-9:
self.log.info("%s set citizens' taxes from %.1f to %.1f", self, self.settlement.tax_settings[TIER.CITIZENS], citizen_taxes)
SetTaxSetting(self.settlement, TIER.CITIZENS, citizen_taxes).execute(self.land_manager.session)
if self.settlement.upgrade_permissions[TIER.SAILORS] != sailor_upgrades:
self.log.info('%s set sailor upgrade permissions to %s', self, sailor_upgrades)
SetSettlementUpgradePermissions(self.settlement, TIER.SAILORS, sailor_upgrades).execute(self.land_manager.session)
if self.settlement.upgrade_permissions[TIER.PIONEERS] != pioneer_upgrades:
self.log.info('%s set pioneer upgrade permissions to %s', self, pioneer_upgrades)
SetSettlementUpgradePermissions(self.settlement, TIER.PIONEERS, pioneer_upgrades).execute(self.land_manager.session)
if self.settlement.upgrade_permissions[TIER.SETTLERS] != settler_upgrades:
self.log.info('%s set settler upgrade permissions to %s', self, settler_upgrades)
SetSettlementUpgradePermissions(self.settlement, TIER.SETTLERS, settler_upgrades).execute(self.land_manager.session)
def _set_taxes_and_permissions_prefix(self, prefix):
"""Set new tax settings and building permissions according to the prefix used in the personality file."""
sailor_taxes = getattr(self.personality, '%s_sailor_taxes' % prefix)
pioneer_taxes = getattr(self.personality, '%s_pioneer_taxes' % prefix)
settler_taxes = getattr(self.personality, '%s_settler_taxes' % prefix)
citizen_taxes = getattr(self.personality, '%s_citizen_taxes' % prefix)
sailor_upgrades = getattr(self.personality, '%s_sailor_upgrades' % prefix)