mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
WIP for possibility to select player and ennemy faction
This commit is contained in:
parent
09135adadc
commit
fbd01fbfdb
225
game/db.py
225
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)
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
22
game/game.py
22
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")
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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():
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
374
gen/aaa.py
374
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(
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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])
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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"])
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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":
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user