WIP for possibility to select player and ennemy faction

This commit is contained in:
Khopa 2019-06-30 05:31:22 +02:00
parent 09135adadc
commit fbd01fbfdb
31 changed files with 448 additions and 357 deletions

View File

@ -90,6 +90,7 @@ PRICES = {
Armor.MBT_T_55: 22, Armor.MBT_T_55: 22,
Armor.MBT_T_80U: 28, Armor.MBT_T_80U: 28,
Armor.MBT_T_90: 35, Armor.MBT_T_90: 35,
Armor.APC_M113: 5,
Armor.ATGM_M1134_Stryker: 18, Armor.ATGM_M1134_Stryker: 18,
Armor.MBT_M60A3_Patton: 24, 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 = { EXTRA_AA = {
"Russia": AirDefence.SAM_SA_8_Osa_9A33, "Russia": AirDefence.SAM_SA_8_Osa_9A33,
"USA": AirDefence.SAM_Linebacker_M6, "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! 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 = { UNIT_BY_COUNTRY = {
"Russia": [ "Russia 2010": {
AJS37, "country": "Russia",
MiG_23MLD, "units": [
F_5E_3, AJS37,
Su_25, MiG_23MLD,
Su_27, F_5E_3,
Su_33, Su_25,
MiG_15bis, Su_27,
MiG_21Bis, Su_33,
MiG_29A, MiG_15bis,
MiG_29S, MiG_21Bis,
M_2000C, MiG_29A,
MiG_29S,
M_2000C,
Su_25T, Su_25T,
Su_34, Su_34,
L_39ZA, L_39ZA,
IL_76MD, IL_76MD,
IL_78M, IL_78M,
An_26B, An_26B,
An_30M, An_30M,
Yak_40, Yak_40,
A_50, A_50,
Ka_50, Ka_50,
SA342M, SA342M,
UH_1H, UH_1H,
Mi_8MT, Mi_8MT,
AirDefence.SPAAA_ZSU_23_4_Shilka, AirDefence.SPAAA_ZSU_23_4_Shilka,
AirDefence.SAM_SA_9_Strela_1_9P31, AirDefence.SAM_SA_9_Strela_1_9P31,
AirDefence.SAM_SA_8_Osa_9A33, AirDefence.SAM_SA_8_Osa_9A33,
AirDefence.AAA_ZU_23_Closed, AirDefence.AAA_ZU_23_Closed,
AirDefence.SAM_SA_19_Tunguska_2S6, AirDefence.SAM_SA_19_Tunguska_2S6,
AirDefence.SAM_SA_6_Kub_LN_2P25, AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.SAM_SA_3_S_125_LN_5P73, AirDefence.SAM_SA_3_S_125_LN_5P73,
AirDefence.SAM_SA_11_Buk_LN_9A310M1, AirDefence.SAM_SA_11_Buk_LN_9A310M1,
Armor.APC_BTR_80, Armor.APC_BTR_80,
Armor.MBT_T_90, Armor.MBT_T_90,
Armor.MBT_T_80U, Armor.MBT_T_80U,
Armor.MBT_T_55, Armor.MBT_T_55,
Unarmed.Transport_Ural_375, Unarmed.Transport_Ural_375,
Unarmed.Transport_UAZ_469, Unarmed.Transport_UAZ_469,
Infantry.Soldier_AK, Infantry.Soldier_AK,
CV_1143_5_Admiral_Kuznetsov, CV_1143_5_Admiral_Kuznetsov,
Bulk_cargo_ship_Yakushev, Bulk_cargo_ship_Yakushev,
Dry_cargo_ship_Ivanov, Dry_cargo_ship_Ivanov,
Tanker_Elnya_160, Tanker_Elnya_160,
], ]
},
"USA": [ "Russia 1955": {
F_5E_3, "country": "Russia",
F_15C, "units": [
F_14B, MiG_15bis,
FA_18C_hornet,
AJS37,
M_2000C,
MiG_21Bis,
MiG_15bis,
A_10A, IL_76MD,
A_10C, IL_78M,
AV8BNA, An_26B,
An_30M,
Yak_40,
KC_135, A_50,
S_3B_Tanker,
C_130,
E_3A,
Ka_50, Mi_8MT,
SA342M,
UH_1H,
Mi_8MT,
Armor.MBT_M1A2_Abrams, AirDefence.AAA_ZU_23_Closed,
Armor.MBT_M60A3_Patton, AirDefence.SAM_SA_6_Kub_LN_2P25,
Armor.ATGM_M1134_Stryker, AirDefence.SAM_SA_3_S_125_LN_5P73,
Unarmed.Transport_M818,
Infantry.Infantry_M4,
AirDefence.AAA_Vulcan_M163, Armor.APC_BTR_80,
AirDefence.SAM_Linebacker_M6, 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, "USA 2010": {
LHA_1_Tarawa, "country":"USA",
Armed_speedboat, "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 = { 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]: 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: def unit_type_name(unit_type) -> str:
@ -649,7 +718,7 @@ def _validate_db():
for unit_type in total_set: for unit_type in total_set:
did_find = False did_find = False
for country_units_list in UNIT_BY_COUNTRY.values(): 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 did_find = True
assert did_find, "{} not in country list".format(unit_type) assert did_find, "{} not in country list".format(unit_type)

View File

@ -39,7 +39,7 @@ class BaseAttackEvent(Event):
if self.departure_cp.captured: if self.departure_cp.captured:
self.to_cp.captured = True self.to_cp.captured = True
self.to_cp.ground_objects = [] 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) self.to_cp.base.affect_strength(+self.STRENGTH_RECOVERY)
else: else:

View File

@ -47,11 +47,11 @@ class Event:
@property @property
def is_player_attacking(self) -> bool: def is_player_attacking(self) -> bool:
return self.attacker_name == self.game.player return self.attacker_name == self.game.player_name
@property @property
def enemy_cp(self) -> ControlPoint: def enemy_cp(self) -> ControlPoint:
if self.attacker_name == self.game.player: if self.attacker_name == self.game.player_name:
return self.to_cp return self.to_cp
else: else:
return self.departure_cp return self.departure_cp

View File

@ -51,7 +51,7 @@ class InterceptEvent(Event):
def commit(self, debriefing: Debriefing): def commit(self, debriefing: Debriefing):
super(InterceptEvent, self).commit(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): if self.is_successfull(debriefing):
for _, cp in self.game.theater.conflicts(True): for _, cp in self.game.theater.conflicts(True):
cp.base.affect_strength(-self.STRENGTH_INFLUENCE) cp.base.affect_strength(-self.STRENGTH_INFLUENCE)

View File

@ -61,7 +61,7 @@ class NavalInterceptEvent(Event):
def commit(self, debriefing: Debriefing): def commit(self, debriefing: Debriefing):
super(NavalInterceptEvent, self).commit(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): if self.is_successfull(debriefing):
self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE) self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
else: else:

View File

@ -102,8 +102,10 @@ class Game:
self.settings = Settings() self.settings = Settings()
self.events = [] self.events = []
self.theater = theater self.theater = theater
self.player = player_name self.player_name = player_name
self.enemy = enemy_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.turn = 0
self.date = datetime(start_date.year, start_date.month, start_date.day) 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 # skip strikes in case of no targets
return 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): 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)]: 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 # skip base attack if strength is too high
return 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): def _generate_events(self):
strikes_generated_for = set() strikes_generated_for = set()
@ -202,9 +204,9 @@ class Game:
importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW) importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW)
if for_task == AirDefence and not self.settings.sams: 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: 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): def _commision_units(self, cp: ControlPoint):
for for_task in [PinpointStrike, CAS, CAP, AirDefence]: for for_task in [PinpointStrike, CAS, CAP, AirDefence]:
@ -234,8 +236,8 @@ class Game:
self.budget -= AWACS_BUDGET_COST self.budget -= AWACS_BUDGET_COST
def units_delivery_event(self, to_cp: ControlPoint) -> UnitsDeliveryEvent: def units_delivery_event(self, to_cp: ControlPoint) -> UnitsDeliveryEvent:
event = UnitsDeliveryEvent(attacker_name=self.player, event = UnitsDeliveryEvent(attacker_name=self.player_name,
defender_name=self.player, defender_name=self.player_name,
from_cp=to_cp, from_cp=to_cp,
to_cp=to_cp, to_cp=to_cp,
game=self) game=self)
@ -267,9 +269,9 @@ class Game:
def is_player_attack(self, event): def is_player_attack(self, event):
if isinstance(event, Event): if isinstance(event, Event):
return event.attacker_name == self.player return event.attacker_name == self.player_name
else: 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): def pass_turn(self, no_action=False, ignored_cps: typing.Collection[ControlPoint]=None):
logging.info("Pass turn") logging.info("Pass turn")

