本文整理汇总了Python中MoveUtilsAI.get_nearest_drydock_system_id方法的典型用法代码示例。如果您正苦于以下问题:Python MoveUtilsAI.get_nearest_drydock_system_id方法的具体用法?Python MoveUtilsAI.get_nearest_drydock_system_id怎么用?Python MoveUtilsAI.get_nearest_drydock_system_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveUtilsAI
的用法示例。
在下文中一共展示了MoveUtilsAI.get_nearest_drydock_system_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _need_repair
# 需要导入模块: import MoveUtilsAI [as 别名]
# 或者: from MoveUtilsAI import get_nearest_drydock_system_id [as 别名]
def _need_repair(self, repair_limit=0.70):
"""Check if fleet needs to be repaired.
If the fleet is already at a system where it can be repaired, stay there until fully repaired.
Otherwise, repair if fleet health is below specified *repair_limit*.
For military fleets, there is a special evaluation called, cf. *MilitaryAI.avail_mil_needing_repair()*
:param repair_limit: percentage of health below which the fleet is sent to repair
:type repair_limit: float
:return: True if fleet needs repair
:rtype: bool
"""
# TODO: More complex evaluation if fleet needs repair (consider self-repair, distance, threat, mission...)
universe = fo.getUniverse()
fleet_id = self.fleet.id
# if we are already at a system where we can repair, make sure we use it...
system = self.fleet.get_system()
# TODO starlane obstruction is not considered in the next call
nearest_dock = MoveUtilsAI.get_nearest_drydock_system_id(system.id)
if nearest_dock == system.id:
repair_limit = 0.99
# if combat fleet, use military repair check
if foAI.foAIstate.get_fleet_role(fleet_id) in COMBAT_MISSION_TYPES:
return fleet_id in MilitaryAI.avail_mil_needing_repair([fleet_id], on_mission=bool(self.orders),
repair_limit=repair_limit)[0]
# TODO: Allow to split fleet to send only damaged ships to repair
fleet = universe.getFleet(fleet_id)
ships_cur_health = 0
ships_max_health = 0
for ship_id in fleet.shipIDs:
this_ship = universe.getShip(ship_id)
ships_cur_health += this_ship.currentMeterValue(fo.meterType.structure)
ships_max_health += this_ship.currentMeterValue(fo.meterType.maxStructure)
return ships_cur_health < repair_limit * ships_max_health