From fbd01fbfdbe204dc36a64829471101a15b30c981 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sun, 30 Jun 2019 05:31:22 +0200 Subject: [PATCH] WIP for possibility to select player and ennemy faction --- game/db.py | 225 ++++++++----- game/event/baseattack.py | 2 +- game/event/event.py | 4 +- game/event/intercept.py | 2 +- game/event/navalintercept.py | 2 +- game/game.py | 22 +- game/operation/baseattack.py | 8 +- game/operation/convoystrike.py | 4 +- game/operation/frontlineattack.py | 6 +- game/operation/frontlinepatrol.py | 4 +- game/operation/infantrytransport.py | 4 +- game/operation/insurgentattack.py | 4 +- game/operation/intercept.py | 8 +- game/operation/navalintercept.py | 8 +- game/operation/operation.py | 13 +- game/operation/strike.py | 6 +- gen/aaa.py | 374 +++++++++++----------- gen/airsupportgen.py | 8 +- gen/groundobjectsgen.py | 6 +- gen/triggergen.py | 2 +- gen/visualgen.py | 8 +- resources/tools/generate_loadout_check.py | 2 +- theater/caucasus.py | 2 +- theater/start_generator.py | 27 +- ui/basemenu.py | 10 +- ui/eventmenu.py | 2 +- ui/eventresultsmenu.py | 16 +- ui/newgamemenu.py | 12 +- ui/overviewcanvas.py | 4 +- ui/window.py | 4 + userdata/debriefing.py | 6 +- 31 files changed, 448 insertions(+), 357 deletions(-) diff --git a/game/db.py b/game/db.py index 5e0889df..b9b5f4a1 100644 --- a/game/db.py +++ b/game/db.py @@ -90,6 +90,7 @@ PRICES = { Armor.MBT_T_55: 22, Armor.MBT_T_80U: 28, Armor.MBT_T_90: 35, + Armor.APC_M113: 5, Armor.ATGM_M1134_Stryker: 18, Armor.MBT_M60A3_Patton: 24, @@ -263,6 +264,8 @@ AirDefense units that will be spawned at control points not related to the curre EXTRA_AA = { "Russia": AirDefence.SAM_SA_8_Osa_9A33, "USA": AirDefence.SAM_Linebacker_M6, + "Russia 1955": AirDefence.AAA_ZU_23_Closed, + "USA 1965": AirDefence.AAA_Vulcan_M163, } """ @@ -270,94 +273,160 @@ Units separated by country. Currently only Russia and USA are supported. Be advised that putting unit to the country that have not access to the unit in the game itself will result in incorrect missions generated! """ UNIT_BY_COUNTRY = { - "Russia": [ - AJS37, - MiG_23MLD, - F_5E_3, - Su_25, - Su_27, - Su_33, - MiG_15bis, - MiG_21Bis, - MiG_29A, - MiG_29S, - M_2000C, + "Russia 2010": { + "country": "Russia", + "units": [ + AJS37, + MiG_23MLD, + F_5E_3, + Su_25, + Su_27, + Su_33, + MiG_15bis, + MiG_21Bis, + MiG_29A, + MiG_29S, + M_2000C, - Su_25T, - Su_34, - L_39ZA, + Su_25T, + Su_34, + L_39ZA, - IL_76MD, - IL_78M, - An_26B, - An_30M, - Yak_40, - A_50, + IL_76MD, + IL_78M, + An_26B, + An_30M, + Yak_40, + A_50, - Ka_50, - SA342M, - UH_1H, - Mi_8MT, + Ka_50, + SA342M, + UH_1H, + Mi_8MT, - AirDefence.SPAAA_ZSU_23_4_Shilka, - AirDefence.SAM_SA_9_Strela_1_9P31, - AirDefence.SAM_SA_8_Osa_9A33, - AirDefence.AAA_ZU_23_Closed, - AirDefence.SAM_SA_19_Tunguska_2S6, - AirDefence.SAM_SA_6_Kub_LN_2P25, - AirDefence.SAM_SA_3_S_125_LN_5P73, - AirDefence.SAM_SA_11_Buk_LN_9A310M1, + AirDefence.SPAAA_ZSU_23_4_Shilka, + AirDefence.SAM_SA_9_Strela_1_9P31, + AirDefence.SAM_SA_8_Osa_9A33, + AirDefence.AAA_ZU_23_Closed, + AirDefence.SAM_SA_19_Tunguska_2S6, + AirDefence.SAM_SA_6_Kub_LN_2P25, + AirDefence.SAM_SA_3_S_125_LN_5P73, + AirDefence.SAM_SA_11_Buk_LN_9A310M1, - Armor.APC_BTR_80, - Armor.MBT_T_90, - Armor.MBT_T_80U, - Armor.MBT_T_55, - Unarmed.Transport_Ural_375, - Unarmed.Transport_UAZ_469, - Infantry.Soldier_AK, - CV_1143_5_Admiral_Kuznetsov, - Bulk_cargo_ship_Yakushev, - Dry_cargo_ship_Ivanov, - Tanker_Elnya_160, - ], + Armor.APC_BTR_80, + Armor.MBT_T_90, + Armor.MBT_T_80U, + Armor.MBT_T_55, + Unarmed.Transport_Ural_375, + Unarmed.Transport_UAZ_469, + Infantry.Soldier_AK, + CV_1143_5_Admiral_Kuznetsov, + Bulk_cargo_ship_Yakushev, + Dry_cargo_ship_Ivanov, + Tanker_Elnya_160, + ] + }, - "USA": [ - F_5E_3, - F_15C, - F_14B, - FA_18C_hornet, - AJS37, - M_2000C, - MiG_21Bis, - MiG_15bis, + "Russia 1955": { + "country": "Russia", + "units": [ + MiG_15bis, - A_10A, - A_10C, - AV8BNA, + IL_76MD, + IL_78M, + An_26B, + An_30M, + Yak_40, - KC_135, - S_3B_Tanker, - C_130, - E_3A, + A_50, - Ka_50, - SA342M, - UH_1H, - Mi_8MT, + Mi_8MT, - Armor.MBT_M1A2_Abrams, - Armor.MBT_M60A3_Patton, - Armor.ATGM_M1134_Stryker, - Unarmed.Transport_M818, - Infantry.Infantry_M4, + AirDefence.AAA_ZU_23_Closed, + AirDefence.SAM_SA_6_Kub_LN_2P25, + AirDefence.SAM_SA_3_S_125_LN_5P73, - AirDefence.AAA_Vulcan_M163, - AirDefence.SAM_Linebacker_M6, + Armor.APC_BTR_80, + Armor.MBT_T_55, + Unarmed.Transport_Ural_375, + Unarmed.Transport_UAZ_469, + Infantry.Soldier_AK, + CV_1143_5_Admiral_Kuznetsov, + Bulk_cargo_ship_Yakushev, + Dry_cargo_ship_Ivanov, + Tanker_Elnya_160 + ] + }, - CVN_74_John_C__Stennis, - LHA_1_Tarawa, - Armed_speedboat, - ], + "USA 2010": { + "country":"USA", + "units":[ + F_5E_3, + F_15C, + F_14B, + FA_18C_hornet, + AJS37, + M_2000C, + MiG_21Bis, + MiG_15bis, + + A_10A, + A_10C, + AV8BNA, + + KC_135, + S_3B_Tanker, + C_130, + E_3A, + + Ka_50, + SA342M, + UH_1H, + Mi_8MT, + + Armor.MBT_M1A2_Abrams, + Armor.MBT_M60A3_Patton, + Armor.ATGM_M1134_Stryker, + Unarmed.Transport_M818, + Infantry.Infantry_M4, + + AirDefence.AAA_Vulcan_M163, + AirDefence.SAM_Linebacker_M6, + + CVN_74_John_C__Stennis, + LHA_1_Tarawa, + Armed_speedboat, + ] + }, + + "USA 1965": { + "country":"USA", + "units":[ + F_86F_Sabre, + F_5E_3, + + A_10A, + + KC_135, + S_3B_Tanker, + C_130, + E_3A, + + UH_1H, + + Armor.MBT_M60A3_Patton, + Armor.APC_M113, + Unarmed.Transport_M818, + Infantry.Infantry_M4, + + AirDefence.AAA_Vulcan_M163, + AirDefence.SAM_Linebacker_M6, + + CVN_74_John_C__Stennis, + LHA_1_Tarawa, + Armed_speedboat, + ] + }, } CARRIER_TYPE_BY_PLANE = { @@ -519,7 +588,7 @@ def unit_task(unit: UnitType) -> Task: def find_unittype(for_task: Task, country_name: str) -> typing.List[UnitType]: - return [x for x in UNIT_BY_TASK[for_task] if x in UNIT_BY_COUNTRY[country_name]] + return [x for x in UNIT_BY_TASK[for_task] if x in UNIT_BY_COUNTRY[country_name]["units"]] def unit_type_name(unit_type) -> str: @@ -649,7 +718,7 @@ def _validate_db(): for unit_type in total_set: did_find = False for country_units_list in UNIT_BY_COUNTRY.values(): - if unit_type in country_units_list: + if unit_type in country_units_list["units"]: did_find = True assert did_find, "{} not in country list".format(unit_type) diff --git a/game/event/baseattack.py b/game/event/baseattack.py index dfe08ff1..a6bc4a7d 100644 --- a/game/event/baseattack.py +++ b/game/event/baseattack.py @@ -39,7 +39,7 @@ class BaseAttackEvent(Event): if self.departure_cp.captured: self.to_cp.captured = True self.to_cp.ground_objects = [] - self.to_cp.base.filter_units(db.UNIT_BY_COUNTRY[self.attacker_name]) + self.to_cp.base.filter_units(db.UNIT_BY_COUNTRY[self.attacker_name]["units"]) self.to_cp.base.affect_strength(+self.STRENGTH_RECOVERY) else: diff --git a/game/event/event.py b/game/event/event.py index d0475472..dffed6d4 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -47,11 +47,11 @@ class Event: @property def is_player_attacking(self) -> bool: - return self.attacker_name == self.game.player + return self.attacker_name == self.game.player_name @property def enemy_cp(self) -> ControlPoint: - if self.attacker_name == self.game.player: + if self.attacker_name == self.game.player_name: return self.to_cp else: return self.departure_cp diff --git a/game/event/intercept.py b/game/event/intercept.py index 9c14e753..4e609c93 100644 --- a/game/event/intercept.py +++ b/game/event/intercept.py @@ -51,7 +51,7 @@ class InterceptEvent(Event): def commit(self, debriefing: Debriefing): super(InterceptEvent, self).commit(debriefing) - if self.attacker_name == self.game.player: + if self.attacker_name == self.game.player_name: if self.is_successfull(debriefing): for _, cp in self.game.theater.conflicts(True): cp.base.affect_strength(-self.STRENGTH_INFLUENCE) diff --git a/game/event/navalintercept.py b/game/event/navalintercept.py index f29bcb8a..baba7bc8 100644 --- a/game/event/navalintercept.py +++ b/game/event/navalintercept.py @@ -61,7 +61,7 @@ class NavalInterceptEvent(Event): def commit(self, debriefing: Debriefing): super(NavalInterceptEvent, self).commit(debriefing) - if self.attacker_name == self.game.player: + if self.attacker_name == self.game.player_name: if self.is_successfull(debriefing): self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE) else: diff --git a/game/game.py b/game/game.py index f5303a66..cf21d4d6 100644 --- a/game/game.py +++ b/game/game.py @@ -102,8 +102,10 @@ class Game: self.settings = Settings() self.events = [] self.theater = theater - self.player = player_name - self.enemy = enemy_name + self.player_name = player_name + self.player_country = db.UNIT_BY_COUNTRY[player_name]["country"] + self.enemy_name = enemy_name + self.enemy_country = db.UNIT_BY_COUNTRY[enemy_name]["country"] self.turn = 0 self.date = datetime(start_date.year, start_date.month, start_date.day) @@ -127,7 +129,7 @@ class Game: # skip strikes in case of no targets return - self.events.append(event_class(self, player_cp, enemy_cp, enemy_cp.position, self.player, self.enemy)) + self.events.append(event_class(self, player_cp, enemy_cp, enemy_cp.position, self.player_name, self.enemy_name)) def _generate_enemy_event(self, event_class, player_cp, enemy_cp): if event_class in [type(x) for x in self.events if not self.is_player_attack(x)]: @@ -167,7 +169,7 @@ class Game: # skip base attack if strength is too high return - self.events.append(event_class(self, enemy_cp, player_cp, player_cp.position, self.enemy, self.player)) + self.events.append(event_class(self, enemy_cp, player_cp, player_cp.position, self.enemy_name, self.player_name)) def _generate_events(self): strikes_generated_for = set() @@ -202,9 +204,9 @@ class Game: importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW) if for_task == AirDefence and not self.settings.sams: - return [x for x in db.find_unittype(AirDefence, self.enemy) if x not in db.SAM_BAN] + return [x for x in db.find_unittype(AirDefence, self.enemy_name) if x not in db.SAM_BAN] else: - return db.choose_units(for_task, importance_factor, COMMISION_UNIT_VARIETY, self.enemy) + return db.choose_units(for_task, importance_factor, COMMISION_UNIT_VARIETY, self.enemy_country) def _commision_units(self, cp: ControlPoint): for for_task in [PinpointStrike, CAS, CAP, AirDefence]: @@ -234,8 +236,8 @@ class Game: self.budget -= AWACS_BUDGET_COST def units_delivery_event(self, to_cp: ControlPoint) -> UnitsDeliveryEvent: - event = UnitsDeliveryEvent(attacker_name=self.player, - defender_name=self.player, + event = UnitsDeliveryEvent(attacker_name=self.player_name, + defender_name=self.player_name, from_cp=to_cp, to_cp=to_cp, game=self) @@ -267,9 +269,9 @@ class Game: def is_player_attack(self, event): if isinstance(event, Event): - return event.attacker_name == self.player + return event.attacker_name == self.player_name else: - return event.name == self.player + return event.name == self.player_name def pass_turn(self, no_action=False, ignored_cps: typing.Collection[ControlPoint]=None): logging.info("Pass turn") diff --git a/game/operation/baseattack.py b/game/operation/baseattack.py index f87ced61..73822cf2 100644 --- a/game/operation/baseattack.py +++ b/game/operation/baseattack.py @@ -33,12 +33,12 @@ class BaseAttackOperation(Operation): super(BaseAttackOperation, self).prepare(terrain, is_quick) self.defenders_starting_position = None - if self.game.player == self.defender_name: + if self.game.player_name == self.defender_name: self.attackers_starting_position = None conflict = Conflict.capture_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater @@ -60,7 +60,7 @@ class BaseAttackOperation(Operation): self.briefinggen.title = "Base attack" self.briefinggen.description = "The goal of an attacker is to lower defender presence by destroying their armor and aircraft. Base will be considered captured if attackers on the ground overrun the defenders. Be advised that your flight will not attack anything until you explicitly tell them so by comms menu." - if self.game.player == self.attacker_name: + if self.game.player_name == self.attacker_name: self.briefinggen.append_waypoint("TARGET") else: pass diff --git a/game/operation/convoystrike.py b/game/operation/convoystrike.py index c38a2eed..07ae3e4c 100644 --- a/game/operation/convoystrike.py +++ b/game/operation/convoystrike.py @@ -17,8 +17,8 @@ class ConvoyStrikeOperation(Operation): super(ConvoyStrikeOperation, self).prepare(terrain, is_quick) conflict = Conflict.convoy_strike_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/game/operation/frontlineattack.py b/game/operation/frontlineattack.py index a9272cb6..9f412fe6 100644 --- a/game/operation/frontlineattack.py +++ b/game/operation/frontlineattack.py @@ -29,13 +29,13 @@ class FrontlineAttackOperation(Operation): def prepare(self, terrain: Terrain, is_quick: bool): super(FrontlineAttackOperation, self).prepare(terrain, is_quick) - if self.defender_name == self.game.player: + if self.defender_name == self.game.player_name: self.attackers_starting_position = None self.defenders_starting_position = None conflict = Conflict.frontline_cas_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/game/operation/frontlinepatrol.py b/game/operation/frontlinepatrol.py index 631d89fe..a6446920 100644 --- a/game/operation/frontlinepatrol.py +++ b/game/operation/frontlinepatrol.py @@ -32,8 +32,8 @@ class FrontlinePatrolOperation(Operation): self.defenders_starting_position = None conflict = Conflict.frontline_cap_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/game/operation/infantrytransport.py b/game/operation/infantrytransport.py index 4ff4128d..07226cc0 100644 --- a/game/operation/infantrytransport.py +++ b/game/operation/infantrytransport.py @@ -15,8 +15,8 @@ class InfantryTransportOperation(Operation): super(InfantryTransportOperation, self).prepare(terrain, is_quick) conflict = Conflict.transport_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/game/operation/insurgentattack.py b/game/operation/insurgentattack.py index 0afe950c..36c18190 100644 --- a/game/operation/insurgentattack.py +++ b/game/operation/insurgentattack.py @@ -17,8 +17,8 @@ class InsurgentAttackOperation(Operation): super(InsurgentAttackOperation, self).prepare(terrain, is_quick) conflict = Conflict.ground_attack_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/game/operation/intercept.py b/game/operation/intercept.py index 19ac6b72..1e3feb7e 100644 --- a/game/operation/intercept.py +++ b/game/operation/intercept.py @@ -27,12 +27,12 @@ class InterceptOperation(Operation): def prepare(self, terrain: Terrain, is_quick: bool): super(InterceptOperation, self).prepare(terrain, is_quick) self.defenders_starting_position = None - if self.defender_name == self.game.player: + if self.defender_name == self.game.player_name: self.attackers_starting_position = None conflict = Conflict.intercept_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), position=self.location, from_cp=self.from_cp, to_cp=self.to_cp, @@ -53,7 +53,7 @@ class InterceptOperation(Operation): self.briefinggen.title = "Air Intercept" - if self.game.player == self.attacker_name: + if self.game.player_name == self.attacker_name: self.briefinggen.description = "Intercept enemy supply transport aircraft. Escort will also be present if there are available planes on the base. Operation will be considered successful if most of the targets are destroyed, lowering targets strength as a result" self.briefinggen.append_waypoint("TARGET") for unit_type, count in self.transport.items(): diff --git a/game/operation/navalintercept.py b/game/operation/navalintercept.py index 5c30581d..9033be40 100644 --- a/game/operation/navalintercept.py +++ b/game/operation/navalintercept.py @@ -22,12 +22,12 @@ class NavalInterceptionOperation(Operation): def prepare(self, terrain: Terrain, is_quick: bool): super(NavalInterceptionOperation, self).prepare(terrain, is_quick) - if self.defender_name == self.game.player: + if self.defender_name == self.game.player_name: self.attackers_starting_position = None conflict = Conflict.naval_intercept_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), position=self.location, from_cp=self.from_cp, to_cp=self.to_cp, @@ -55,7 +55,7 @@ class NavalInterceptionOperation(Operation): ) self.briefinggen.title = "Naval Intercept" - if self.game.player == self.attacker_name: + if self.game.player_name == self.attacker_name: self.briefinggen.description = "Destroy supply transport ships. Lowers target strength. Be advised that your flight will not attack anything until you explicitly tell them so by comms menu." for unit_type, count in self.targets.items(): self.briefinggen.append_target("{} ({})".format(db.unit_type_name(unit_type), count)) diff --git a/game/operation/operation.py b/game/operation/operation.py index a035b808..1cf81c92 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -43,7 +43,10 @@ class Operation: to_cp: ControlPoint = None): self.game = game self.attacker_name = attacker_name + self.attacker_country = db.UNIT_BY_COUNTRY[attacker_name]["country"] self.defender_name = defender_name + self.defender_country = db.UNIT_BY_COUNTRY[defender_name]["country"] + print(self.defender_country, self.attacker_country) self.from_cp = from_cp self.departure_cp = departure_cp self.to_cp = to_cp @@ -74,9 +77,9 @@ class Operation: self.groundobjectgen = GroundObjectsGenerator(mission, conflict, self.game) self.briefinggen = BriefingGenerator(mission, conflict, self.game) - player_name = self.from_cp.captured and self.attacker_name or self.defender_name - enemy_name = self.from_cp.captured and self.defender_name or self.attacker_name - self.extra_aagen = ExtraAAConflictGenerator(mission, conflict, self.game, player_name, enemy_name) + player_country = self.from_cp.captured and self.attacker_country or self.defender_country + enemy_country = self.from_cp.captured and self.defender_country or self.attacker_country + self.extra_aagen = ExtraAAConflictGenerator(mission, conflict, self.game, player_country, enemy_country) def prepare(self, terrain: Terrain, is_quick: bool): with open("resources/default_options.lua", "r") as f: @@ -104,7 +107,7 @@ class Operation: return ship = self.shipgen.generate_carrier(for_units=[t for t, c in for_units.items() if c > 0], - country=self.game.player, + country=self.game.player_country, at=self.departure_cp.at) if not self.is_quick: @@ -124,7 +127,7 @@ class Operation: # combined arms self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 - if self.game.player in [country.name for country in self.current_mission.coalition["blue"].countries.values()]: + if self.game.player_country in [country.name for country in self.current_mission.coalition["blue"].countries.values()]: self.current_mission.groundControl.blue_tactical_commander = self.ca_slots else: self.current_mission.groundControl.red_tactical_commander = self.ca_slots diff --git a/game/operation/strike.py b/game/operation/strike.py index 84b4eed5..d777e6f6 100644 --- a/game/operation/strike.py +++ b/game/operation/strike.py @@ -25,12 +25,12 @@ class StrikeOperation(Operation): super(StrikeOperation, self).prepare(terrain, is_quick) self.defenders_starting_position = None - if self.game.player == self.defender_name: + if self.game.player_name == self.defender_name: self.attackers_starting_position = None conflict = Conflict.strike_conflict( - attacker=self.current_mission.country(self.attacker_name), - defender=self.current_mission.country(self.defender_name), + attacker=self.current_mission.country(self.attacker_country), + defender=self.current_mission.country(self.defender_country), from_cp=self.from_cp, to_cp=self.to_cp, theater=self.game.theater diff --git a/gen/aaa.py b/gen/aaa.py index 3b2b0426..930b63b3 100644 --- a/gen/aaa.py +++ b/gen/aaa.py @@ -52,7 +52,7 @@ def determine_positions(position, heading, num_units, launcher_distance, coverag def aaa_vehicle_group(self, country, name, _type: unittype.VehicleType, position: mapping.Point, - heading=0, group_size=1, + heading=0, formation=unitgroup.VehicleGroup.Formation.Line, move_formation: PointAction=PointAction.OffRoad): """ @@ -62,208 +62,208 @@ def aaa_vehicle_group(self, country, name, _type: unittype.VehicleType, position """ vg = unitgroup.VehicleGroup(self.next_group_id(), self.string(name)) - for i in range(1, group_size + 1): - heading = randint(0, 359) - if _type == AirDefence.SAM_SA_3_S_125_LN_5P73: - # 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR - num_launchers = 4 - # search radar + heading = randint(0, 359) + if _type == AirDefence.SAM_SA_3_S_125_LN_5P73: + # 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR + num_launchers = 4 + # search radar + v = self.vehicle( + name + " Unit #{nr}".format(nr=1), + AirDefence.SAM_SR_P_19, + ) + v.position.x = position.x + v.position.y = position.y + v.heading = heading + vg.add_unit(v) + # track radar + v = self.vehicle( + name + " Unit #{nr}".format(nr=2), + AirDefence.SAM_SA_3_S_125_TR_SNR, + ) + + center_x = position.x + randint(20, 40) + center_y = position.y + + v.position.x = center_x + v.position.y = center_y + v.heading = heading + vg.add_unit(v) + plop_positions = determine_positions( + position, + heading, + num_launchers, + launcher_distance=100, + coverage=180, + ) + for x in range(0, num_launchers): v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SR_P_19, + name + " Unit #{nr}".format(nr=3+x), + AirDefence.SAM_SA_3_S_125_LN_5P73, ) - v.position.x = position.x - v.position.y = position.y + (i - 1) * 20 - v.heading = heading + + v.position.x = plop_positions[x][0] + v.position.y = plop_positions[x][1] + v.heading = plop_positions[x][2] vg.add_unit(v) - # track radar + + elif _type == AirDefence.SAM_SA_6_Kub_LN_2P25: + # 6 launchers (360 degree coverage) + # 1 S/TR + # search/track radar + num_launchers = 6 + v = self.vehicle( + name + " Unit #{nr}".format(nr=1), + AirDefence.SAM_SA_6_Kub_STR_9S91, + ) + v.position.x = position.x + v.position.y = position.y + v.heading = heading + vg.add_unit(v) + + plop_positions = determine_positions( + position, + heading, + num_launchers, + launcher_distance=100, + coverage=360, + ) + for x in range(0, num_launchers): v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_3_S_125_TR_SNR, + name + " Unit #{nr}".format(nr=1+x), + AirDefence.SAM_SA_6_Kub_LN_2P25, ) - center_x = position.x + randint(20, 40) - center_y = position.y + (i - 1) * 20 - - v.position.x = center_x - v.position.y = center_y - v.heading = heading + v.position.x = plop_positions[x][0] + v.position.y = plop_positions[x][1] + v.heading = plop_positions[x][2] vg.add_unit(v) - plop_positions = determine_positions( - position, - heading, - num_launchers, - launcher_distance=100, - coverage=180, - ) - for x in range(0, num_launchers): - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_3_S_125_LN_5P73, - ) + elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C: + # 8 launchers - 4 directions, two in each direction + # 1 SR (offset) + # 1 TR (center) + # search radar + num_launchers = 8 + v = self.vehicle( + name + " Unit #{nr}".format(nr=1), + AirDefence.SAM_SA_10_S_300PS_SR_5N66M, + ) + v.position.x = position.x + v.position.y = position.y + v.heading = heading + vg.add_unit(v) + # track radar + v = self.vehicle( + name + " Unit #{nr}".format(nr=2), + AirDefence.SAM_SA_10_S_300PS_TR_30N6, + ) - v.position.x = plop_positions[x][0] - v.position.y = plop_positions[x][1] - v.heading = plop_positions[x][2] - vg.add_unit(v) + center_x = position.x + randint(20, 40) + center_y = position.y - elif _type == AirDefence.SAM_SA_6_Kub_LN_2P25: - # 6 launchers (360 degree coverage) - # 1 S/TR - # search/track radar - num_launchers = 6 + v.position.x = center_x + v.position.y = center_y + v.heading = heading + vg.add_unit(v) + # command center + v = self.vehicle( + name + " Unit #{nr}".format(nr=3), + AirDefence.SAM_SA_10_S_300PS_CP_54K6, + ) + + center_x = position.x + randint(40, 60) + center_y = position.y + + v.position.x = center_x + v.position.y = center_y + v.heading = heading + vg.add_unit(v) + + plop_positions = determine_positions( + position, + heading, + num_launchers, + launcher_distance=150, + coverage=360, + ) + for x in range(0, num_launchers): v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_6_Kub_STR_9S91, + name + " Unit #{nr}".format(nr=3+x), + AirDefence.SAM_SA_10_S_300PS_LN_5P85C, ) - v.position.x = position.x - v.position.y = position.y + (i - 1) * 20 - v.heading = heading + + v.position.x = plop_positions[x][0] + v.position.y = plop_positions[x][1] + v.heading = plop_positions[x][2] vg.add_unit(v) - plop_positions = determine_positions( - position, - heading, - num_launchers, - launcher_distance=100, - coverage=360, - ) - for x in range(0, num_launchers): - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_6_Kub_LN_2P25, - ) + elif _type == AirDefence.SAM_SA_10_S_300PS_CP_54K6: + # 8 launchers - 4 directions, two in each direction + # 1 SR (offset) + # 1 TR (center) + # search radar + num_launchers = 8 + v = self.vehicle( + name + " Unit #{nr}".format(nr=1), + AirDefence.SAM_SA_10_S_300PS_SR_64H6E, + ) + v.position.x = position.x + v.position.y = position.y + v.heading = heading + vg.add_unit(v) + # track radar + v = self.vehicle( + name + " Unit #{nr}".format(nr=2), + AirDefence.SAM_SA_10_S_300PS_TR_30N6, + ) - v.position.x = plop_positions[x][0] - v.position.y = plop_positions[x][1] - v.heading = plop_positions[x][2] - vg.add_unit(v) - elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C: - # 8 launchers - 4 directions, two in each direction - # 1 SR (offset) - # 1 TR (center) - # search radar - num_launchers = 8 + center_x = position.x + randint(20, 40) + center_y = position.y + + v.position.x = center_x + v.position.y = center_y + v.heading = heading + vg.add_unit(v) + # command center + v = self.vehicle( + name + " Unit #{nr}".format(nr=3), + AirDefence.SAM_SA_10_S_300PS_CP_54K6, + ) + + center_x = position.x + randint(40, 60) + center_y = position.y + + v.position.x = center_x + v.position.y = center_y + v.heading = heading + vg.add_unit(v) + + plop_positions = determine_positions( + position, + heading, + num_units=num_launchers, + launcher_distance=150, + coverage=360, + ) + for x in range(0, num_launchers): v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_SR_5N66M, + name + " Unit #{nr}".format(nr=3+x), + AirDefence.SAM_SA_10_S_300PS_LN_5P85D, ) - v.position.x = position.x - v.position.y = position.y + (i - 1) * 20 - v.heading = heading - vg.add_unit(v) - # track radar - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_TR_30N6, - ) - - center_x = position.x + randint(20, 40) - center_y = position.y + (i - 1) * 20 - - v.position.x = center_x - v.position.y = center_y - v.heading = heading - vg.add_unit(v) - # command center - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_CP_54K6, - ) - - center_x = position.x + randint(40, 60) - center_y = position.y + (i - 1) * 20 - - v.position.x = center_x - v.position.y = center_y - v.heading = heading - vg.add_unit(v) - - plop_positions = determine_positions( - position, - heading, - num_launchers, - launcher_distance=150, - coverage=360, - ) - for x in range(0, num_launchers): - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_LN_5P85C, - ) - - v.position.x = plop_positions[x][0] - v.position.y = plop_positions[x][1] - v.heading = plop_positions[x][2] - vg.add_unit(v) - - elif _type == AirDefence.SAM_SA_10_S_300PS_CP_54K6: - # 8 launchers - 4 directions, two in each direction - # 1 SR (offset) - # 1 TR (center) - # search radar - num_launchers = 8 - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_SR_64H6E, - ) - v.position.x = position.x - v.position.y = position.y + (i - 1) * 20 - v.heading = heading - vg.add_unit(v) - # track radar - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_TR_30N6, - ) - - center_x = position.x + randint(20, 40) - center_y = position.y + (i - 1) * 20 - - v.position.x = center_x - v.position.y = center_y - v.heading = heading - vg.add_unit(v) - # command center - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_CP_54K6, - ) - - center_x = position.x + randint(40, 60) - center_y = position.y + (i - 1) * 20 - - v.position.x = center_x - v.position.y = center_y - v.heading = heading - vg.add_unit(v) - - plop_positions = determine_positions( - position, - heading, - num_units=num_launchers, - launcher_distance=150, - coverage=360, - ) - for x in range(0, num_launchers): - v = self.vehicle( - name + " Unit #{nr}".format(nr=i), - AirDefence.SAM_SA_10_S_300PS_LN_5P85D, - ) - - v.position.x = plop_positions[x][0] - v.position.y = plop_positions[x][1] - v.heading = plop_positions[x][2] - vg.add_unit(v) - else: - v = self.vehicle(name + " Unit #{nr}".format(nr=i), _type) - v.position.x = position.x - v.position.y = position.y + (i - 1) * 20 - v.heading = heading + + v.position.x = plop_positions[x][0] + v.position.y = plop_positions[x][1] + v.heading = plop_positions[x][2] vg.add_unit(v) + else: + v = self.vehicle(name + " Unit #{nr}".format(nr=1), _type) + v.position.x = position.x + v.position.y = position.y # + (i - 1) * 20 + v.heading = heading + vg.add_unit(v) wp = vg.add_waypoint(vg.units[0].position, move_formation, 0) wp.ETA_locked = True + if _type.eplrs: wp.tasks.append(task.EPLRS(self.next_eplrs("vehicle"))) @@ -301,12 +301,12 @@ class AAConflictGenerator: class ExtraAAConflictGenerator: - def __init__(self, mission: Mission, conflict: Conflict, game, player_name: Country, enemy_name: Country): + def __init__(self, mission: Mission, conflict: Conflict, game, player_country: Country, enemy_country: Country): self.mission = mission self.game = game self.conflict = conflict - self.player_name = player_name - self.enemy_name = enemy_name + self.player_country = player_country + self.enemy_country = enemy_country def generate(self): from theater.conflicttheater import ControlPoint @@ -327,7 +327,7 @@ class ExtraAAConflictGenerator: if cp.position.distance_to_point(self.conflict.position) > EXTRA_AA_MAX_DISTANCE: continue - country_name = cp.captured and self.player_name or self.enemy_name + country_name = cp.captured and self.player_country or self.enemy_country position = cp.position.point_from_heading(0, EXTRA_AA_POSITION_FROM_CP) self.mission.vehicle_group( diff --git a/gen/airsupportgen.py b/gen/airsupportgen.py index caad2d49..3d63b9c7 100644 --- a/gen/airsupportgen.py +++ b/gen/airsupportgen.py @@ -37,8 +37,8 @@ class AirSupportConflictGenerator: tanker_heading = self.conflict.to_cp.position.heading_between_point(self.conflict.from_cp.position) + TANKER_HEADING_OFFSET * i tanker_position = player_cp.position.point_from_heading(tanker_heading, TANKER_DISTANCE) tanker_group = self.mission.refuel_flight( - country=self.mission.country(self.game.player), - name=namegen.next_tanker_name(self.mission.country(self.game.player)), + country=self.mission.country(self.game.player_country), + name=namegen.next_tanker_name(self.mission.country(self.game.player_country)), airport=None, plane_type=tanker_unit_type, position=tanker_position, @@ -55,8 +55,8 @@ class AirSupportConflictGenerator: if is_awacs_enabled: awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side.name)[0] awacs_flight = self.mission.awacs_flight( - country=self.mission.country(self.game.player), - name=namegen.next_awacs_name(self.mission.country(self.game.player)), + country=self.mission.country(self.game.player_country), + name=namegen.next_awacs_name(self.mission.country(self.game.player_country)), plane_type=awacs_unit, altitude=AWACS_ALT, airport=None, diff --git a/gen/groundobjectsgen.py b/gen/groundobjectsgen.py index dd5df011..41d6dff9 100644 --- a/gen/groundobjectsgen.py +++ b/gen/groundobjectsgen.py @@ -36,16 +36,16 @@ class GroundObjectsGenerator: position = position.point_from_heading(0, i * 275) yield self.m.farp( - country=self.m.country(self.game.player), + country=self.m.country(self.game.player_country), name="FARP", position=position, ) def generate(self): - side = self.m.country(self.game.enemy) + side = self.m.country(self.game.enemy_country) cp = None # type: ControlPoint - if self.conflict.attackers_side.name == self.game.player: + if self.conflict.attackers_side.name == self.game.player_country: cp = self.conflict.to_cp else: cp = self.conflict.from_cp diff --git a/gen/triggergen.py b/gen/triggergen.py index 19e815ce..6d529475 100644 --- a/gen/triggergen.py +++ b/gen/triggergen.py @@ -165,7 +165,7 @@ class TriggersGenerator: self.mission.triggerrules.triggers.append(trigger_three) def generate(self, player_cp: ControlPoint, is_quick: bool, activation_trigger_radius: int, awacs_enabled: bool): - player_coalition = self.game.player == "USA" and "blue" or "red" + player_coalition = self.game.player_country == "USA" and "blue" or "red" enemy_coalition = player_coalition == "blue" and "red" or "blue" self.mission.coalition[player_coalition].bullseye = {"x": self.conflict.position.x, diff --git a/gen/visualgen.py b/gen/visualgen.py index 16a848e9..bb9bf073 100644 --- a/gen/visualgen.py +++ b/gen/visualgen.py @@ -119,7 +119,7 @@ class VisualGenerator: break self.mission.static_group( - self.mission.country(self.game.enemy), + self.mission.country(self.game.enemy_country), "", _type=v, position=pos) @@ -146,7 +146,7 @@ class VisualGenerator: break self.mission.static_group( - self.mission.country(self.game.enemy), + self.mission.country(self.game.enemy_country), "", _type=v, position=position) @@ -154,7 +154,7 @@ class VisualGenerator: def generate_transportation_marker(self, at: Point): self.mission.static_group( - self.mission.country(self.game.player), + self.mission.country(self.game.player_country), "", _type=MarkerSmoke, position=at @@ -163,7 +163,7 @@ class VisualGenerator: def generate_transportation_destination(self, at: Point): self.generate_transportation_marker(at.point_from_heading(0, 20)) self.mission.static_group( - self.mission.country(self.game.player), + self.mission.country(self.game.player_country), "", _type=Outpost, position=at diff --git a/resources/tools/generate_loadout_check.py b/resources/tools/generate_loadout_check.py index 33bce161..cded7b57 100644 --- a/resources/tools/generate_loadout_check.py +++ b/resources/tools/generate_loadout_check.py @@ -20,7 +20,7 @@ for t, uts in db.UNIT_BY_TASK.items(): pos.x += 10000 for ut in uts: pos.y += 5000 - ctr = mis.country([k for k, v in db.UNIT_BY_COUNTRY.items() if ut in v][0]) + ctr = mis.country([v["country"] for k, v in db.UNIT_BY_COUNTRY.items() if ut in v["units"]][0]) g = mis.flight_group_inflight( country=ctr, diff --git a/theater/caucasus.py b/theater/caucasus.py index 975d2bd5..415aa8e9 100644 --- a/theater/caucasus.py +++ b/theater/caucasus.py @@ -72,7 +72,7 @@ class CaucasusTheater(ConflictTheater): self.add_controlpoint(self.carrier_1) self.carrier_1.captured = True - self.soganlug.captured = True + self.batumi.captured = True def add_controlpoint(self, point: ControlPoint, connected_to: typing.Collection[ControlPoint] = []): point.name = " ".join(re.split(r"[ -]", point.name)[:1]) diff --git a/theater/start_generator.py b/theater/start_generator.py index 6a95f705..349d7f9b 100644 --- a/theater/start_generator.py +++ b/theater/start_generator.py @@ -19,28 +19,37 @@ COUNT_BY_TASK = { } -def generate_inital_units(theater: ConflictTheater, enemy: str, sams: bool, multiplier: float): +def generate_inital_units(theater: ConflictTheater, enemy_country: str, sams: bool, multiplier: float): for cp in theater.enemy_points(): if cp.captured: continue + # Force reset cp on generation + cp.base.aircraft = {} + cp.base.armor = {} + cp.base.aa = {} + cp.base.commision_points = {} + cp.base.strength = 1 + for task in [PinpointStrike, CAP, CAS, AirDefence]: assert cp.importance <= IMPORTANCE_HIGH, "invalid importance {}".format(cp.importance) assert cp.importance >= IMPORTANCE_LOW, "invalid importance {}".format(cp.importance) importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW) variety = int(UNIT_VARIETY) - unittypes = db.choose_units(task, importance_factor, variety, enemy) + unittypes = db.choose_units(task, importance_factor, variety, enemy_country) if not sams and task == AirDefence: - unittypes = [x for x in db.find_unittype(AirDefence, enemy) if x not in db.SAM_BAN] + unittypes = [x for x in db.find_unittype(AirDefence, enemy_country) if x not in db.SAM_BAN] count_log = math.log(cp.importance + 0.01, UNIT_COUNT_IMPORTANCE_LOG) count = max(COUNT_BY_TASK[task] * multiplier * (1+count_log), 1) - count_per_type = max(int(float(count) / len(unittypes)), 1) - for unit_type in unittypes: - logging.info("{} - {} {}".format(cp.name, db.unit_type_name(unit_type), count_per_type)) - cp.base.commision_units({unit_type: count_per_type}) + + if len(unittypes) > 0: + count_per_type = max(int(float(count) / len(unittypes)), 1) + for unit_type in unittypes: + logging.info("{} - {} {}".format(cp.name, db.unit_type_name(unit_type), count_per_type)) + cp.base.commision_units({unit_type: count_per_type}) def generate_groundobjects(theater: ConflictTheater): @@ -73,6 +82,10 @@ def generate_groundobjects(theater: ConflictTheater): group_id = 0 for cp in theater.controlpoints: + + # Reset cp ground objects + cp.ground_objects = [] + if cp.is_global: continue diff --git a/ui/basemenu.py b/ui/basemenu.py index f2f76248..b82aaa67 100644 --- a/ui/basemenu.py +++ b/ui/basemenu.py @@ -19,11 +19,11 @@ class BaseMenu(Menu): def display(self): self.window.clear_right_pane() units = { - CAP: db.find_unittype(CAP, self.game.player), - Embarking: db.find_unittype(Embarking, self.game.player), - AirDefence: db.find_unittype(AirDefence, self.game.player), - CAS: db.find_unittype(CAS, self.game.player), - PinpointStrike: db.find_unittype(PinpointStrike, self.game.player), + CAP: db.find_unittype(CAP, self.game.player_name), + Embarking: db.find_unittype(Embarking, self.game.player_name), + AirDefence: db.find_unittype(AirDefence, self.game.player_name), + CAS: db.find_unittype(CAS, self.game.player_name), + PinpointStrike: db.find_unittype(PinpointStrike, self.game.player_name), } # Header diff --git a/ui/eventmenu.py b/ui/eventmenu.py index 24aa7e70..d7a55189 100644 --- a/ui/eventmenu.py +++ b/ui/eventmenu.py @@ -19,7 +19,7 @@ class EventMenu(Menu): self.event = event self.scramble_entries = {k: {} for k in self.event.tasks} - if self.event.attacker_name == self.game.player: + if self.event.attacker_name == self.game.player_name: self.base = self.event.departure_cp.base else: self.base = self.event.to_cp.base diff --git a/ui/eventresultsmenu.py b/ui/eventresultsmenu.py index 68c25c21..9bd92e2f 100644 --- a/ui/eventresultsmenu.py +++ b/ui/eventresultsmenu.py @@ -109,15 +109,15 @@ class EventResultsMenu(Menu): debriefing.calculate_units(regular_mission=self.event.operation.regular_mission, quick_mission=self.event.operation.quick_mission, - player_name=self.game.player, - enemy_name=self.game.enemy) + player_country=self.game.player_country, + enemy_country=self.game.enemy_country) self.game.finish_event(event=self.event, debriefing=debriefing) self.game.pass_turn(ignored_cps=[self.event.to_cp, ]) self.finished = True - self.player_losses = debriefing.destroyed_units.get(self.game.player, {}) - self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy, {}) + self.player_losses = debriefing.destroyed_units.get(self.game.player_country, {}) + self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy_country, {}) self.display() def simulate_result(self, player_factor: float, enemy_factor: float): @@ -144,8 +144,8 @@ class EventResultsMenu(Menu): return result - player = self.event.operation.mission.country(self.game.player) - enemy = self.event.operation.mission.country(self.game.enemy) + player = self.event.operation.mission.country(self.game.player_country) + enemy = self.event.operation.mission.country(self.game.enemy_country) alive_player_units = count(player) alive_enemy_units = count(enemy) @@ -170,8 +170,8 @@ class EventResultsMenu(Menu): self.finished = True self.debriefing = debriefing - self.player_losses = debriefing.destroyed_units.get(self.game.player, {}) - self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy, {}) + self.player_losses = debriefing.destroyed_units.get(self.game.player_country, {}) + self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy_country, {}) self.game.finish_event(self.event, debriefing) self.display() diff --git a/ui/newgamemenu.py b/ui/newgamemenu.py index f580f91b..1147c6c2 100644 --- a/ui/newgamemenu.py +++ b/ui/newgamemenu.py @@ -39,16 +39,16 @@ class NewGameMenu(Menu): @property def player_country_name(self): if self.selected_country.get() == 0: - return "USA" + return "USA 1965" else: - return "Russia" + return "Russia 1955" @property def enemy_country_name(self): if self.selected_country.get() == 1: - return "USA" + return "USA 1965" else: - return "Russia" + return "Russia 1955" @property def terrain_name(self) -> str: @@ -76,10 +76,10 @@ class NewGameMenu(Menu): country.grid(row=0, column=0, sticky=NW, padx=5) Radiobutton(country, variable=self.selected_country, value=0, **STYLES["radiobutton"]).grid(row=0, column=0, sticky=W) - Label(country, text="USA", **STYLES["widget"]).grid(row=0, column=1, sticky=W) + Label(country, text="USA 1965", **STYLES["widget"]).grid(row=0, column=1, sticky=W) Radiobutton(country, variable=self.selected_country, value=1, **STYLES["radiobutton"]).grid(row=1, column=0, sticky=W) - Label(country, text="Russia", **STYLES["widget"]).grid(row=1, column=1, sticky=W) + Label(country, text="Russia 1955", **STYLES["widget"]).grid(row=1, column=1, sticky=W) # Terrain Selection terrain = LabelFrame(body, text="Terrain", **STYLES["label-frame"]) diff --git a/ui/overviewcanvas.py b/ui/overviewcanvas.py index 9c739885..c1cdce07 100644 --- a/ui/overviewcanvas.py +++ b/ui/overviewcanvas.py @@ -641,10 +641,10 @@ class OverviewCanvas: return event.is_departure_available_from(cp) def _player_color(self): - return self.game.player == "USA" and BLUE or RED + return self.game.player_country == "USA" and BLUE or RED def _enemy_color(self): - return self.game.player == "USA" and RED or BLUE + return self.game.player_country == "USA" and RED or BLUE def update(self): self.redraw_required = True diff --git a/ui/window.py b/ui/window.py index 70ce0431..bed38fb8 100644 --- a/ui/window.py +++ b/ui/window.py @@ -88,6 +88,10 @@ class Window: self.build() def start_new_game(self, player_name: str, enemy_name: str, terrain: str, sams: bool, midgame: bool, multiplier: float, period:datetime): + + player_country = db.UNIT_BY_COUNTRY[player_name]["country"] + enemy_country = db.UNIT_BY_COUNTRY[enemy_name]["country"] + if terrain == "persiangulf": conflicttheater = persiangulf.PersianGulfTheater() elif terrain == "nevada": diff --git a/userdata/debriefing.py b/userdata/debriefing.py index 94685264..4d50f596 100644 --- a/userdata/debriefing.py +++ b/userdata/debriefing.py @@ -101,7 +101,7 @@ class Debriefing: return Debriefing(dead_units, trigger_state) - def calculate_units(self, regular_mission: Mission, quick_mission: Mission, player_name: str, enemy_name: str): + def calculate_units(self, regular_mission: Mission, quick_mission: Mission, player_country: str, enemy_country: str): def count_groups(groups: typing.List[UnitType]) -> typing.Dict[UnitType, int]: result = {} for group in groups: @@ -116,8 +116,8 @@ class Debriefing: mission = regular_mission if len(self._trigger_state) else quick_mission - player = mission.country(player_name) - enemy = mission.country(enemy_name) + player = mission.country(player_country) + enemy = mission.country(enemy_country) player_units = count_groups(player.plane_group + player.vehicle_group + player.ship_group) enemy_units = count_groups(enemy.plane_group + enemy.vehicle_group + enemy.ship_group)