View File

@ -33,12 +33,12 @@ class BaseAttackOperation(Operation):
super(BaseAttackOperation, self).prepare(terrain, is_quick) super(BaseAttackOperation, self).prepare(terrain, is_quick)
self.defenders_starting_position = None 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 self.attackers_starting_position = None
conflict = Conflict.capture_conflict( conflict = Conflict.capture_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater
@ -60,7 +60,7 @@ class BaseAttackOperation(Operation):
self.briefinggen.title = "Base attack" 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." 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") self.briefinggen.append_waypoint("TARGET")
else: else:
pass pass

View File

@ -17,8 +17,8 @@ class ConvoyStrikeOperation(Operation):
super(ConvoyStrikeOperation, self).prepare(terrain, is_quick) super(ConvoyStrikeOperation, self).prepare(terrain, is_quick)
conflict = Conflict.convoy_strike_conflict( conflict = Conflict.convoy_strike_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -29,13 +29,13 @@ class FrontlineAttackOperation(Operation):
def prepare(self, terrain: Terrain, is_quick: bool): def prepare(self, terrain: Terrain, is_quick: bool):
super(FrontlineAttackOperation, self).prepare(terrain, is_quick) 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.attackers_starting_position = None
self.defenders_starting_position = None self.defenders_starting_position = None
conflict = Conflict.frontline_cas_conflict( conflict = Conflict.frontline_cas_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -32,8 +32,8 @@ class FrontlinePatrolOperation(Operation):
self.defenders_starting_position = None self.defenders_starting_position = None
conflict = Conflict.frontline_cap_conflict( conflict = Conflict.frontline_cap_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -15,8 +15,8 @@ class InfantryTransportOperation(Operation):
super(InfantryTransportOperation, self).prepare(terrain, is_quick) super(InfantryTransportOperation, self).prepare(terrain, is_quick)
conflict = Conflict.transport_conflict( conflict = Conflict.transport_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -17,8 +17,8 @@ class InsurgentAttackOperation(Operation):
super(InsurgentAttackOperation, self).prepare(terrain, is_quick) super(InsurgentAttackOperation, self).prepare(terrain, is_quick)
conflict = Conflict.ground_attack_conflict( conflict = Conflict.ground_attack_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -27,12 +27,12 @@ class InterceptOperation(Operation):
def prepare(self, terrain: Terrain, is_quick: bool): def prepare(self, terrain: Terrain, is_quick: bool):
super(InterceptOperation, self).prepare(terrain, is_quick) super(InterceptOperation, self).prepare(terrain, is_quick)
self.defenders_starting_position = None 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 self.attackers_starting_position = None
conflict = Conflict.intercept_conflict( conflict = Conflict.intercept_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
position=self.location, position=self.location,
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
@ -53,7 +53,7 @@ class InterceptOperation(Operation):
self.briefinggen.title = "Air Intercept" 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.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") self.briefinggen.append_waypoint("TARGET")
for unit_type, count in self.transport.items(): for unit_type, count in self.transport.items():

View File

@ -22,12 +22,12 @@ class NavalInterceptionOperation(Operation):
def prepare(self, terrain: Terrain, is_quick: bool): def prepare(self, terrain: Terrain, is_quick: bool):
super(NavalInterceptionOperation, self).prepare(terrain, is_quick) 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 self.attackers_starting_position = None
conflict = Conflict.naval_intercept_conflict( conflict = Conflict.naval_intercept_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
position=self.location, position=self.location,
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
@ -55,7 +55,7 @@ class NavalInterceptionOperation(Operation):
) )
self.briefinggen.title = "Naval Intercept" 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." 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(): for unit_type, count in self.targets.items():
self.briefinggen.append_target("{} ({})".format(db.unit_type_name(unit_type), count)) self.briefinggen.append_target("{} ({})".format(db.unit_type_name(unit_type), count))

View File

@ -43,7 +43,10 @@ class Operation:
to_cp: ControlPoint = None): to_cp: ControlPoint = None):
self.game = game self.game = game
self.attacker_name = attacker_name self.attacker_name = attacker_name
self.attacker_country = db.UNIT_BY_COUNTRY[attacker_name]["country"]
self.defender_name = defender_name 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.from_cp = from_cp
self.departure_cp = departure_cp self.departure_cp = departure_cp
self.to_cp = to_cp self.to_cp = to_cp
@ -74,9 +77,9 @@ class Operation:
self.groundobjectgen = GroundObjectsGenerator(mission, conflict, self.game) self.groundobjectgen = GroundObjectsGenerator(mission, conflict, self.game)
self.briefinggen = BriefingGenerator(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 player_country = self.from_cp.captured and self.attacker_country or self.defender_country
enemy_name = self.from_cp.captured and self.defender_name or self.attacker_name enemy_country = self.from_cp.captured and self.defender_country or self.attacker_country
self.extra_aagen = ExtraAAConflictGenerator(mission, conflict, self.game, player_name, enemy_name) self.extra_aagen = ExtraAAConflictGenerator(mission, conflict, self.game, player_country, enemy_country)
def prepare(self, terrain: Terrain, is_quick: bool): def prepare(self, terrain: Terrain, is_quick: bool):
with open("resources/default_options.lua", "r") as f: with open("resources/default_options.lua", "r") as f:
@ -104,7 +107,7 @@ class Operation:
return return
ship = self.shipgen.generate_carrier(for_units=[t for t, c in for_units.items() if c > 0], 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) at=self.departure_cp.at)
if not self.is_quick: if not self.is_quick:
@ -124,7 +127,7 @@ class Operation:
# combined arms # combined arms
self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0 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 self.current_mission.groundControl.blue_tactical_commander = self.ca_slots
else: else:
self.current_mission.groundControl.red_tactical_commander = self.ca_slots self.current_mission.groundControl.red_tactical_commander = self.ca_slots

View File

@ -25,12 +25,12 @@ class StrikeOperation(Operation):
super(StrikeOperation, self).prepare(terrain, is_quick) super(StrikeOperation, self).prepare(terrain, is_quick)
self.defenders_starting_position = None 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 self.attackers_starting_position = None
conflict = Conflict.strike_conflict( conflict = Conflict.strike_conflict(
attacker=self.current_mission.country(self.attacker_name), attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_name), defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp, from_cp=self.from_cp,
to_cp=self.to_cp, to_cp=self.to_cp,
theater=self.game.theater theater=self.game.theater

View File

@ -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, 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, formation=unitgroup.VehicleGroup.Formation.Line,
move_formation: PointAction=PointAction.OffRoad): 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)) vg = unitgroup.VehicleGroup(self.next_group_id(), self.string(name))
for i in range(1, group_size + 1): heading = randint(0, 359)
heading = randint(0, 359) if _type == AirDefence.SAM_SA_3_S_125_LN_5P73:
if _type == AirDefence.SAM_SA_3_S_125_LN_5P73: # 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR
# 4 launchers (180 degrees all facing the same direction), 1 SR, 1 TR num_launchers = 4
num_launchers = 4 # search radar
# 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( v = self.vehicle(
name + " Unit #{nr}".format(nr=i), name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SR_P_19, AirDefence.SAM_SA_3_S_125_LN_5P73,
) )
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20 v.position.x = plop_positions[x][0]
v.heading = heading v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v) 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( v = self.vehicle(
name + " Unit #{nr}".format(nr=i), name + " Unit #{nr}".format(nr=1+x),
AirDefence.SAM_SA_3_S_125_TR_SNR, AirDefence.SAM_SA_6_Kub_LN_2P25,
) )
center_x = position.x + randint(20, 40) v.position.x = plop_positions[x][0]
center_y = position.y + (i - 1) * 20 v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
v.position.x = center_x
v.position.y = center_y
v.heading = heading
vg.add_unit(v) vg.add_unit(v)
plop_positions = determine_positions( elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C:
position, # 8 launchers - 4 directions, two in each direction
heading, # 1 SR (offset)
num_launchers, # 1 TR (center)
launcher_distance=100, # search radar
coverage=180, num_launchers = 8
) v = self.vehicle(
for x in range(0, num_launchers): name + " Unit #{nr}".format(nr=1),
v = self.vehicle( AirDefence.SAM_SA_10_S_300PS_SR_5N66M,
name + " Unit #{nr}".format(nr=i), )
AirDefence.SAM_SA_3_S_125_LN_5P73, 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] center_x = position.x + randint(20, 40)
v.position.y = plop_positions[x][1] center_y = position.y
v.heading = plop_positions[x][2]
vg.add_unit(v)
elif _type == AirDefence.SAM_SA_6_Kub_LN_2P25: v.position.x = center_x
# 6 launchers (360 degree coverage) v.position.y = center_y
# 1 S/TR v.heading = heading
# search/track radar vg.add_unit(v)
num_launchers = 6 # 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( v = self.vehicle(
name + " Unit #{nr}".format(nr=i), name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SA_6_Kub_STR_9S91, AirDefence.SAM_SA_10_S_300PS_LN_5P85C,
) )
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20 v.position.x = plop_positions[x][0]
v.heading = heading v.position.y = plop_positions[x][1]
v.heading = plop_positions[x][2]
vg.add_unit(v) vg.add_unit(v)
plop_positions = determine_positions( elif _type == AirDefence.SAM_SA_10_S_300PS_CP_54K6:
position, # 8 launchers - 4 directions, two in each direction
heading, # 1 SR (offset)
num_launchers, # 1 TR (center)
launcher_distance=100, # search radar
coverage=360, num_launchers = 8
) v = self.vehicle(
for x in range(0, num_launchers): name + " Unit #{nr}".format(nr=1),
v = self.vehicle( AirDefence.SAM_SA_10_S_300PS_SR_64H6E,
name + " Unit #{nr}".format(nr=i), )
AirDefence.SAM_SA_6_Kub_LN_2P25, 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] center_x = position.x + randint(20, 40)
v.position.y = plop_positions[x][1] center_y = position.y
v.heading = plop_positions[x][2]
vg.add_unit(v) v.position.x = center_x
elif _type == AirDefence.SAM_SA_10_S_300PS_LN_5P85C: v.position.y = center_y
# 8 launchers - 4 directions, two in each direction v.heading = heading
# 1 SR (offset) vg.add_unit(v)
# 1 TR (center) # command center
# search radar v = self.vehicle(
num_launchers = 8 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( v = self.vehicle(
name + " Unit #{nr}".format(nr=i), name + " Unit #{nr}".format(nr=3+x),
AirDefence.SAM_SA_10_S_300PS_SR_5N66M, AirDefence.SAM_SA_10_S_300PS_LN_5P85D,
) )
v.position.x = position.x
v.position.y = position.y + (i - 1) * 20 v.position.x = plop_positions[x][0]
v.heading = heading v.position.y = plop_positions[x][1]
vg.add_unit(v) v.heading = plop_positions[x][2]
# 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
vg.add_unit(v) 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 = vg.add_waypoint(vg.units[0].position, move_formation, 0)
wp.ETA_locked = True wp.ETA_locked = True
if _type.eplrs: if _type.eplrs:
wp.tasks.append(task.EPLRS(self.next_eplrs("vehicle"))) wp.tasks.append(task.EPLRS(self.next_eplrs("vehicle")))
@ -301,12 +301,12 @@ class AAConflictGenerator:
class ExtraAAConflictGenerator: 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.mission = mission
self.game = game self.game = game
self.conflict = conflict self.conflict = conflict
self.player_name = player_name self.player_country = player_country
self.enemy_name = enemy_name self.enemy_country = enemy_country
def generate(self): def generate(self):
from theater.conflicttheater import ControlPoint from theater.conflicttheater import ControlPoint
@ -327,7 +327,7 @@ class ExtraAAConflictGenerator:
if cp.position.distance_to_point(self.conflict.position) > EXTRA_AA_MAX_DISTANCE: if cp.position.distance_to_point(self.conflict.position) > EXTRA_AA_MAX_DISTANCE:
continue 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) position = cp.position.point_from_heading(0, EXTRA_AA_POSITION_FROM_CP)
self.mission.vehicle_group( self.mission.vehicle_group(

View File

@ -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_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_position = player_cp.position.point_from_heading(tanker_heading, TANKER_DISTANCE)
tanker_group = self.mission.refuel_flight( tanker_group = self.mission.refuel_flight(
country=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)), name=namegen.next_tanker_name(self.mission.country(self.game.player_country)),
airport=None, airport=None,
plane_type=tanker_unit_type, plane_type=tanker_unit_type,
position=tanker_position, position=tanker_position,
@ -55,8 +55,8 @@ class AirSupportConflictGenerator:
if is_awacs_enabled: if is_awacs_enabled:
awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side.name)[0] awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side.name)[0]
awacs_flight = self.mission.awacs_flight( awacs_flight = self.mission.awacs_flight(
country=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)), name=namegen.next_awacs_name(self.mission.country(self.game.player_country)),
plane_type=awacs_unit, plane_type=awacs_unit,
altitude=AWACS_ALT, altitude=AWACS_ALT,
airport=None, airport=None,

