mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
configure client slots on scramble + fixes
This commit is contained in:
parent
0f569d43b0
commit
fb377cb6ca
2
.idea/dcs_pmcliberation.iml
generated
2
.idea/dcs_pmcliberation.iml
generated
@ -4,7 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.6 (venv)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TestRunnerService">
|
<component name="TestRunnerService">
|
||||||
|
|||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (venv)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
@ -10,6 +10,7 @@ import ui.window
|
|||||||
import ui.mainmenu
|
import ui.mainmenu
|
||||||
|
|
||||||
from game.game import Game
|
from game.game import Game
|
||||||
|
from theater import start_generator
|
||||||
from theater.controlpoint import *
|
from theater.controlpoint import *
|
||||||
|
|
||||||
from dcs.planes import *
|
from dcs.planes import *
|
||||||
@ -17,6 +18,8 @@ from dcs.vehicles import *
|
|||||||
|
|
||||||
m = dcs.Mission()
|
m = dcs.Mission()
|
||||||
theater = theater.caucasus.CaucasusTheater()
|
theater = theater.caucasus.CaucasusTheater()
|
||||||
|
|
||||||
|
start_generator.generate_initial(theater, "Russia")
|
||||||
theater.kutaisi.base.aircraft = {
|
theater.kutaisi.base.aircraft = {
|
||||||
F_15C: 4,
|
F_15C: 4,
|
||||||
A_10C: 2,
|
A_10C: 2,
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class GroundInterceptEvent(Event):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def player_attacking(self, position: Point, strikegroup: typing.Dict[PlaneType, int]):
|
def player_attacking(self, position: Point, strikegroup: db.PlaneDict, clients: db.PlaneDict):
|
||||||
suitable_unittypes = db.find_unittype(CAP, self.defender.name)
|
suitable_unittypes = db.find_unittype(CAP, self.defender.name)
|
||||||
random.shuffle(suitable_unittypes)
|
random.shuffle(suitable_unittypes)
|
||||||
unittypes = suitable_unittypes[:self.TARGET_VARIETY]
|
unittypes = suitable_unittypes[:self.TARGET_VARIETY]
|
||||||
@ -81,6 +81,8 @@ class GroundInterceptEvent(Event):
|
|||||||
self.operation = GroundInterceptOperation(mission=self.mission,
|
self.operation = GroundInterceptOperation(mission=self.mission,
|
||||||
attacker=self.attacker,
|
attacker=self.attacker,
|
||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
|
attacker_clients=clients,
|
||||||
|
defender_clients={},
|
||||||
position=position,
|
position=position,
|
||||||
target=targets,
|
target=targets,
|
||||||
strikegroup=strikegroup)
|
strikegroup=strikegroup)
|
||||||
@ -105,7 +107,7 @@ class InterceptEvent(Event):
|
|||||||
if self.to_cp.captured:
|
if self.to_cp.captured:
|
||||||
self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
|
self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
|
||||||
|
|
||||||
def player_attacking(self, interceptors: typing.Dict[PlaneType, int]):
|
def player_attacking(self, interceptors: db.PlaneDict, clients: db.PlaneDict):
|
||||||
escort = self.to_cp.base.scramble_sweep(self.to_cp)
|
escort = self.to_cp.base.scramble_sweep(self.to_cp)
|
||||||
transport_unit = random.choice(db.find_unittype(Transport, self.defender.name))
|
transport_unit = random.choice(db.find_unittype(Transport, self.defender.name))
|
||||||
assert transport_unit is not None
|
assert transport_unit is not None
|
||||||
@ -113,13 +115,15 @@ class InterceptEvent(Event):
|
|||||||
self.operation = InterceptOperation(mission=self.mission,
|
self.operation = InterceptOperation(mission=self.mission,
|
||||||
attacker=self.attacker,
|
attacker=self.attacker,
|
||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
|
attacker_clients=clients,
|
||||||
|
defender_clients={},
|
||||||
destination=self.to_cp,
|
destination=self.to_cp,
|
||||||
destination_port=self.to_cp.airport,
|
destination_port=self.to_cp.airport,
|
||||||
escort=escort,
|
escort=escort,
|
||||||
transport={transport_unit: 1},
|
transport={transport_unit: 1},
|
||||||
interceptors=interceptors)
|
interceptors=interceptors)
|
||||||
|
|
||||||
def player_defending(self, escort: typing.Dict[PlaneType, int]):
|
def player_defending(self, escort: db.PlaneDict, clients: db.PlaneDict):
|
||||||
interceptors = self.from_cp.base.scramble_interceptors_count(self.difficulty * self.ESCORT_AMOUNT_FACTOR)
|
interceptors = self.from_cp.base.scramble_interceptors_count(self.difficulty * self.ESCORT_AMOUNT_FACTOR)
|
||||||
transport_unit = random.choice(db.find_unittype(Transport, self.defender.name))
|
transport_unit = random.choice(db.find_unittype(Transport, self.defender.name))
|
||||||
assert transport_unit is not None
|
assert transport_unit is not None
|
||||||
@ -127,6 +131,8 @@ class InterceptEvent(Event):
|
|||||||
self.operation = InterceptOperation(mission=self.mission,
|
self.operation = InterceptOperation(mission=self.mission,
|
||||||
attacker=self.attacker,
|
attacker=self.attacker,
|
||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
|
attacker_clients={},
|
||||||
|
defender_clients=clients,
|
||||||
destination=self.to_cp,
|
destination=self.to_cp,
|
||||||
destination_port=self.to_cp.airport,
|
destination_port=self.to_cp.airport,
|
||||||
escort=escort,
|
escort=escort,
|
||||||
@ -156,7 +162,7 @@ class CaptureEvent(Event):
|
|||||||
if self.to_cp.captured:
|
if self.to_cp.captured:
|
||||||
self.to_cp.captured = False
|
self.to_cp.captured = False
|
||||||
|
|
||||||
def player_defending(self, interceptors: typing.Dict[PlaneType, int]):
|
def player_defending(self, interceptors: db.PlaneDict, clients: db.PlaneDict):
|
||||||
cas = self.from_cp.base.scramble_cas(self.to_cp)
|
cas = self.from_cp.base.scramble_cas(self.to_cp)
|
||||||
escort = self.from_cp.base.scramble_sweep(self.to_cp)
|
escort = self.from_cp.base.scramble_sweep(self.to_cp)
|
||||||
attackers = self.from_cp.base.assemble_cap(self.to_cp)
|
attackers = self.from_cp.base.assemble_cap(self.to_cp)
|
||||||
@ -164,6 +170,8 @@ class CaptureEvent(Event):
|
|||||||
self.operation = CaptureOperation(mission=self.mission,
|
self.operation = CaptureOperation(mission=self.mission,
|
||||||
attacker=self.attacker,
|
attacker=self.attacker,
|
||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
|
attacker_clients={},
|
||||||
|
defender_clients=clients,
|
||||||
from_cp=self.from_cp,
|
from_cp=self.from_cp,
|
||||||
to_cp=self.to_cp,
|
to_cp=self.to_cp,
|
||||||
cas=cas,
|
cas=cas,
|
||||||
@ -173,12 +181,14 @@ class CaptureEvent(Event):
|
|||||||
defense=self.to_cp.base.armor,
|
defense=self.to_cp.base.armor,
|
||||||
aa=self.to_cp.base.aa)
|
aa=self.to_cp.base.aa)
|
||||||
|
|
||||||
def player_attacking(self, cas: typing.Dict[PlaneType, int], escort: typing.Dict[PlaneType, int], armor: typing.Dict[Armor, int]):
|
def player_attacking(self, cas: db.PlaneDict, escort: db.PlaneDict, armor: db.ArmorDict, clients: db.PlaneDict):
|
||||||
interceptors = self.to_cp.base.scramble_sweep(for_target=self.to_cp)
|
interceptors = self.to_cp.base.scramble_sweep(for_target=self.to_cp)
|
||||||
|
|
||||||
self.operation = CaptureOperation(mission=self.mission,
|
self.operation = CaptureOperation(mission=self.mission,
|
||||||
attacker=self.attacker,
|
attacker=self.attacker,
|
||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
|
attacker_clients=clients,
|
||||||
|
defender_clients={},
|
||||||
from_cp=self.from_cp,
|
from_cp=self.from_cp,
|
||||||
to_cp=self.to_cp,
|
to_cp=self.to_cp,
|
||||||
cas=cas,
|
cas=cas,
|
||||||
|
|||||||
@ -8,6 +8,7 @@ from dcs.vehicles import *
|
|||||||
from theater.controlpoint import *
|
from theater.controlpoint import *
|
||||||
from theater.conflicttheater import *
|
from theater.conflicttheater import *
|
||||||
from theater.base import *
|
from theater.base import *
|
||||||
|
from shop import *
|
||||||
|
|
||||||
from gen.armor import *
|
from gen.armor import *
|
||||||
from gen.aircraft import *
|
from gen.aircraft import *
|
||||||
@ -38,19 +39,23 @@ class CaptureOperation(Operation):
|
|||||||
mission: Mission,
|
mission: Mission,
|
||||||
attacker: Country,
|
attacker: Country,
|
||||||
defender: Country,
|
defender: Country,
|
||||||
|
attacker_clients: db.PlaneDict,
|
||||||
|
defender_clients: db.PlaneDict,
|
||||||
from_cp: ControlPoint,
|
from_cp: ControlPoint,
|
||||||
to_cp: ControlPoint,
|
to_cp: ControlPoint,
|
||||||
cas: typing.Dict[PlaneType, int],
|
cas: db.PlaneDict,
|
||||||
escort: typing.Dict[PlaneType, int],
|
escort: db.PlaneDict,
|
||||||
attack: typing.Dict[Armor, int],
|
attack: db.ArmorDict,
|
||||||
intercept: typing.Dict[PlaneType, int],
|
intercept: db.PlaneDict,
|
||||||
defense: typing.Dict[Armor, int],
|
defense: db.ArmorDict,
|
||||||
aa: typing.Dict[AirDefence, int]):
|
aa: db.AADict):
|
||||||
conflict = to_cp.conflict_attack(from_cp, attacker, defender)
|
conflict = to_cp.conflict_attack(from_cp, attacker, defender)
|
||||||
|
|
||||||
super(CaptureOperation, self).__init__(mission, conflict)
|
super(CaptureOperation, self).__init__(mission, conflict)
|
||||||
self.from_cp = from_cp
|
self.from_cp = from_cp
|
||||||
self.to_cp = to_cp
|
self.to_cp = to_cp
|
||||||
|
self.attacker_clients = attacker_clients
|
||||||
|
self.defender_clients = defender_clients
|
||||||
self.cas = cas
|
self.cas = cas
|
||||||
self.escort = escort
|
self.escort = escort
|
||||||
self.intercept = intercept
|
self.intercept = intercept
|
||||||
@ -62,9 +67,9 @@ class CaptureOperation(Operation):
|
|||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.armorgen.generate(self.attack, self.defense)
|
self.armorgen.generate(self.attack, self.defense)
|
||||||
self.airgen.generate_cas(self.cas)
|
self.airgen.generate_cas(self.cas, clients=self.attacker_clients)
|
||||||
self.airgen.generate_cas_escort(self.escort)
|
self.airgen.generate_cas_escort(self.escort, clients=self.attacker_clients)
|
||||||
self.airgen.generate_defense(self.intercept)
|
self.airgen.generate_defense(self.intercept, clients=self.defender_clients)
|
||||||
self.aagen.generate(self.aa)
|
self.aagen.generate(self.aa)
|
||||||
|
|
||||||
|
|
||||||
@ -73,11 +78,13 @@ class InterceptOperation(Operation):
|
|||||||
mission: Mission,
|
mission: Mission,
|
||||||
attacker: Country,
|
attacker: Country,
|
||||||
defender: Country,
|
defender: Country,
|
||||||
|
attacker_clients: db.PlaneDict,
|
||||||
|
defender_clients: db.PlaneDict,
|
||||||
destination: ControlPoint,
|
destination: ControlPoint,
|
||||||
destination_port: Airport,
|
destination_port: Airport,
|
||||||
escort: typing.Dict[PlaneType, int],
|
escort: db.PlaneDict,
|
||||||
transport: typing.Dict[PlaneType, int],
|
transport: db.PlaneDict,
|
||||||
interceptors: typing.Dict[PlaneType, int]):
|
interceptors: db.PlaneDict):
|
||||||
conflict = Conflict.intercept_conflict(
|
conflict = Conflict.intercept_conflict(
|
||||||
attacker=attacker,
|
attacker=attacker,
|
||||||
defender=defender,
|
defender=defender,
|
||||||
@ -88,14 +95,16 @@ class InterceptOperation(Operation):
|
|||||||
|
|
||||||
super(InterceptOperation, self).__init__(mission, conflict)
|
super(InterceptOperation, self).__init__(mission, conflict)
|
||||||
self.destination_port = destination_port
|
self.destination_port = destination_port
|
||||||
|
self.attacker_clients = attacker_clients
|
||||||
|
self.defender_clients = defender_clients
|
||||||
self.escort = escort
|
self.escort = escort
|
||||||
self.transport = transport
|
self.transport = transport
|
||||||
self.interceptors = interceptors
|
self.interceptors = interceptors
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.airgen.generate_transport(self.transport, self.destination_port)
|
self.airgen.generate_transport(self.transport, self.destination_port)
|
||||||
self.airgen.generate_transport_escort(self.escort)
|
self.airgen.generate_transport_escort(self.escort, clients=self.defender_clients)
|
||||||
self.airgen.generate_interception(self.interceptors)
|
self.airgen.generate_interception(self.interceptors, clients=self.attacker_clients)
|
||||||
|
|
||||||
|
|
||||||
class GroundInterceptOperation(Operation):
|
class GroundInterceptOperation(Operation):
|
||||||
@ -103,9 +112,11 @@ class GroundInterceptOperation(Operation):
|
|||||||
mission: Mission,
|
mission: Mission,
|
||||||
attacker: Country,
|
attacker: Country,
|
||||||
defender: Country,
|
defender: Country,
|
||||||
|
attacker_clients: db.PlaneDict,
|
||||||
|
defender_clients: db.PlaneDict,
|
||||||
position: Point,
|
position: Point,
|
||||||
target: typing.Dict[VehicleType, int],
|
target: db.ArmorDict,
|
||||||
strikegroup: typing.Dict[PlaneType, int]):
|
strikegroup: db.PlaneDict):
|
||||||
conflict = Conflict.ground_intercept_conflict(
|
conflict = Conflict.ground_intercept_conflict(
|
||||||
attacker=attacker,
|
attacker=attacker,
|
||||||
defender=defender,
|
defender=defender,
|
||||||
@ -115,10 +126,12 @@ class GroundInterceptOperation(Operation):
|
|||||||
)
|
)
|
||||||
|
|
||||||
super(GroundInterceptOperation, self).__init__(mission, conflict)
|
super(GroundInterceptOperation, self).__init__(mission, conflict)
|
||||||
|
self.attacker_clients = attacker_clients
|
||||||
|
self.defender_clients = defender_clients
|
||||||
self.strikegroup = strikegroup
|
self.strikegroup = strikegroup
|
||||||
self.target = target
|
self.target = target
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.airgen.generate_cas(self.strikegroup)
|
self.airgen.generate_cas(self.strikegroup, clients=self.attacker_clients)
|
||||||
self.armorgen.generate({}, self.target)
|
self.armorgen.generate({}, self.target)
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from random import randint
|
|||||||
|
|
||||||
import globals
|
import globals
|
||||||
|
|
||||||
|
from shop import db
|
||||||
from .conflictgen import *
|
from .conflictgen import *
|
||||||
from .naming import *
|
from .naming import *
|
||||||
|
|
||||||
@ -48,38 +49,44 @@ class AircraftConflictGenerator:
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
side: Country,
|
side: Country,
|
||||||
unit: UnitType,
|
unit: PlaneType,
|
||||||
count: int,
|
count: int,
|
||||||
|
client_count: int,
|
||||||
at: Point = None,
|
at: Point = None,
|
||||||
airport: Airport = None) -> PlaneGroup:
|
airport: Airport = None) -> FlyingGroup:
|
||||||
starttype = airport == None and StartType.Warm or StartType.Cold
|
starttype = airport is None and StartType.Warm or StartType.Cold
|
||||||
print("generating {} ({}) at {} {}".format(unit, count, at, airport, side))
|
|
||||||
assert count > 0
|
assert count > 0
|
||||||
|
|
||||||
return self.m.flight_group(
|
group = self.m.flight_group(
|
||||||
country=side,
|
country=side,
|
||||||
name=name,
|
name=name,
|
||||||
aircraft_type=unit,
|
aircraft_type=unit,
|
||||||
airport=airport,
|
airport=airport,
|
||||||
position=at,
|
position=at,
|
||||||
altitude=WARM_START_ALTITUDE,
|
altitude=WARM_START_ALTITUDE,
|
||||||
speed=WARM_START_AIRSPEED,
|
speed=WARM_START_AIRSPEED,
|
||||||
maintask=None,
|
maintask=None,
|
||||||
start_type=starttype,
|
start_type=starttype,
|
||||||
group_size=count)
|
group_size=count)
|
||||||
|
|
||||||
def _generate_escort(self, units: typing.Dict[PlaneType, int], airport: Airport, side: Country, location: Point):
|
for idx in range(client_count):
|
||||||
|
group.units[idx].set_client()
|
||||||
|
|
||||||
|
return group
|
||||||
|
|
||||||
|
def _generate_escort(self, units: db.PlaneDict, clients: db.PlaneDict, airport: Airport, side: Country, location: Point):
|
||||||
if len(self.escort_targets) == 0:
|
if len(self.escort_targets) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
for type, count in units.items():
|
for type, count in units.items():
|
||||||
group = self._generate_group(
|
group = self._generate_group(
|
||||||
name=namegen.next_escort_group_name(),
|
name=namegen.next_escort_group_name(),
|
||||||
side=side,
|
side=side,
|
||||||
unit=type,
|
unit=type,
|
||||||
count=count,
|
count=count,
|
||||||
at=location,
|
client_count=clients.get(type, 0),
|
||||||
airport=airport)
|
at=location,
|
||||||
|
airport=airport)
|
||||||
|
|
||||||
group.task = Escort.name
|
group.task = Escort.name
|
||||||
group.load_task_default_loadout(dcs.task.Escort)
|
group.load_task_default_loadout(dcs.task.Escort)
|
||||||
@ -91,7 +98,7 @@ class AircraftConflictGenerator:
|
|||||||
for group in self.escort_targets:
|
for group in self.escort_targets:
|
||||||
wayp.tasks.append(EscortTaskAction(group.id, engagement_max_dist=ESCORT_MAX_DIST))
|
wayp.tasks.append(EscortTaskAction(group.id, engagement_max_dist=ESCORT_MAX_DIST))
|
||||||
|
|
||||||
def generate_cas(self, attackers: typing.Dict[PlaneType, int], airport: Airport = None):
|
def generate_cas(self, attackers: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||||
assert len(self.escort_targets) == 0
|
assert len(self.escort_targets) == 0
|
||||||
|
|
||||||
for type, count in attackers.items():
|
for type, count in attackers.items():
|
||||||
@ -100,6 +107,7 @@ class AircraftConflictGenerator:
|
|||||||
side=self.conflict.attackers_side,
|
side=self.conflict.attackers_side,
|
||||||
unit=type,
|
unit=type,
|
||||||
count=count,
|
count=count,
|
||||||
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
||||||
airport=airport)
|
airport=airport)
|
||||||
self.escort_targets.append(group)
|
self.escort_targets.append(group)
|
||||||
@ -108,29 +116,32 @@ class AircraftConflictGenerator:
|
|||||||
group.task = CAS.name
|
group.task = CAS.name
|
||||||
group.load_task_default_loadout(CAS)
|
group.load_task_default_loadout(CAS)
|
||||||
|
|
||||||
def generate_cas_escort(self, attackers: typing.Dict[PlaneType, int], airport: Airport = None):
|
def generate_cas_escort(self, attackers: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||||
self._generate_escort(
|
self._generate_escort(
|
||||||
units=attackers,
|
units=attackers,
|
||||||
|
clients=clients,
|
||||||
airport=airport,
|
airport=airport,
|
||||||
side=self.conflict.attackers_side,
|
side=self.conflict.attackers_side,
|
||||||
location=airport is None and self._group_point(self.conflict.air_attackers_location) or None
|
location=airport is None and self._group_point(self.conflict.air_attackers_location) or None
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_transport_escort(self, escort: typing.Dict[PlaneType, int], airport: Airport = None):
|
def generate_transport_escort(self, escort: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||||
self._generate_escort(
|
self._generate_escort(
|
||||||
units=escort,
|
units=escort,
|
||||||
|
clients=clients,
|
||||||
airport=airport,
|
airport=airport,
|
||||||
side=self.conflict.defenders_side,
|
side=self.conflict.defenders_side,
|
||||||
location=airport is None and self._group_point(self.conflict.air_defenders_location) or None
|
location=airport is None and self._group_point(self.conflict.air_defenders_location) or None
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_defense(self, defenders: typing.Dict[PlaneType, int], airport: Airport = None):
|
def generate_defense(self, defenders: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||||
for type, count in defenders.items():
|
for type, count in defenders.items():
|
||||||
group = self._generate_group(
|
group = self._generate_group(
|
||||||
name=namegen.next_intercept_group_name(),
|
name=namegen.next_intercept_group_name(),
|
||||||
side=self.conflict.defenders_side,
|
side=self.conflict.defenders_side,
|
||||||
unit=type,
|
unit=type,
|
||||||
count=count,
|
count=count,
|
||||||
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_defenders_location) or None,
|
at=airport is None and self._group_point(self.conflict.air_defenders_location) or None,
|
||||||
airport=airport)
|
airport=airport)
|
||||||
|
|
||||||
@ -140,7 +151,7 @@ class AircraftConflictGenerator:
|
|||||||
wayp.tasks.append(dcs.task.EngageTargets(max_distance=self.conflict.size * INTERCEPT_MAX_DISTANCE_FACTOR))
|
wayp.tasks.append(dcs.task.EngageTargets(max_distance=self.conflict.size * INTERCEPT_MAX_DISTANCE_FACTOR))
|
||||||
wayp.tasks.append(dcs.task.OrbitAction())
|
wayp.tasks.append(dcs.task.OrbitAction())
|
||||||
|
|
||||||
def generate_transport(self, transport: typing.Dict[PlaneType, int], destination: Airport):
|
def generate_transport(self, transport: db.PlaneDict, destination: Airport):
|
||||||
assert len(self.escort_targets) == 0
|
assert len(self.escort_targets) == 0
|
||||||
|
|
||||||
for type, count in transport.items():
|
for type, count in transport.items():
|
||||||
@ -149,6 +160,7 @@ class AircraftConflictGenerator:
|
|||||||
side=self.conflict.defenders_side,
|
side=self.conflict.defenders_side,
|
||||||
unit=type,
|
unit=type,
|
||||||
count=count,
|
count=count,
|
||||||
|
client_count=0,
|
||||||
at=self._group_point(self.conflict.air_defenders_location),
|
at=self._group_point(self.conflict.air_defenders_location),
|
||||||
airport=None
|
airport=None
|
||||||
)
|
)
|
||||||
@ -158,13 +170,14 @@ class AircraftConflictGenerator:
|
|||||||
self.escort_targets.append(group)
|
self.escort_targets.append(group)
|
||||||
group.land_at(destination)
|
group.land_at(destination)
|
||||||
|
|
||||||
def generate_interception(self, interceptors: typing.Dict[PlaneType, int], airport: Airport = None):
|
def generate_interception(self, interceptors: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||||
for type, count in interceptors.items():
|
for type, count in interceptors.items():
|
||||||
group = self._generate_group(
|
group = self._generate_group(
|
||||||
name=namegen.next_intercept_group_name(),
|
name=namegen.next_intercept_group_name(),
|
||||||
side=self.conflict.attackers_side,
|
side=self.conflict.attackers_side,
|
||||||
unit=type,
|
unit=type,
|
||||||
count=count,
|
count=count,
|
||||||
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
||||||
airport=airport
|
airport=airport
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,6 +6,7 @@ from random import randint
|
|||||||
|
|
||||||
import globals
|
import globals
|
||||||
|
|
||||||
|
from shop import db
|
||||||
from .conflictgen import *
|
from .conflictgen import *
|
||||||
from .naming import *
|
from .naming import *
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ from dcs.country import *
|
|||||||
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
|
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
|
||||||
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
|
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
|
||||||
|
|
||||||
|
|
||||||
class ArmorConflictGenerator:
|
class ArmorConflictGenerator:
|
||||||
def __init__(self, mission: Mission, conflict: Conflict):
|
def __init__(self, mission: Mission, conflict: Conflict):
|
||||||
self.m = mission
|
self.m = mission
|
||||||
@ -34,7 +36,7 @@ class ArmorConflictGenerator:
|
|||||||
|
|
||||||
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_SIZE_FACTOR)
|
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_SIZE_FACTOR)
|
||||||
|
|
||||||
def _generate_group(self, side: Country, unit: UnitType, count: int, at: Point):
|
def _generate_group(self, side: Country, unit: VehicleType, count: int, at: Point):
|
||||||
for c in range(count):
|
for c in range(count):
|
||||||
group = self.m.vehicle_group(
|
group = self.m.vehicle_group(
|
||||||
side,
|
side,
|
||||||
@ -46,7 +48,7 @@ class ArmorConflictGenerator:
|
|||||||
wayp = group.add_waypoint(self.conflict.position)
|
wayp = group.add_waypoint(self.conflict.position)
|
||||||
wayp.tasks = []
|
wayp.tasks = []
|
||||||
|
|
||||||
def generate(self, attackers: typing.Dict[UnitType, int], defenders: typing.Dict[UnitType, int]):
|
def generate(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
|
||||||
for type, count in attackers.items():
|
for type, count in attackers.items():
|
||||||
self._generate_group(
|
self._generate_group(
|
||||||
side=self.conflict.attackers_side,
|
side=self.conflict.attackers_side,
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class Conflict:
|
|||||||
air_defenders_location = None # type: Point
|
air_defenders_location = None # type: Point
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def capture_conflict(self, attacker: Country, attack_heading: int, defender: Country, defense_heading: int, position: Point, size: int, radials: typing.List[int]):
|
def capture_conflict(self, attacker: Country, attack_heading: int, defender: Country, defense_heading: int, position: Point, size: int, radials: typing.Collection[int]):
|
||||||
instance = self()
|
instance = self()
|
||||||
instance.attackers_side = attacker
|
instance.attackers_side = attacker
|
||||||
instance.defenders_side = defender
|
instance.defenders_side = defender
|
||||||
|
|||||||
11
shop/db.py
11
shop/db.py
@ -40,21 +40,28 @@ PRICES = {
|
|||||||
|
|
||||||
Armor.ATGM_M1134_Stryker: 6,
|
Armor.ATGM_M1134_Stryker: 6,
|
||||||
Armor.APC_BTR_80: 6,
|
Armor.APC_BTR_80: 6,
|
||||||
|
|
||||||
|
AirDefence.AAA_ZU_23_on_Ural_375: 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_BY_TASK = {
|
UNIT_BY_TASK = {
|
||||||
FighterSweep: [Su_27, Su_33, Su_25, F_15C, MiG_15bis, MiG_21Bis, MiG_29A, ],
|
FighterSweep: [Su_27, Su_33, Su_25, F_15C, MiG_15bis, MiG_21Bis, MiG_29A, ],
|
||||||
CAS: [Su_25T, A_10A, A_10C, ],
|
CAS: [Su_25T, A_10A, A_10C, ],
|
||||||
CAP: [Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, Armor.APC_BTR_80, ],
|
CAP: [Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, Armor.APC_BTR_80, ],
|
||||||
AirDefence: [AirDefence.AAA_ZU_23_on_Ural_375, ],
|
AirDefence: [AirDefence.AAA_ZU_23_on_Ural_375, ],
|
||||||
Transport: [IL_76MD, S_3B_Tanker, ],
|
Transport: [IL_76MD, S_3B_Tanker, ],
|
||||||
}
|
}
|
||||||
|
|
||||||
UNIT_BY_COUNTRY = {
|
UNIT_BY_COUNTRY = {
|
||||||
"Russia": [Su_25T, A_10C, Su_27, Su_33, Su_25, MiG_15bis, MiG_21Bis, MiG_29A, AirDefence.AAA_ZU_23_on_Ural_375, Armor.APC_BTR_80, Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, IL_76MD, ],
|
"Russia": [Su_25T, Su_27, Su_33, Su_25, MiG_15bis, MiG_21Bis, MiG_29A, AirDefence.AAA_ZU_23_on_Ural_375, Armor.APC_BTR_80, Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, IL_76MD, ],
|
||||||
"USA": [F_15C, A_10C, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, S_3B_Tanker],
|
"USA": [F_15C, A_10C, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, S_3B_Tanker],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnitsDict = typing.Dict[UnitType, int]
|
||||||
|
PlaneDict = typing.Dict[PlaneType, int]
|
||||||
|
ArmorDict = typing.Dict[VehicleType, int]
|
||||||
|
AADict = typing.Dict[AirDefence, int]
|
||||||
|
|
||||||
|
|
||||||
def unit_task(unit: UnitType) -> Task:
|
def unit_task(unit: UnitType) -> Task:
|
||||||
for task, units in UNIT_BY_TASK.items():
|
for task, units in UNIT_BY_TASK.items():
|
||||||
|
|||||||
@ -3,6 +3,7 @@ from dcs.terrain import caucasus
|
|||||||
from .conflicttheater import *
|
from .conflicttheater import *
|
||||||
from .base import *
|
from .base import *
|
||||||
|
|
||||||
|
|
||||||
class CaucasusTheater(ConflictTheater):
|
class CaucasusTheater(ConflictTheater):
|
||||||
kutaisi = ControlPoint(caucasus.Kutaisi, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
kutaisi = ControlPoint(caucasus.Kutaisi, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
||||||
senaki = ControlPoint(caucasus.Senaki, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
senaki = ControlPoint(caucasus.Senaki, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
||||||
|
|||||||
@ -3,9 +3,33 @@ import random
|
|||||||
|
|
||||||
import dcs
|
import dcs
|
||||||
|
|
||||||
|
from shop import db
|
||||||
from theater.controlpoint import *
|
from theater.controlpoint import *
|
||||||
from theater.base import *
|
from theater.base import *
|
||||||
from theater.conflicttheater import *
|
from theater.conflicttheater import *
|
||||||
|
|
||||||
def generate_initial(theater: ConflictTheater):
|
UNIT_VARIETY = 2
|
||||||
pass
|
UNIT_AMOUNT_FACTOR = 1
|
||||||
|
|
||||||
|
|
||||||
|
def generate_initial(theater: ConflictTheater, enemy: str):
|
||||||
|
for cp in theater.enemy_bases():
|
||||||
|
if cp.captured:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for task in [CAP, FighterSweep, CAS, AirDefence]:
|
||||||
|
suitable_unittypes = db.find_unittype(task, enemy)
|
||||||
|
suitable_unittypes.sort(key=lambda x: db.PRICES[x])
|
||||||
|
|
||||||
|
importance = cp.importance * 10 - 10
|
||||||
|
units_idx_start = int(importance * UNIT_VARIETY)
|
||||||
|
units_idx_end = units_idx_start + UNIT_VARIETY
|
||||||
|
|
||||||
|
range_start = min(len(suitable_unittypes)-1, units_idx_start)
|
||||||
|
range_end = min(len(suitable_unittypes), units_idx_end)
|
||||||
|
unittypes = suitable_unittypes[range_start:range_end]
|
||||||
|
|
||||||
|
typecount = max(math.floor(importance * UNIT_AMOUNT_FACTOR), 1)
|
||||||
|
units = {unittype: typecount for unittype in unittypes}
|
||||||
|
print("{} - {}".format(cp.name, units))
|
||||||
|
cp.base.commision_units(units)
|
||||||
|
|||||||
@ -62,7 +62,11 @@ class BaseMenu(Menu):
|
|||||||
|
|
||||||
def sell(self, unit_type):
|
def sell(self, unit_type):
|
||||||
def action():
|
def action():
|
||||||
if self.base.total_units_of_type(unit_type) > 0:
|
if self.event.units.get(unit_type, 0) > 0:
|
||||||
|
price = db.PRICES[unit_type]
|
||||||
|
self.game.budget += price
|
||||||
|
self.event.units[unit_type] = self.event.units[unit_type] - 1
|
||||||
|
elif self.base.total_units_of_type(unit_type) > 0:
|
||||||
price = db.PRICES[unit_type]
|
price = db.PRICES[unit_type]
|
||||||
self.game.budget += price
|
self.game.budget += price
|
||||||
self.base.commit_losses({unit_type: 1})
|
self.base.commit_losses({unit_type: 1})
|
||||||
|
|||||||
@ -2,13 +2,15 @@ from tkinter import *
|
|||||||
from ui.window import *
|
from ui.window import *
|
||||||
from ui.eventresultsmenu import *
|
from ui.eventresultsmenu import *
|
||||||
|
|
||||||
|
from shop import db
|
||||||
from game.game import *
|
from game.game import *
|
||||||
from game import event
|
from game import event
|
||||||
|
|
||||||
|
|
||||||
class EventMenu(Menu):
|
class EventMenu(Menu):
|
||||||
aircraft_scramble_entries = None # type: typing.Dict[PlaneType, Entry]
|
aircraft_scramble_entries = None # type: typing.Dict[PlaneType , Entry]
|
||||||
armor_scramble_entries = None # type: typing.Dict[Armor, Entry]
|
aircraft_client_entries = None # type: typing.Dict[PlaneType, Entry]
|
||||||
|
armor_scramble_entries = None # type: typing.Dict[VehicleType, Entry]
|
||||||
|
|
||||||
def __init__(self, window: Window, parent, game: Game, event: event.Event):
|
def __init__(self, window: Window, parent, game: Game, event: event.Event):
|
||||||
super(EventMenu, self).__init__(window, parent, game)
|
super(EventMenu, self).__init__(window, parent, game)
|
||||||
@ -16,6 +18,7 @@ class EventMenu(Menu):
|
|||||||
self.event = event
|
self.event = event
|
||||||
self.aircraft_scramble_entries = {}
|
self.aircraft_scramble_entries = {}
|
||||||
self.armor_scramble_entries = {}
|
self.armor_scramble_entries = {}
|
||||||
|
self.aircraft_client_entries = {}
|
||||||
|
|
||||||
self.frame = self.window.right_pane
|
self.frame = self.window.right_pane
|
||||||
|
|
||||||
@ -31,11 +34,24 @@ class EventMenu(Menu):
|
|||||||
|
|
||||||
def scrable_row(unit_type, unit_count):
|
def scrable_row(unit_type, unit_count):
|
||||||
nonlocal row
|
nonlocal row
|
||||||
Label(self.frame, text="{} ({})".format(unit_type.id and unit_type.id or unit_type.name, unit_count)).grid(row=row)
|
Label(self.frame, text="{} ({})".format(db.unit_type_name(unit_type), unit_count)).grid(row=row)
|
||||||
e = Entry(self.frame)
|
scramble_entry = Entry(self.frame)
|
||||||
e.grid(column=1, row=row)
|
scramble_entry.grid(column=1, row=row)
|
||||||
|
self.aircraft_scramble_entries[unit_type] = scramble_entry
|
||||||
|
|
||||||
|
client_entry = Entry(self.frame)
|
||||||
|
client_entry.grid(column=2, row=row)
|
||||||
|
self.aircraft_client_entries[unit_type] = client_entry
|
||||||
|
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
def scramble_armor_row(unit_type, unit_count):
|
||||||
|
nonlocal row
|
||||||
|
Label(self.frame, text="{} ({})".format(db.unit_type_name(unit_type), unit_count)).grid(row=row)
|
||||||
|
scramble_entry = Entry(self.frame)
|
||||||
|
scramble_entry.grid(column=1, row=row)
|
||||||
|
self.armor_scramble_entries[unit_type] = scramble_entry
|
||||||
|
|
||||||
self.aircraft_scramble_entries[unit_type] = e
|
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
base = None # type: Base
|
base = None # type: Base
|
||||||
@ -48,8 +64,12 @@ class EventMenu(Menu):
|
|||||||
for unit_type, count in base.aircraft.items():
|
for unit_type, count in base.aircraft.items():
|
||||||
scrable_row(unit_type, count)
|
scrable_row(unit_type, count)
|
||||||
|
|
||||||
Button(self.frame, text="Commit", command=self.start).grid(row=row)
|
label("Armor")
|
||||||
Button(self.frame, text="Back", command=self.dismiss).grid(row=row)
|
for unit_type, count in base.armor.items():
|
||||||
|
scramble_armor_row(unit_type, count)
|
||||||
|
|
||||||
|
Button(self.frame, text="Commit", command=self.start).grid(column=0, row=row)
|
||||||
|
Button(self.frame, text="Back", command=self.dismiss).grid(column=2, row=row)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
scrambled_aircraft = {}
|
scrambled_aircraft = {}
|
||||||
@ -67,6 +87,13 @@ class EventMenu(Menu):
|
|||||||
elif task == FighterSweep:
|
elif task == FighterSweep:
|
||||||
scrambled_sweep[unit_type] = amount
|
scrambled_sweep[unit_type] = amount
|
||||||
|
|
||||||
|
scrambled_clients = {}
|
||||||
|
for unit_type, field in self.aircraft_client_entries.items():
|
||||||
|
value = field.get()
|
||||||
|
if value and int(value) > 0:
|
||||||
|
amount = int(value)
|
||||||
|
scrambled_clients[unit_type] = amount
|
||||||
|
|
||||||
scrambled_armor = {}
|
scrambled_armor = {}
|
||||||
for unit_type, field in self.armor_scramble_entries.items():
|
for unit_type, field in self.armor_scramble_entries.items():
|
||||||
value = field.get()
|
value = field.get()
|
||||||
@ -78,18 +105,22 @@ class EventMenu(Menu):
|
|||||||
if self.game.is_player_attack(self.event):
|
if self.game.is_player_attack(self.event):
|
||||||
e.player_attacking(cas=scrambled_cas,
|
e.player_attacking(cas=scrambled_cas,
|
||||||
escort=scrambled_sweep,
|
escort=scrambled_sweep,
|
||||||
armor=scrambled_armor)
|
armor=scrambled_armor,
|
||||||
|
clients=scrambled_clients)
|
||||||
else:
|
else:
|
||||||
e.player_defending(interceptors=scrambled_aircraft)
|
e.player_defending(interceptors=scrambled_aircraft,
|
||||||
|
clients=scrambled_clients)
|
||||||
elif type(self.event) is InterceptEvent:
|
elif type(self.event) is InterceptEvent:
|
||||||
e = self.event # type: InterceptEvent
|
e = self.event # type: InterceptEvent
|
||||||
if self.game.is_player_attack(self.event):
|
if self.game.is_player_attack(self.event):
|
||||||
e.player_attacking(interceptors=scrambled_aircraft)
|
e.player_attacking(interceptors=scrambled_aircraft,
|
||||||
|
clients=scrambled_clients)
|
||||||
else:
|
else:
|
||||||
e.player_defending(escort=scrambled_aircraft)
|
e.player_defending(escort=scrambled_aircraft,
|
||||||
|
clients=scrambled_clients)
|
||||||
elif type(self.event) is GroundInterceptEvent:
|
elif type(self.event) is GroundInterceptEvent:
|
||||||
e = self.event # type: GroundInterceptEvent
|
e = self.event # type: GroundInterceptEvent
|
||||||
e.player_attacking(e.to_cp.position.random_point_within(30000), strikegroup=scrambled_aircraft)
|
e.player_attacking(e.to_cp.position.random_point_within(30000), strikegroup=scrambled_aircraft, clients=scrambled_clients)
|
||||||
|
|
||||||
self.game.initiate_event(self.event)
|
self.game.initiate_event(self.event)
|
||||||
EventResultsMenu(self.window, self.parent, self.game, self.event).display()
|
EventResultsMenu(self.window, self.parent, self.game, self.event).display()
|
||||||
|
|||||||
@ -44,12 +44,10 @@ class MainMenu(Menu):
|
|||||||
Button(self.frame, text=title, command=self.go_cp(cp)).grid(row=row, sticky=NW)
|
Button(self.frame, text=title, command=self.go_cp(cp)).grid(row=row, sticky=NW)
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
statusbar = Frame(self.frame).grid(column=0, row=row, sticky=NSEW)
|
Label(self.frame, text="Budget: {}m".format(self.game.budget)).grid(column=0, row=0, sticky=NW)
|
||||||
|
Button(self.frame, text="Pass turn", command=self.pass_turn).grid(column=1, row=0, sticky=NE)
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
Label(statusbar, text="Budget: {}m".format(self.game.budget)).grid(column=0, row=0, sticky=NW)
|
|
||||||
Button(statusbar, text="Pass turn", command=self.pass_turn).grid(column=1, row=0, sticky=NE)
|
|
||||||
|
|
||||||
for event in self.game.events:
|
for event in self.game.events:
|
||||||
if not event.informational:
|
if not event.informational:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user