parameters: (self)
docstring: generates AIFleetOrders from fleets targets to accomplish
docstring_summary: generates AIFleetOrders from fleets targets to accomplish
docstring_tokens: generates AIFleetOrders from fleets targets to accomplish
function: def generate_fleet_orders(self):
          """generates AIFleetOrders from fleets targets to accomplish"""
          universe = fo.getUniverse()
          fleet_id = self.fleet.id
          fleet = universe.getFleet(fleet_id)
          if (not fleet) or fleet.empty or (fleet_id in universe.destroyedObjectIDs(fo.empireID())):
              # fleet was probably merged into another or was destroyed
              get_aistate().delete_fleet_info(fleet_id)
              return
  
          # TODO: priority
          self.clear_fleet_orders()
          system_id = fleet.systemID
          # if fleet doesn't have any mission,
          # then repair if needed or resupply if is current location not in supplyable system
          empire = fo.getEmpire()
          fleet_supplyable_system_ids = empire.fleetSupplyableSystemIDs
          # if (not self.hasAnyAIMissionTypes()):
          if not self.target and (
              system_id
              not in set(
                  AIstate.colonyTargetedSystemIDs + AIstate.outpostTargetedSystemIDs + AIstate.invasionTargetedSystemIDs
              )
          ):
              if self._need_repair():
                  repair_fleet_order = MoveUtilsAI.get_repair_fleet_order(self.fleet)
                  if repair_fleet_order and repair_fleet_order.is_valid():
                      self.orders.append(repair_fleet_order)
              cur_fighter_capacity, max_fighter_capacity = FleetUtilsAI.get_fighter_capacity_of_fleet(fleet_id)
              if (
                  fleet.fuel < fleet.maxFuel
                  or cur_fighter_capacity < max_fighter_capacity
                  and get_fleet_position(self.fleet.id) not in fleet_supplyable_system_ids
              ):
                  resupply_fleet_order = MoveUtilsAI.get_resupply_fleet_order(self.fleet)
                  if resupply_fleet_order.is_valid():
                      self.orders.append(resupply_fleet_order)
              return  # no targets
  
          if self.target:
              # for some targets fleet has to visit systems and therefore fleet visit them
  
              system_to_visit = (
                  self.target.get_system()
                  if not self.type == MissionType.PROTECT_REGION
                  else TargetSystem(self._get_target_for_protection_mission())
              )
              if not system_to_visit:
                  return
              orders_to_visit_systems = MoveUtilsAI.create_move_orders_to_system(self.fleet, system_to_visit)
              # TODO: if fleet doesn't have enough fuel to get to final target, consider resetting Mission
              for fleet_order in orders_to_visit_systems:
                  self.orders.append(fleet_order)
  
              # also generate appropriate final orders
              fleet_order = self._get_fleet_order_from_target(
                  self.type, self.target if not self.type == MissionType.PROTECT_REGION else system_to_visit
              )
              self.orders.append(fleet_order)
function_tokens: def generate_fleet_orders ( self ) : universe = fo . getUniverse ( ) fleet_id = self . fleet . id fleet = universe . getFleet ( fleet_id ) if ( not fleet ) or fleet . empty or ( fleet_id in universe . destroyedObjectIDs ( fo . empireID ( ) ) ) : # fleet was probably merged into another or was destroyed get_aistate ( ) . delete_fleet_info ( fleet_id ) return # TODO: priority self . clear_fleet_orders ( ) system_id = fleet . systemID # if fleet doesn't have any mission, # then repair if needed or resupply if is current location not in supplyable system empire = fo . getEmpire ( ) fleet_supplyable_system_ids = empire . fleetSupplyableSystemIDs # if (not self.hasAnyAIMissionTypes()): if not self . target and ( system_id not in set ( AIstate . colonyTargetedSystemIDs + AIstate . outpostTargetedSystemIDs + AIstate . invasionTargetedSystemIDs ) ) : if self . _need_repair ( ) : repair_fleet_order = MoveUtilsAI . get_repair_fleet_order ( self . fleet ) if repair_fleet_order and repair_fleet_order . is_valid ( ) : self . orders . append ( repair_fleet_order ) cur_fighter_capacity , max_fighter_capacity = FleetUtilsAI . get_fighter_capacity_of_fleet ( fleet_id ) if ( fleet . fuel < fleet . maxFuel or cur_fighter_capacity < max_fighter_capacity and get_fleet_position ( self . fleet . id ) not in fleet_supplyable_system_ids ) : resupply_fleet_order = MoveUtilsAI . get_resupply_fleet_order ( self . fleet ) if resupply_fleet_order . is_valid ( ) : self . orders . append ( resupply_fleet_order ) return # no targets if self . target : # for some targets fleet has to visit systems and therefore fleet visit them system_to_visit = ( self . target . get_system ( ) if not self . type == MissionType . PROTECT_REGION else TargetSystem ( self . _get_target_for_protection_mission ( ) ) ) if not system_to_visit : return orders_to_visit_systems = MoveUtilsAI . create_move_orders_to_system ( self . fleet , system_to_visit ) # TODO: if fleet doesn't have enough fuel to get to final target, consider resetting Mission for fleet_order in orders_to_visit_systems : self . orders . append ( fleet_order ) # also generate appropriate final orders fleet_order = self . _get_fleet_order_from_target ( self . type , self . target if not self . type == MissionType . PROTECT_REGION else system_to_visit ) self . orders . append ( fleet_order )