本文整理汇总了Python中CombatRatingsAI.get_ship_rating方法的典型用法代码示例。如果您正苦于以下问题:Python CombatRatingsAI.get_ship_rating方法的具体用法?Python CombatRatingsAI.get_ship_rating怎么用?Python CombatRatingsAI.get_ship_rating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CombatRatingsAI
的用法示例。
在下文中一共展示了CombatRatingsAI.get_ship_rating方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: issue_fleet_orders
# 需要导入模块: import CombatRatingsAI [as 别名]
# 或者: from CombatRatingsAI import get_ship_rating [as 别名]
#.........这里部分代码省略.........
debug("Check if PROTECT_REGION mission with target %d is finished.", last_sys_target)
fleet_id = self.fleet.id
if clear_all:
if orders:
debug("Fleet %d has completed its mission; clearing all orders and targets." % self.fleet.id)
debug("Full set of orders were:")
for this_order in orders:
debug("\t\t %s" % this_order)
self.clear_fleet_orders()
self.clear_target()
if aistate.get_fleet_role(fleet_id) in (MissionType.MILITARY, MissionType.SECURE):
allocations = MilitaryAI.get_military_fleets(mil_fleets_ids=[fleet_id],
try_reset=False,
thisround="Fleet %d Reassignment" % fleet_id)
if allocations:
MilitaryAI.assign_military_fleets_to_systems(use_fleet_id_list=[fleet_id],
allocations=allocations)
else: # no orders
debug("No Current Orders")
else:
potential_threat = CombatRatingsAI.combine_ratings(
MilitaryAI.get_system_local_threat(last_sys_target),
MilitaryAI.get_system_neighbor_threat(last_sys_target)
)
threat_present = potential_threat > 0
debug("Fleet threat present? %s", threat_present)
target_system = universe.getSystem(last_sys_target)
if not threat_present and target_system:
for pid in target_system.planetIDs:
planet = universe.getPlanet(pid)
if (planet and
planet.owner != fo.empireID() and
planet.currentMeterValue(fo.meterType.maxDefense) > 0):
debug("Found local planetary threat: %s", planet)
threat_present = True
break
if not threat_present:
debug("No current threat in target system; releasing a portion of ships.")
# at least first stage of current task is done;
# release extra ships for potential other deployments
new_fleets = FleetUtilsAI.split_fleet(self.fleet.id)
if self.type == MissionType.PROTECT_REGION:
self.clear_fleet_orders()
self.clear_target()
new_fleets.append(self.fleet.id)
else:
debug("Threat remains in target system; Considering to release some ships.")
new_fleets = []
fleet_portion_to_remain = self._portion_of_fleet_needed_here()
if fleet_portion_to_remain > 1:
debug("Can not release fleet yet due to large threat.")
elif fleet_portion_to_remain > 0:
debug("Not all ships are needed here - considering releasing a few")
fleet_remaining_rating = CombatRatingsAI.get_fleet_rating(fleet_id)
fleet_min_rating = fleet_portion_to_remain * fleet_remaining_rating
debug("Starting rating: %.1f, Target rating: %.1f",
fleet_remaining_rating, fleet_min_rating)
allowance = CombatRatingsAI.rating_needed(fleet_remaining_rating, fleet_min_rating)
debug("May release ships with total rating of %.1f", allowance)
ship_ids = list(self.fleet.get_object().shipIDs)
for ship_id in ship_ids:
ship_rating = CombatRatingsAI.get_ship_rating(ship_id)
debug("Considering to release ship %d with rating %.1f", ship_id, ship_rating)
if ship_rating > allowance:
debug("Remaining rating insufficient. Not released.")
continue
debug("Splitting from fleet.")
new_fleet_id = FleetUtilsAI.split_ship_from_fleet(fleet_id, ship_id)
if assertion_fails(new_fleet_id and new_fleet_id != INVALID_ID):
break
new_fleets.append(new_fleet_id)
fleet_remaining_rating = CombatRatingsAI.rating_difference(
fleet_remaining_rating, ship_rating)
allowance = CombatRatingsAI.rating_difference(
fleet_remaining_rating, fleet_min_rating)
debug("Remaining fleet rating: %.1f - Allowance: %.1f",
fleet_remaining_rating, allowance)
if new_fleets:
aistate.get_fleet_role(fleet_id, force_new=True)
aistate.update_fleet_rating(fleet_id)
aistate.ensure_have_fleet_missions(new_fleets)
else:
debug("Planetary defenses are deemed sufficient. Release fleet.")
new_fleets = FleetUtilsAI.split_fleet(self.fleet.id)
new_military_fleets = []
for fleet_id in new_fleets:
if aistate.get_fleet_role(fleet_id) in COMBAT_MISSION_TYPES:
new_military_fleets.append(fleet_id)
allocations = []
if new_military_fleets:
allocations = MilitaryAI.get_military_fleets(
mil_fleets_ids=new_military_fleets,
try_reset=False,
thisround="Fleet Reassignment %s" % new_military_fleets
)
if allocations:
MilitaryAI.assign_military_fleets_to_systems(use_fleet_id_list=new_military_fleets,
allocations=allocations)