當前位置: 首頁>>代碼示例>>Python>>正文


Python FleetUtilsAI.get_current_and_max_structure方法代碼示例

本文整理匯總了Python中FleetUtilsAI.get_current_and_max_structure方法的典型用法代碼示例。如果您正苦於以下問題:Python FleetUtilsAI.get_current_and_max_structure方法的具體用法?Python FleetUtilsAI.get_current_and_max_structure怎麽用?Python FleetUtilsAI.get_current_and_max_structure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FleetUtilsAI的用法示例。


在下文中一共展示了FleetUtilsAI.get_current_and_max_structure方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _need_repair

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import get_current_and_max_structure [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...)
        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_best_drydock_system_id(system.id, fleet_id)
        if nearest_dock == system.id:
            repair_limit = 0.99
        # if combat fleet, use military repair check
        if get_aistate().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
        ships_cur_health, ships_max_health = FleetUtilsAI.get_current_and_max_structure(fleet_id)
        return ships_cur_health < repair_limit * ships_max_health
開發者ID:adrianbroher,項目名稱:freeorion,代碼行數:29,代碼來源:AIFleetMission.py

示例2: issue_order

# 需要導入模塊: import FleetUtilsAI [as 別名]
# 或者: from FleetUtilsAI import get_current_and_max_structure [as 別名]
 def issue_order(self):
     if not super(OrderRepair, self).issue_order():
         return False
     fleet_id = self.fleet.id
     system_id = self.target.get_system().id
     fleet = self.fleet.get_object()  # type: fo.fleet
     if system_id == fleet.systemID:
         if foAI.foAIstate.get_fleet_role(fleet_id) == MissionType.EXPLORATION:
             if system_id in foAI.foAIstate.needsEmergencyExploration:
                 foAI.foAIstate.needsEmergencyExploration.remove(system_id)
     elif system_id != fleet.nextSystemID:
         fo.issueAggressionOrder(fleet_id, False)
         start_id = FleetUtilsAI.get_fleet_system(fleet)
         dest_id = MoveUtilsAI.get_safe_path_leg_to_dest(fleet_id, start_id, system_id)
         universe = fo.getUniverse()
         print "fleet %d with order type(%s) sent to safe leg dest %s and ultimate dest %s" % (
             fleet_id, self.ORDER_NAME, universe.getSystem(dest_id), universe.getSystem(system_id))
         fo.issueFleetMoveOrder(fleet_id, dest_id)
         print "Order issued: %s fleet: %s target: %s" % (self.ORDER_NAME, self.fleet, self.target)
     ships_cur_health, ships_max_health = FleetUtilsAI.get_current_and_max_structure(fleet_id)
     self.executed = (ships_cur_health == ships_max_health)
     return True
開發者ID:matt474,項目名稱:freeorion,代碼行數:24,代碼來源:fleet_orders.py


注:本文中的FleetUtilsAI.get_current_and_max_structure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。