本文整理汇总了Python中horizons.ai.aiplayer.productionbuilder.ProductionBuilder.manage_production方法的典型用法代码示例。如果您正苦于以下问题:Python ProductionBuilder.manage_production方法的具体用法?Python ProductionBuilder.manage_production怎么用?Python ProductionBuilder.manage_production使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.ai.aiplayer.productionbuilder.ProductionBuilder
的用法示例。
在下文中一共展示了ProductionBuilder.manage_production方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettlementManager
# 需要导入模块: from horizons.ai.aiplayer.productionbuilder import ProductionBuilder [as 别名]
# 或者: from horizons.ai.aiplayer.productionbuilder.ProductionBuilder import manage_production [as 别名]
#.........这里部分代码省略.........
ToggleActive(building.get_component(Producer), upgrade_production).execute(self.land_manager.session)
num_upgrading += 1
upgraded_any = True
if num_upgrading >= limit:
return True
return upgraded_any
def get_ideal_production_level(self, resource_id):
"""
Return the amount of resource per tick the settlement should produce.
This is the amount that should be produced to satisfy the people in this settlement,
keep up the current export rate, and fix the player's global deficit. This means
that different (feeder) islands will have different ideal production levels.
"""
total = 0.0
for settlement_manager in self.owner.settlement_managers:
usage = settlement_manager.get_resource_production_requirement(resource_id) * self.personality.production_level_multiplier
production = settlement_manager.get_resource_production(resource_id)
resource_import = settlement_manager.trade_manager.get_total_import(resource_id)
resource_export = settlement_manager.resource_manager.get_total_export(resource_id)
total += usage
if settlement_manager is not self:
total -= production + resource_export - resource_import
return max(0.0, total)
def _start_feeder_tick(self):
self.log.info('%s food requirement %.5f', self, self.get_ideal_production_level(RES.FOOD))
self.log.info('%s textile requirement %.5f', self, self.get_ideal_production_level(RES.TEXTILE))
self.log.info('%s liquor requirement %.5f', self, self.get_ideal_production_level(RES.LIQUOR))
self.log.info('%s salt requirement %.5f', self, self.get_ideal_production_level(RES.SALT))
self.log.info('%s tobacco products requirement %.5f', self, self.get_ideal_production_level(RES.TOBACCO_PRODUCTS))
self.production_builder.manage_production()
self.resource_manager.refresh()
def _end_feeder_tick(self):
self.resource_manager.replay_deep_low_priority_requests()
self.resource_manager.record_expected_exportable_production(self.owner.tick_interval)
self.resource_manager.manager_buysell()
self.resource_manager.finish_tick()
def _start_general_tick(self):
self.log.info('%s food production %.5f / %.5f', self, self.get_resource_production(RES.FOOD),
self.get_resource_production_requirement(RES.FOOD))
self.log.info('%s textile production %.5f / %.5f', self, self.get_resource_production(RES.TEXTILE),
self.get_resource_production_requirement(RES.TEXTILE))
self.log.info('%s get-together production %.5f / %.5f', self, self.get_resource_production(RES.GET_TOGETHER),
self.get_resource_production_requirement(RES.GET_TOGETHER))
self.log.info('%s salt production %.5f / %.5f', self, self.get_resource_production(RES.SALT),
self.get_resource_production_requirement(RES.SALT))
self.log.info('%s tobacco products production %.5f / %.5f', self, self.get_resource_production(RES.TOBACCO_PRODUCTS),
self.get_resource_production_requirement(RES.TOBACCO_PRODUCTS))
self.production_builder.manage_production()
self.trade_manager.refresh()
self.resource_manager.refresh()
self.need_materials = False
def refresh_taxes_and_upgrade_permissions(self):
# TODO: use a better system for managing settler upgrades and taxes
if self.land_manager.owner.settler_level == 0:
# if we are on level 0 and there is a house that can be upgraded then do it.
if self._manual_upgrade(0, 1):
self._set_taxes_and_permissions_prefix('early')
elif self.get_resource_production(RES.BRICKS) > 1e-9 and not self.settlement.count_buildings(BUILDINGS.VILLAGE_SCHOOL):
# if we just need the school then upgrade sailors manually