Selectable factions wip

This commit is contained in:
Khopa
2019-06-30 14:05:26 +02:00
parent 658120b8d9
commit 309c10c4cb
23 changed files with 359 additions and 132 deletions

View File

@@ -46,18 +46,23 @@ PRICES = {
MiG_29A: 18,
MiG_29S: 20,
F_5E_3: 6,
MiG_15bis: 5,
MiG_21Bis: 6,
AJS37: 8,
F_5E_3: 8,
MiG_15bis: 4,
MiG_19P: 6,
F_86F_Sabre: 4,
MiG_21Bis: 8,
F_4E: 10,
AJS37: 12,
AV8BNA: 13,
M_2000C: 13,
FA_18C_hornet: 18,
F_15C: 20,
F_14B: 14,
AV8BNA: 14,
M_2000C: 16,
Mirage_2000_5: 22,
FA_18C_hornet: 22,
F_15C: 24,
F_14B: 18,
# bomber
Su_17M4: 10,
Su_25: 15,
Su_25T: 13,
L_39ZA: 10,
@@ -86,15 +91,25 @@ PRICES = {
C_130: 8,
# armor
Armor.APC_BTR_80: 16,
Armor.MBT_T_55: 22,
Armor.MBT_T_80U: 28,
Armor.ARV_BRDM_2: 4,
Armor.ARV_BTR_RD: 6,
Armor.APC_BTR_80: 8,
Armor.MBT_T_55: 18,
Armor.MBT_T_72B: 25,
Armor.MBT_T_80U: 30,
Armor.MBT_T_90: 35,
Armor.APC_M113: 5,
Armor.IFV_BMD_1: 8,
Armor.IFV_BMP_1: 14,
Armor.IFV_BMP_2: 16,
Armor.IFV_BMP_3: 20,
Armor.APC_M113: 5,
Armor.IFV_M2A2_Bradley: 12,
Armor.APC_M1126_Stryker_ICV: 16,
Armor.ATGM_M1134_Stryker: 18,
Armor.MBT_M60A3_Patton: 24,
Armor.MBT_M60A3_Patton: 18,
Armor.MBT_M1A2_Abrams: 35,
Armor.MBT_Leclerc: 35,
Unarmed.Transport_UAZ_469: 3,
Unarmed.Transport_Ural_375: 3,
@@ -158,15 +173,18 @@ UNIT_BY_TASK = {
],
CAS: [
MiG_15bis,
MiG_19P,
L_39ZA,
AV8BNA,
AJS37,
A_10A,
A_10C,
Su_17M4,
Su_25,
Su_25T,
Su_34,
Ka_50,
F_4E,
SA342M,
],
@@ -188,16 +206,28 @@ UNIT_BY_TASK = {
AWACS: [E_3A, A_50, ],
PinpointStrike: [
Armor.ARV_BRDM_2,
Armor.ARV_BRDM_2,
Armor.ARV_BRDM_2,
Armor.ARV_BTR_RD,
Armor.APC_BTR_80,
Armor.APC_BTR_80,
Armor.APC_BTR_80,
Armor.MBT_T_55,
Armor.MBT_T_55,
Armor.MBT_T_55,
Armor.MBT_T_72B,
Armor.MBT_T_72B,
Armor.MBT_T_80U,
Armor.MBT_T_80U,
Armor.MBT_T_90,
Armor.APC_M113,
Armor.APC_M113,
Armor.APC_M113,
Armor.APC_M113,
Armor.IFV_M2A2_Bradley,
Armor.IFV_M2A2_Bradley,
Armor.ATGM_M1134_Stryker,
Armor.ATGM_M1134_Stryker,
Armor.MBT_M60A3_Patton,
@@ -265,31 +295,39 @@ EXTRA_AA = {
"Russia": AirDefence.SAM_SA_8_Osa_9A33,
"USA": AirDefence.SAM_Linebacker_M6,
"Russia 1955": AirDefence.AAA_ZU_23_Closed,
"USA 1955": AirDefence.AAA_Vulcan_M163,
"Russia 1965": AirDefence.AAA_ZU_23_Closed,
"USA 1965": AirDefence.AAA_Vulcan_M163,
"Russia 1990": AirDefence.AAA_ZU_23_Closed,
"USA 1990": AirDefence.AAA_Vulcan_M163,
}
"""
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!
So it's better to just use 'Russia' or 'USA', 'Ukraine' and 'USAF Aggresor' faction which have most units.
country : DCS Country name
"""
UNIT_BY_COUNTRY = {
FACTIONS = {
"Russia 2010": {
"country": "Russia",
"side":"red",
"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,
Su_17M4,
L_39ZA,
IL_76MD,
@@ -316,7 +354,9 @@ UNIT_BY_COUNTRY = {
Armor.APC_BTR_80,
Armor.MBT_T_90,
Armor.MBT_T_80U,
Armor.MBT_T_55,
Armor.MBT_T_72B,
Unarmed.Transport_Ural_375,
Unarmed.Transport_UAZ_469,
Infantry.Soldier_AK,
@@ -327,10 +367,13 @@ UNIT_BY_COUNTRY = {
]
},
"Russia 1955": {
"Russia 1965": {
"country": "Russia",
"side": "red",
"units": [
MiG_15bis,
MiG_19P,
MiG_21Bis,
IL_76MD,
IL_78M,
@@ -346,11 +389,14 @@ UNIT_BY_COUNTRY = {
AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.SAM_SA_3_S_125_LN_5P73,
Armor.APC_BTR_80,
Armor.ARV_BRDM_2,
Armor.ARV_BTR_RD,
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,
@@ -358,20 +404,100 @@ UNIT_BY_COUNTRY = {
]
},
"USA 2010": {
"country":"USA",
"units":[
"Russia 1955": {
"country": "Russia",
"side": "red",
"units": [
MiG_15bis,
IL_76MD,
IL_78M,
An_26B,
An_30M,
Yak_40,
AirDefence.AAA_ZU_23_Closed,
AirDefence.SAM_SA_6_Kub_LN_2P25,
AirDefence.SAM_SA_3_S_125_LN_5P73,
Armor.ARV_BRDM_2,
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 1955": {
"country": "USA",
"side": "blue",
"units": [
F_86F_Sabre,
P_51D,
P_51D_30_NA,
KC_135,
S_3B_Tanker,
C_130,
E_3A,
UH_1H,
Unarmed.Transport_M818,
Infantry.Infantry_M4,
AirDefence.AAA_Vulcan_M163,
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
]
},
"USA 1965": {
"country": "USA",
"side": "blue",
"units": [
F_5E_3,
F_4E,
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,
]
},
"USA 1990": {
"country":"USA",
"side":"blue",
"units":[
F_15C,
F_14B,
FA_18C_hornet,
AJS37,
M_2000C,
MiG_21Bis,
MiG_15bis,
A_10A,
A_10C,
AV8BNA,
KC_135,
@@ -379,10 +505,7 @@ UNIT_BY_COUNTRY = {
C_130,
E_3A,
Ka_50,
SA342M,
UH_1H,
Mi_8MT,
Armor.MBT_M1A2_Abrams,
Armor.MBT_M60A3_Patton,
@@ -399,13 +522,17 @@ UNIT_BY_COUNTRY = {
]
},
"USA 1965": {
"country":"USA",
"units":[
F_86F_Sabre,
F_5E_3,
"USA 2005": {
"country": "USA",
"side": "blue",
"units": [
F_15C,
F_14B,
FA_18C_hornet,
A_10A,
A_10C,
AV8BNA,
KC_135,
S_3B_Tanker,
@@ -414,8 +541,37 @@ UNIT_BY_COUNTRY = {
UH_1H,
Armor.MBT_M60A3_Patton,
Armor.APC_M113,
Armor.MBT_M1A2_Abrams,
Armor.ATGM_M1134_Stryker,
Armor.IFV_M2A2_Bradley,
Unarmed.Transport_M818,
Infantry.Infantry_M4,
AirDefence.AAA_Vulcan_M163,
AirDefence.SAM_Linebacker_M6,
CVN_74_John_C__Stennis,
LHA_1_Tarawa,
Armed_speedboat,
]
},
"France 1990": {
"country": "USA",
"side": "blue",
"units":[
M_2000C,
Mirage_2000_5,
KC_135,
S_3B_Tanker,
C_130,
E_3A,
SA342M,
Armor.MBT_Leclerc,
Unarmed.Transport_M818,
Infantry.Infantry_M4,
@@ -588,7 +744,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]["units"]]
return [x for x in UNIT_BY_TASK[for_task] if x in FACTIONS[country_name]["units"]]
def unit_type_name(unit_type) -> str:
@@ -711,13 +867,13 @@ def _validate_db():
total_set = set()
for t, unit_collection in UNIT_BY_TASK.items():
for unit_type in set(unit_collection):
assert unit_type not in total_set, "{} is duplicate".format(unit_type)
assert unit_type not in total_set, "{} is duplicate for task {}".format(unit_type, t)
total_set.add(unit_type)
# check country allegiance
for unit_type in total_set:
did_find = False
for country_units_list in UNIT_BY_COUNTRY.values():
for country_units_list in FACTIONS.values():
if unit_type in country_units_list["units"]:
did_find = True
assert did_find, "{} not in country list".format(unit_type)

View File

@@ -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]["units"])
self.to_cp.base.filter_units(db.FACTIONS[self.attacker_name]["units"])
self.to_cp.base.affect_strength(+self.STRENGTH_RECOVERY)
else:

View File

@@ -103,9 +103,9 @@ class Game:
self.events = []
self.theater = theater
self.player_name = player_name
self.player_country = db.UNIT_BY_COUNTRY[player_name]["country"]
self.player_country = db.FACTIONS[player_name]["country"]
self.enemy_name = enemy_name
self.enemy_country = db.UNIT_BY_COUNTRY[enemy_name]["country"]
self.enemy_country = db.FACTIONS[enemy_name]["country"]
self.turn = 0
self.date = datetime(start_date.year, start_date.month, start_date.day)
@@ -206,7 +206,7 @@ class Game:
if for_task == AirDefence and not self.settings.sams:
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_country)
return db.choose_units(for_task, importance_factor, COMMISION_UNIT_VARIETY, self.enemy_name)
def _commision_units(self, cp: ControlPoint):
for for_task in [PinpointStrike, CAS, CAP, AirDefence]:

View File

@@ -37,6 +37,8 @@ class BaseAttackOperation(Operation):
self.attackers_starting_position = None
conflict = Conflict.capture_conflict(
attacker_name=self.attacker_name,
defender_name=self.defender_name,
attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp,

View File

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

View File

@@ -34,6 +34,8 @@ class FrontlineAttackOperation(Operation):
self.defenders_starting_position = None
conflict = Conflict.frontline_cas_conflict(
attacker_name=self.attacker_name,
defender_name=self.defender_name,
attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp,

View File

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

View File

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

View File

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

View File

@@ -31,6 +31,8 @@ class InterceptOperation(Operation):
self.attackers_starting_position = None
conflict = Conflict.intercept_conflict(
attacker_name=self.attacker_name,
defender_name=self.defender_name,
attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_country),
position=self.location,

View File

@@ -26,6 +26,8 @@ class NavalInterceptionOperation(Operation):
self.attackers_starting_position = None
conflict = Conflict.naval_intercept_conflict(
attacker_name=self.attacker_name,
defender_name=self.defender_name,
attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_country),
position=self.location,

View File

@@ -43,9 +43,9 @@ 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.attacker_country = db.FACTIONS[attacker_name]["country"]
self.defender_name = defender_name
self.defender_country = db.UNIT_BY_COUNTRY[defender_name]["country"]
self.defender_country = db.FACTIONS[defender_name]["country"]
print(self.defender_country, self.attacker_country)
self.from_cp = from_cp
self.departure_cp = departure_cp
@@ -137,7 +137,7 @@ class Operation:
self.extra_aagen.generate()
# triggers
if self.game.is_player_attack(self.conflict.attackers_side):
if self.game.is_player_attack(self.conflict.attackers_country):
cp = self.conflict.from_cp
else:
cp = self.conflict.to_cp

View File

@@ -29,6 +29,8 @@ class StrikeOperation(Operation):
self.attackers_starting_position = None
conflict = Conflict.strike_conflict(
attacker_name=self.attacker_name,
defender_name=self.defender_name,
attacker=self.current_mission.country(self.attacker_country),
defender=self.current_mission.country(self.defender_country),
from_cp=self.from_cp,