本文整理汇总了Python中MilitaryAI.get_my_defense_rating_in_system方法的典型用法代码示例。如果您正苦于以下问题:Python MilitaryAI.get_my_defense_rating_in_system方法的具体用法?Python MilitaryAI.get_my_defense_rating_in_system怎么用?Python MilitaryAI.get_my_defense_rating_in_system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilitaryAI
的用法示例。
在下文中一共展示了MilitaryAI.get_my_defense_rating_in_system方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _portion_of_fleet_needed_here
# 需要导入模块: import MilitaryAI [as 别名]
# 或者: from MilitaryAI import get_my_defense_rating_in_system [as 别名]
def _portion_of_fleet_needed_here(self):
"""Calculate the portion of the fleet needed in target system considering enemy forces."""
# TODO check rating against planets
if assertion_fails(self.type in COMBAT_MISSION_TYPES, msg=str(self)):
return 0
if assertion_fails(self.target and self.target.id != INVALID_ID, msg=str(self)):
return 0
system_id = self.target.id
aistate = get_aistate()
local_defenses = MilitaryAI.get_my_defense_rating_in_system(system_id)
potential_threat = CombatRatingsAI.combine_ratings(
MilitaryAI.get_system_local_threat(system_id),
MilitaryAI.get_system_neighbor_threat(system_id)
)
universe = fo.getUniverse()
system = universe.getSystem(system_id)
# tally planetary defenses
total_defense = total_shields = 0
for planet_id in system.planetIDs:
planet = universe.getPlanet(planet_id)
total_defense += planet.currentMeterValue(fo.meterType.defense)
total_shields += planet.currentMeterValue(fo.meterType.shield)
planetary_ratings = total_defense * (total_shields + total_defense)
potential_threat += planetary_ratings # TODO: rewrite to return min rating vs planets as well
# consider safety factor just once here rather than everywhere below
safety_factor = aistate.character.military_safety_factor()
potential_threat *= safety_factor
fleet_rating = CombatRatingsAI.get_fleet_rating(self.fleet.id)
return CombatRatingsAI.rating_needed(potential_threat, local_defenses) / float(fleet_rating)