View File

@ -36,16 +36,16 @@ class GroundObjectsGenerator:
position = position.point_from_heading(0, i * 275) position = position.point_from_heading(0, i * 275)
yield self.m.farp( yield self.m.farp(
country=self.m.country(self.game.player), country=self.m.country(self.game.player_country),
name="FARP", name="FARP",
position=position, position=position,
) )
def generate(self): def generate(self):
side = self.m.country(self.game.enemy) side = self.m.country(self.game.enemy_country)
cp = None # type: ControlPoint 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 cp = self.conflict.to_cp
else: else:
cp = self.conflict.from_cp cp = self.conflict.from_cp

View File

@ -165,7 +165,7 @@ class TriggersGenerator:
self.mission.triggerrules.triggers.append(trigger_three) self.mission.triggerrules.triggers.append(trigger_three)
def generate(self, player_cp: ControlPoint, is_quick: bool, activation_trigger_radius: int, awacs_enabled: bool): 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" enemy_coalition = player_coalition == "blue" and "red" or "blue"
self.mission.coalition[player_coalition].bullseye = {"x": self.conflict.position.x, self.mission.coalition[player_coalition].bullseye = {"x": self.conflict.position.x,

View File

@ -119,7 +119,7 @@ class VisualGenerator:
break break
self.mission.static_group( self.mission.static_group(
self.mission.country(self.game.enemy), self.mission.country(self.game.enemy_country),
"", "",
_type=v, _type=v,
position=pos) position=pos)
@ -146,7 +146,7 @@ class VisualGenerator:
break break
self.mission.static_group( self.mission.static_group(
self.mission.country(self.game.enemy), self.mission.country(self.game.enemy_country),
"", "",
_type=v, _type=v,
position=position) position=position)
@ -154,7 +154,7 @@ class VisualGenerator:
def generate_transportation_marker(self, at: Point): def generate_transportation_marker(self, at: Point):
self.mission.static_group( self.mission.static_group(
self.mission.country(self.game.player), self.mission.country(self.game.player_country),
"", "",
_type=MarkerSmoke, _type=MarkerSmoke,
position=at position=at
@ -163,7 +163,7 @@ class VisualGenerator:
def generate_transportation_destination(self, at: Point): def generate_transportation_destination(self, at: Point):
self.generate_transportation_marker(at.point_from_heading(0, 20)) self.generate_transportation_marker(at.point_from_heading(0, 20))
self.mission.static_group( self.mission.static_group(
self.mission.country(self.game.player), self.mission.country(self.game.player_country),
"", "",
_type=Outpost, _type=Outpost,
position=at position=at

View File

@ -20,7 +20,7 @@ for t, uts in db.UNIT_BY_TASK.items():
pos.x += 10000 pos.x += 10000
for ut in uts: for ut in uts:
pos.y += 5000 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( g = mis.flight_group_inflight(
country=ctr, country=ctr,

View File

@ -72,7 +72,7 @@ class CaucasusTheater(ConflictTheater):
self.add_controlpoint(self.carrier_1) self.add_controlpoint(self.carrier_1)
self.carrier_1.captured = True self.carrier_1.captured = True
self.soganlug.captured = True self.batumi.captured = True
def add_controlpoint(self, point: ControlPoint, connected_to: typing.Collection[ControlPoint] = []): def add_controlpoint(self, point: ControlPoint, connected_to: typing.Collection[ControlPoint] = []):
point.name = " ".join(re.split(r"[ -]", point.name)[:1]) point.name = " ".join(re.split(r"[ -]", point.name)[:1])

View File

@ -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(): for cp in theater.enemy_points():
if cp.captured: if cp.captured:
continue 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]: for task in [PinpointStrike, CAP, CAS, AirDefence]:
assert cp.importance <= IMPORTANCE_HIGH, "invalid importance {}".format(cp.importance) assert cp.importance <= IMPORTANCE_HIGH, "invalid importance {}".format(cp.importance)
assert cp.importance >= IMPORTANCE_LOW, "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) importance_factor = (cp.importance - IMPORTANCE_LOW) / (IMPORTANCE_HIGH - IMPORTANCE_LOW)
variety = int(UNIT_VARIETY) 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: 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_log = math.log(cp.importance + 0.01, UNIT_COUNT_IMPORTANCE_LOG)
count = max(COUNT_BY_TASK[task] * multiplier * (1+count_log), 1) 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: if len(unittypes) > 0:
logging.info("{} - {} {}".format(cp.name, db.unit_type_name(unit_type), count_per_type)) count_per_type = max(int(float(count) / len(unittypes)), 1)
cp.base.commision_units({unit_type: count_per_type}) 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): def generate_groundobjects(theater: ConflictTheater):
@ -73,6 +82,10 @@ def generate_groundobjects(theater: ConflictTheater):
group_id = 0 group_id = 0
for cp in theater.controlpoints: for cp in theater.controlpoints:
# Reset cp ground objects
cp.ground_objects = []
if cp.is_global: if cp.is_global:
continue continue

View File

@ -19,11 +19,11 @@ class BaseMenu(Menu):
def display(self): def display(self):
self.window.clear_right_pane() self.window.clear_right_pane()
units = { units = {
CAP: db.find_unittype(CAP, self.game.player), CAP: db.find_unittype(CAP, self.game.player_name),
Embarking: db.find_unittype(Embarking, self.game.player), Embarking: db.find_unittype(Embarking, self.game.player_name),
AirDefence: db.find_unittype(AirDefence, self.game.player), AirDefence: db.find_unittype(AirDefence, self.game.player_name),
CAS: db.find_unittype(CAS, self.game.player), CAS: db.find_unittype(CAS, self.game.player_name),
PinpointStrike: db.find_unittype(PinpointStrike, self.game.player), PinpointStrike: db.find_unittype(PinpointStrike, self.game.player_name),
} }
# Header # Header

View File

@ -19,7 +19,7 @@ class EventMenu(Menu):
self.event = event self.event = event
self.scramble_entries = {k: {} for k in self.event.tasks} 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 self.base = self.event.departure_cp.base
else: else:
self.base = self.event.to_cp.base self.base = self.event.to_cp.base

View File

@ -109,15 +109,15 @@ class EventResultsMenu(Menu):
debriefing.calculate_units(regular_mission=self.event.operation.regular_mission, debriefing.calculate_units(regular_mission=self.event.operation.regular_mission,
quick_mission=self.event.operation.quick_mission, quick_mission=self.event.operation.quick_mission,
player_name=self.game.player, player_country=self.game.player_country,
enemy_name=self.game.enemy) enemy_country=self.game.enemy_country)
self.game.finish_event(event=self.event, debriefing=debriefing) self.game.finish_event(event=self.event, debriefing=debriefing)
self.game.pass_turn(ignored_cps=[self.event.to_cp, ]) self.game.pass_turn(ignored_cps=[self.event.to_cp, ])
self.finished = True self.finished = True
self.player_losses = debriefing.destroyed_units.get(self.game.player, {}) self.player_losses = debriefing.destroyed_units.get(self.game.player_country, {})
self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy, {}) self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy_country, {})
self.display() self.display()
def simulate_result(self, player_factor: float, enemy_factor: float): def simulate_result(self, player_factor: float, enemy_factor: float):
@ -144,8 +144,8 @@ class EventResultsMenu(Menu):
return result return result
player = self.event.operation.mission.country(self.game.player) player = self.event.operation.mission.country(self.game.player_country)
enemy = self.event.operation.mission.country(self.game.enemy) enemy = self.event.operation.mission.country(self.game.enemy_country)
alive_player_units = count(player) alive_player_units = count(player)
alive_enemy_units = count(enemy) alive_enemy_units = count(enemy)
@ -170,8 +170,8 @@ class EventResultsMenu(Menu):
self.finished = True self.finished = True
self.debriefing = debriefing self.debriefing = debriefing
self.player_losses = debriefing.destroyed_units.get(self.game.player, {}) self.player_losses = debriefing.destroyed_units.get(self.game.player_country, {})
self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy, {}) self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy_country, {})
self.game.finish_event(self.event, debriefing) self.game.finish_event(self.event, debriefing)
self.display() self.display()

View File

@ -39,16 +39,16 @@ class NewGameMenu(Menu):
@property @property
def player_country_name(self): def player_country_name(self):
if self.selected_country.get() == 0: if self.selected_country.get() == 0:
return "USA" return "USA 1965"
else: else:
return "Russia" return "Russia 1955"
@property @property
def enemy_country_name(self): def enemy_country_name(self):
if self.selected_country.get() == 1: if self.selected_country.get() == 1:
return "USA" return "USA 1965"
else: else:
return "Russia" return "Russia 1955"
@property @property
def terrain_name(self) -> str: def terrain_name(self) -> str:
@ -76,10 +76,10 @@ class NewGameMenu(Menu):
country.grid(row=0, column=0, sticky=NW, padx=5) 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, Radiobutton(country, variable=self.selected_country, value=0, **STYLES["radiobutton"]).grid(row=0, column=0,
sticky=W) 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, Radiobutton(country, variable=self.selected_country, value=1, **STYLES["radiobutton"]).grid(row=1, column=0,
sticky=W) 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 Selection
terrain = LabelFrame(body, text="Terrain", **STYLES["label-frame"]) terrain = LabelFrame(body, text="Terrain", **STYLES["label-frame"])

View File

@ -641,10 +641,10 @@ class OverviewCanvas:
return event.is_departure_available_from(cp) return event.is_departure_available_from(cp)
def _player_color(self): 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): 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): def update(self):
self.redraw_required = True self.redraw_required = True

View File

@ -88,6 +88,10 @@ class Window:
self.build() self.build()
def start_new_game(self, player_name: str, enemy_name: str, terrain: str, sams: bool, midgame: bool, multiplier: float, period:datetime): 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": if terrain == "persiangulf":
conflicttheater = persiangulf.PersianGulfTheater() conflicttheater = persiangulf.PersianGulfTheater()
elif terrain == "nevada": elif terrain == "nevada":

View File

@ -101,7 +101,7 @@ class Debriefing:
return Debriefing(dead_units, trigger_state) 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]: def count_groups(groups: typing.List[UnitType]) -> typing.Dict[UnitType, int]:
result = {} result = {}
for group in groups: for group in groups:
@ -116,8 +116,8 @@ class Debriefing:
mission = regular_mission if len(self._trigger_state) else quick_mission mission = regular_mission if len(self._trigger_state) else quick_mission
player = mission.country(player_name) player = mission.country(player_country)
enemy = mission.country(enemy_name) enemy = mission.country(enemy_country)
player_units = count_groups(player.plane_group + player.vehicle_group + player.ship_group) 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) enemy_units = count_groups(enemy.plane_group + enemy.vehicle_group + enemy.ship_group)