本文整理汇总了Python中MilitaryAI.get_military_fleets_with_target_system方法的典型用法代码示例。如果您正苦于以下问题:Python MilitaryAI.get_military_fleets_with_target_system方法的具体用法?Python MilitaryAI.get_military_fleets_with_target_system怎么用?Python MilitaryAI.get_military_fleets_with_target_system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilitaryAI
的用法示例。
在下文中一共展示了MilitaryAI.get_military_fleets_with_target_system方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trooper_move_reqs_met
# 需要导入模块: import MilitaryAI [as 别名]
# 或者: from MilitaryAI import get_military_fleets_with_target_system [as 别名]
def trooper_move_reqs_met(main_fleet_mission, order, verbose):
"""
Indicates whether or not move requirements specific to invasion troopers are met for the provided mission and order.
:type main_fleet_mission: AIFleetMission.AIFleetMission
:type order: OrderMove
:param verbose: whether to print verbose decision details
:type verbose: bool
:rtype: bool
"""
# Don't advance outside of our fleet-supply zone unless the target either has no shields at all or there
# is already a military fleet assigned to secure the target, and don't take final jump unless the planet is
# (to the AI's knowledge) down to zero shields. Additional checks will also be done by the later
# generic movement code
invasion_target = main_fleet_mission.target
invasion_planet = invasion_target.get_object()
invasion_system = invasion_target.get_system()
supplied_systems = fo.getEmpire().fleetSupplyableSystemIDs
# if about to leave supply lines
if order.target.id not in supplied_systems or fo.getUniverse().jumpDistance(order.fleet.id, invasion_system.id) < 5:
if invasion_planet.currentMeterValue(fo.meterType.maxShield):
military_support_fleets = MilitaryAI.get_military_fleets_with_target_system(invasion_system.id)
if not military_support_fleets:
if verbose:
print ("trooper_move_reqs_met() holding Invasion fleet %d before leaving supply "
"because target (%s) has nonzero max shields and there is not yet a military fleet "
"assigned to secure the target system.") % (order.fleet.id, invasion_planet)
return False
# if there is a threat in the enemy system, do give military ships at least 1 turn to clear it
delay_to_move_troops = 1 if MilitaryAI.get_system_local_threat(order.target.id) else 0
def eta(fleet_id):
return FleetUtilsAI.calculate_estimated_time_of_arrival(fleet_id, invasion_system.id)
eta_this_fleet = eta(order.fleet.id)
if all(((eta_this_fleet - delay_to_move_troops) <= eta(fid) and eta(fid))
for fid in military_support_fleets):
if verbose:
print ("trooper_move_reqs_met() holding Invasion fleet %d before leaving supply "
"because target (%s) has nonzero max shields and no assigned military fleet would arrive"
"at least %d turn earlier than the invasion fleet") % (
order.fleet.id, invasion_planet, delay_to_move_troops)
return False
if verbose:
print ("trooper_move_reqs_met() allowing Invasion fleet %d to leave supply "
"because target (%s) has zero max shields or there is a military fleet assigned to secure "
"the target system which will arrive at least 1 turn before the invasion fleet.") % (order.fleet.id,
invasion_planet)
return True