Ejemplo n.º 1
0
    def __init__(
        self,
        player_name: str,
        enemy_name: str,
        theater: ConflictTheater,
        start_date: datetime,
        settings: Settings,
        player_budget: float,
        enemy_budget: float,
    ) -> None:
        self.settings = settings
        self.events: List[Event] = []
        self.theater = theater
        self.player_name = player_name
        self.player_country = db.FACTIONS[player_name].country
        self.enemy_name = enemy_name
        self.enemy_country = db.FACTIONS[enemy_name].country
        self.turn = 0
        # NB: This is the *start* date. It is never updated.
        self.date = date(start_date.year, start_date.month, start_date.day)
        self.game_stats = GameStats()
        self.game_stats.update(self)
        self.ground_planners: Dict[int, GroundPlanner] = {}
        self.informations = []
        self.informations.append(Information("Game Start", "-" * 40, 0))
        # Culling Zones are for areas around points of interest that contain things we may not wish to cull.
        self.__culling_zones: List[Point] = []
        # Culling Points are for individual theater ground objects that we don't wish to cull.
        self.__culling_points: List[Point] = []
        self.__destroyed_units: List[str] = []
        self.savepath = ""
        self.budget = player_budget
        self.enemy_budget = enemy_budget
        self.current_unit_id = 0
        self.current_group_id = 0

        self.conditions = self.generate_conditions()

        self.blue_ato = AirTaskingOrder()
        self.red_ato = AirTaskingOrder()

        self.aircraft_inventory = GlobalAircraftInventory(
            self.theater.controlpoints)

        self.sanitize_sides()

        self.on_load()

        # Turn 0 procurement. We don't actually have any missions to plan, but
        # the planner will tell us what it would like to plan so we can use that
        # to drive purchase decisions.
        blue_planner = CoalitionMissionPlanner(self, is_player=True)
        blue_planner.plan_missions()

        red_planner = CoalitionMissionPlanner(self, is_player=False)
        red_planner.plan_missions()

        self.plan_procurement(blue_planner, red_planner)
Ejemplo n.º 2
0
    def initialize_turn_for(self, player: bool) -> None:
        """Processes coalition-specific turn initialization.

        For more information on turn initialization in general, see the documentation
        for `Game.initialize_turn`.

        Args:
            player: True if the player coalition is being initialized. False for opfor
            initialization.
        """
        self.ato_for(player).clear()
        self.air_wing_for(player).reset()

        self.aircraft_inventory.reset()
        for cp in self.theater.controlpoints:
            self.aircraft_inventory.set_from_control_point(cp)
            # Refund all pending deliveries for opfor and if player
            # has automate_aircraft_reinforcements
            if (not player and not cp.captured) or (
                    player and cp.captured
                    and self.settings.automate_aircraft_reinforcements):
                cp.pending_unit_deliveries.refund_all(self)

        # Plan flights & combat for next turn
        with logged_duration("Computing conflict positions"):
            self.compute_conflicts_position()
        with logged_duration("Threat zone computation"):
            self.compute_threat_zones()
        with logged_duration("Transit network identification"):
            self.compute_transit_networks()
        self.ground_planners = {}

        self.procurement_requests_for(player).clear()

        with logged_duration("Procurement of airlift assets"):
            self.transfers.order_airlift_assets()
        with logged_duration("Transport planning"):
            self.transfers.plan_transports()

        if not player or (player and self.settings.auto_ato_behavior
                          is not AutoAtoBehavior.Disabled):
            color = "Blue" if player else "Red"
            with logged_duration(f"{color} mission planning"):
                mission_planner = CoalitionMissionPlanner(self, player)
                mission_planner.plan_missions()

        self.plan_procurement_for(player)
Ejemplo n.º 3
0
    def __init__(self, player_name: str, enemy_name: str,
                 theater: ConflictTheater, start_date: datetime,
                 settings: Settings, player_budget: int,
                 enemy_budget: int) -> None:
        self.settings = settings
        self.events: List[Event] = []
        self.theater = theater
        self.player_name = player_name
        self.player_country = db.FACTIONS[player_name].country
        self.enemy_name = enemy_name
        self.enemy_country = db.FACTIONS[enemy_name].country
        self.turn = 0
        self.date = date(start_date.year, start_date.month, start_date.day)
        self.game_stats = GameStats()
        self.game_stats.update(self)
        self.ground_planners: Dict[int, GroundPlanner] = {}
        self.informations = []
        self.informations.append(Information("Game Start", "-" * 40, 0))
        self.__culling_points: List[Point] = []
        self.__destroyed_units: List[str] = []
        self.savepath = ""
        self.budget = player_budget
        self.enemy_budget = enemy_budget
        self.current_unit_id = 0
        self.current_group_id = 0

        self.conditions = self.generate_conditions()

        self.blue_ato = AirTaskingOrder()
        self.red_ato = AirTaskingOrder()

        self.aircraft_inventory = GlobalAircraftInventory(
            self.theater.controlpoints)

        for cp in self.theater.controlpoints:
            cp.pending_unit_deliveries = self.units_delivery_event(cp)

        self.sanitize_sides()

        self.on_load()

        # Turn 0 procurement. We don't actually have any missions to plan, but
        # the planner will tell us what it would like to plan so we can use that
        # to drive purchase decisions.
        blue_planner = CoalitionMissionPlanner(self, is_player=True)
        blue_planner.plan_missions()

        red_planner = CoalitionMissionPlanner(self, is_player=False)
        red_planner.plan_missions()

        self.plan_procurement(blue_planner, red_planner)
Ejemplo n.º 4
0
    def initialize_turn(self) -> None:
        self.events = []
        self._generate_events()

        # Update statistics
        self.game_stats.update(self)

        self.aircraft_inventory.reset()
        for cp in self.theater.controlpoints:
            self.aircraft_inventory.set_from_control_point(cp)

        # Plan flights & combat for next turn
        self.__culling_points = self.compute_conflicts_position()
        self.ground_planners = {}
        self.blue_ato.clear()
        self.red_ato.clear()
        CoalitionMissionPlanner(self, is_player=True).plan_missions()
        CoalitionMissionPlanner(self, is_player=False).plan_missions()
        for cp in self.theater.controlpoints:
            if cp.has_frontline:
                gplanner = GroundPlanner(cp, self)
                gplanner.plan_groundwar()
                self.ground_planners[cp.id] = gplanner
Ejemplo n.º 5
0
    def initialize_turn(self) -> None:
        self.events = []
        self._generate_events()

        # Update statistics
        self.game_stats.update(self)

        self.aircraft_inventory.reset()
        for cp in self.theater.controlpoints:
            self.aircraft_inventory.set_from_control_point(cp)

        # Check for win or loss condition
        turn_state = self.check_win_loss()
        if turn_state in (TurnState.LOSS, TurnState.WIN):
            return self.process_win_loss(turn_state)

        # Plan flights & combat for next turn
        self.compute_conflicts_position()
        self.compute_threat_zones()
        self.ground_planners = {}
        self.blue_ato.clear()
        self.red_ato.clear()

        blue_planner = CoalitionMissionPlanner(self, is_player=True)
        blue_planner.plan_missions()

        red_planner = CoalitionMissionPlanner(self, is_player=False)
        red_planner.plan_missions()

        for cp in self.theater.controlpoints:
            if cp.has_frontline:
                gplanner = GroundPlanner(cp, self)
                gplanner.plan_groundwar()
                self.ground_planners[cp.id] = gplanner

        self.plan_procurement(blue_planner, red_planner)