mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Merge branch 'master' of https://github.com/shdwp/dcs_pmcliberation
This commit is contained in:
commit
3d0babf65f
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "submodules/dcs"]
|
||||||
|
path = submodules/dcs
|
||||||
|
url = https://github.com/pydcs/dcs
|
||||||
@ -20,11 +20,6 @@ m = dcs.Mission()
|
|||||||
theater = theater.caucasus.CaucasusTheater()
|
theater = theater.caucasus.CaucasusTheater()
|
||||||
|
|
||||||
start_generator.generate_initial(theater, "Russia")
|
start_generator.generate_initial(theater, "Russia")
|
||||||
theater.kutaisi.base.aircraft = {
|
|
||||||
F_15C: 4,
|
|
||||||
A_10C: 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
g = Game(theater=theater)
|
g = Game(theater=theater)
|
||||||
|
|
||||||
w = ui.window.Window()
|
w = ui.window.Window()
|
||||||
|
|||||||
@ -83,6 +83,7 @@ class GroundInterceptEvent(Event):
|
|||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
attacker_clients=clients,
|
attacker_clients=clients,
|
||||||
defender_clients={},
|
defender_clients={},
|
||||||
|
from_cp=self.from_cp,
|
||||||
position=position,
|
position=position,
|
||||||
target=targets,
|
target=targets,
|
||||||
strikegroup=strikegroup)
|
strikegroup=strikegroup)
|
||||||
@ -120,8 +121,8 @@ class InterceptEvent(Event):
|
|||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
attacker_clients=clients,
|
attacker_clients=clients,
|
||||||
defender_clients={},
|
defender_clients={},
|
||||||
destination=self.to_cp,
|
from_cp=self.from_cp,
|
||||||
destination_port=self.to_cp.airport,
|
to_cp=self.to_cp,
|
||||||
escort=escort,
|
escort=escort,
|
||||||
transport={transport_unit: 1},
|
transport={transport_unit: 1},
|
||||||
airdefense={airdefense_unit: self.AIRDEFENSE_COUNT},
|
airdefense={airdefense_unit: self.AIRDEFENSE_COUNT},
|
||||||
@ -137,8 +138,8 @@ class InterceptEvent(Event):
|
|||||||
defender=self.defender,
|
defender=self.defender,
|
||||||
attacker_clients={},
|
attacker_clients={},
|
||||||
defender_clients=clients,
|
defender_clients=clients,
|
||||||
destination=self.to_cp,
|
from_cp=self.from_cp,
|
||||||
destination_port=self.to_cp.airport,
|
to_cp=self.to_cp,
|
||||||
escort=escort,
|
escort=escort,
|
||||||
transport={transport_unit: 1},
|
transport={transport_unit: 1},
|
||||||
interceptors=interceptors,
|
interceptors=interceptors,
|
||||||
|
|||||||
@ -23,8 +23,8 @@ COMMISION_AMOUNTS_FACTORS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ENEMY_INTERCEPT_PROBABILITY_BASE = 15
|
ENEMY_INTERCEPT_PROBABILITY_BASE = 10
|
||||||
ENEMY_CAPTURE_PROBABILITY_BASE = 5
|
ENEMY_CAPTURE_PROBABILITY_BASE = 3
|
||||||
|
|
||||||
PLAYER_INTERCEPT_PROBABILITY_BASE = 30
|
PLAYER_INTERCEPT_PROBABILITY_BASE = 30
|
||||||
PLAYER_GROUNDINTERCEPT_PROBABILITY_BASE = 30
|
PLAYER_GROUNDINTERCEPT_PROBABILITY_BASE = 30
|
||||||
@ -128,7 +128,8 @@ class Game:
|
|||||||
return event
|
return event
|
||||||
|
|
||||||
def units_delivery_remove(self, event: Event):
|
def units_delivery_remove(self, event: Event):
|
||||||
self.events.remove(event)
|
if event in self.events:
|
||||||
|
self.events.remove(event)
|
||||||
|
|
||||||
def initiate_event(self, event: Event):
|
def initiate_event(self, event: Event):
|
||||||
event.operation.generate()
|
event.operation.generate()
|
||||||
|
|||||||
@ -13,6 +13,7 @@ from shop import *
|
|||||||
from gen.armor import *
|
from gen.armor import *
|
||||||
from gen.aircraft import *
|
from gen.aircraft import *
|
||||||
from gen.aaa import *
|
from gen.aaa import *
|
||||||
|
from gen.shipgen import *
|
||||||
from gen.conflictgen import *
|
from gen.conflictgen import *
|
||||||
|
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ class Operation:
|
|||||||
self.armorgen = ArmorConflictGenerator(self.mission, self.conflict)
|
self.armorgen = ArmorConflictGenerator(self.mission, self.conflict)
|
||||||
self.airgen = AircraftConflictGenerator(self.mission, self.conflict)
|
self.airgen = AircraftConflictGenerator(self.mission, self.conflict)
|
||||||
self.aagen = AAConflictGenerator(self.mission, self.conflict)
|
self.aagen = AAConflictGenerator(self.mission, self.conflict)
|
||||||
|
self.shipgen = ShipGenerator(self.mission, self.conflict)
|
||||||
|
|
||||||
def units_of(self, country_name: str) -> typing.Collection[UnitType]:
|
def units_of(self, country_name: str) -> typing.Collection[UnitType]:
|
||||||
return []
|
return []
|
||||||
@ -67,10 +69,11 @@ 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, clients=self.attacker_clients)
|
|
||||||
self.airgen.generate_cas_escort(self.escort, clients=self.attacker_clients)
|
|
||||||
self.airgen.generate_defense(self.intercept, clients=self.defender_clients)
|
|
||||||
self.aagen.generate(self.aa)
|
self.aagen.generate(self.aa)
|
||||||
|
self.airgen.generate_defense(self.intercept, clients=self.defender_clients)
|
||||||
|
|
||||||
|
self.airgen.generate_cas(self.cas, clients=self.attacker_clients, at=self.from_cp.at)
|
||||||
|
self.airgen.generate_cas_escort(self.escort, clients=self.attacker_clients, at=self.from_cp.at)
|
||||||
|
|
||||||
|
|
||||||
class InterceptOperation(Operation):
|
class InterceptOperation(Operation):
|
||||||
@ -80,8 +83,8 @@ class InterceptOperation(Operation):
|
|||||||
defender: Country,
|
defender: Country,
|
||||||
attacker_clients: db.PlaneDict,
|
attacker_clients: db.PlaneDict,
|
||||||
defender_clients: db.PlaneDict,
|
defender_clients: db.PlaneDict,
|
||||||
destination: ControlPoint,
|
from_cp: ControlPoint,
|
||||||
destination_port: Airport,
|
to_cp: ControlPoint,
|
||||||
escort: db.PlaneDict,
|
escort: db.PlaneDict,
|
||||||
transport: db.PlaneDict,
|
transport: db.PlaneDict,
|
||||||
airdefense: db.AirDefenseDict,
|
airdefense: db.AirDefenseDict,
|
||||||
@ -89,13 +92,14 @@ class InterceptOperation(Operation):
|
|||||||
conflict = Conflict.intercept_conflict(
|
conflict = Conflict.intercept_conflict(
|
||||||
attacker=attacker,
|
attacker=attacker,
|
||||||
defender=defender,
|
defender=defender,
|
||||||
position=destination.position,
|
position=to_cp.position,
|
||||||
heading=randint(0, 360),
|
heading=randint(0, 360),
|
||||||
radials=ALL_RADIALS
|
radials=ALL_RADIALS
|
||||||
)
|
)
|
||||||
|
|
||||||
super(InterceptOperation, self).__init__(mission, conflict)
|
super(InterceptOperation, self).__init__(mission, conflict)
|
||||||
self.destination_port = destination_port
|
self.to_cp = to_cp
|
||||||
|
self.from_cp = from_cp
|
||||||
self.attacker_clients = attacker_clients
|
self.attacker_clients = attacker_clients
|
||||||
self.defender_clients = defender_clients
|
self.defender_clients = defender_clients
|
||||||
self.escort = escort
|
self.escort = escort
|
||||||
@ -104,17 +108,22 @@ class InterceptOperation(Operation):
|
|||||||
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.to_cp.at)
|
||||||
self.airgen.generate_transport_escort(self.escort, clients=self.defender_clients)
|
self.airgen.generate_transport_escort(self.escort, clients=self.defender_clients)
|
||||||
self.airgen.generate_interception(self.interceptors, clients=self.attacker_clients)
|
|
||||||
self.aagen.generate(self.airdefense)
|
self.aagen.generate(self.airdefense)
|
||||||
|
|
||||||
|
if self.from_cp.is_global:
|
||||||
|
self.airgen.generate_interception(self.interceptors, clients=self.attacker_clients, at=self.shipgen.generate(self.from_cp.at))
|
||||||
|
else:
|
||||||
|
self.airgen.generate_interception(self.interceptors, clients=self.attacker_clients, at=self.from_cp.at)
|
||||||
|
|
||||||
|
|
||||||
class GroundInterceptOperation(Operation):
|
class GroundInterceptOperation(Operation):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
mission: Mission,
|
mission: Mission,
|
||||||
attacker: Country,
|
attacker: Country,
|
||||||
defender: Country,
|
defender: Country,
|
||||||
|
from_cp: ControlPoint,
|
||||||
attacker_clients: db.PlaneDict,
|
attacker_clients: db.PlaneDict,
|
||||||
defender_clients: db.PlaneDict,
|
defender_clients: db.PlaneDict,
|
||||||
position: Point,
|
position: Point,
|
||||||
@ -131,10 +140,10 @@ class GroundInterceptOperation(Operation):
|
|||||||
super(GroundInterceptOperation, self).__init__(mission, conflict)
|
super(GroundInterceptOperation, self).__init__(mission, conflict)
|
||||||
self.attacker_clients = attacker_clients
|
self.attacker_clients = attacker_clients
|
||||||
self.defender_clients = defender_clients
|
self.defender_clients = defender_clients
|
||||||
|
self.from_cp = from_cp
|
||||||
self.strikegroup = strikegroup
|
self.strikegroup = strikegroup
|
||||||
self.target = target
|
self.target = target
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
self.airgen.generate_cas(self.strikegroup, clients=self.attacker_clients)
|
self.airgen.generate_cas(self.strikegroup, clients=self.attacker_clients, at=self.from_cp.at)
|
||||||
self.armorgen.generate({}, self.target)
|
self.armorgen.generate({}, self.target)
|
||||||
|
|
||||||
|
|||||||
124
gen/aircraft.py
124
gen/aircraft.py
@ -45,28 +45,39 @@ class AircraftConflictGenerator:
|
|||||||
)
|
)
|
||||||
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_FACTOR[0])
|
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_FACTOR[0])
|
||||||
|
|
||||||
def _generate_group(
|
def _generate_at_airport(self, name: str, side: Country, unit_type: FlyingType, count: int, client_count: int, airport: Airport = None) -> FlyingGroup:
|
||||||
self,
|
|
||||||
name: str,
|
|
||||||
side: Country,
|
|
||||||
unit: PlaneType,
|
|
||||||
count: int,
|
|
||||||
client_count: int,
|
|
||||||
at: Point = None,
|
|
||||||
airport: Airport = None) -> FlyingGroup:
|
|
||||||
starttype = airport is None and StartType.Warm or StartType.Cold
|
|
||||||
assert count > 0
|
assert count > 0
|
||||||
|
assert unit is not None
|
||||||
|
|
||||||
|
group = self.m.flight_group_from_airport(
|
||||||
|
country=side,
|
||||||
|
name=name,
|
||||||
|
aircraft_type=unit_type,
|
||||||
|
airport=self.m.terrain.airport_by_id(airport.id),
|
||||||
|
maintask=None,
|
||||||
|
start_type=StartType.Cold,
|
||||||
|
group_size=count,
|
||||||
|
parking_slots=None)
|
||||||
|
|
||||||
|
for idx in range(client_count):
|
||||||
|
group.units[idx].set_client()
|
||||||
|
|
||||||
|
return group
|
||||||
|
|
||||||
|
def _generate_inflight(self, name: str, side: Country, unit_type: FlyingType, count: int, client_count: int, at: Point) -> FlyingGroup:
|
||||||
|
assert count > 0
|
||||||
|
assert unit is not None
|
||||||
|
|
||||||
group = self.m.flight_group(
|
group = self.m.flight_group(
|
||||||
country=side,
|
country=side,
|
||||||
name=name,
|
name=name,
|
||||||
aircraft_type=unit,
|
aircraft_type=unit_type,
|
||||||
airport=airport,
|
airport=None,
|
||||||
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.Warm,
|
||||||
group_size=count)
|
group_size=count)
|
||||||
|
|
||||||
for idx in range(client_count):
|
for idx in range(client_count):
|
||||||
@ -74,7 +85,35 @@ class AircraftConflictGenerator:
|
|||||||
|
|
||||||
return group
|
return group
|
||||||
|
|
||||||
def _generate_escort(self, units: db.PlaneDict, clients: db.PlaneDict, airport: Airport, side: Country, location: Point):
|
def _generate_at_carrier(self, name: str, side: Country, unit_type: FlyingType, count: int, client_count: int, at: ShipGroup) -> FlyingGroup:
|
||||||
|
assert count > 0
|
||||||
|
assert unit is not None
|
||||||
|
|
||||||
|
group = self.m.flight_group_from_unit(
|
||||||
|
country=side,
|
||||||
|
name=name,
|
||||||
|
aircraft_type=unit_type,
|
||||||
|
pad_group=at,
|
||||||
|
maintask=None,
|
||||||
|
start_type=StartType.Warm,
|
||||||
|
group_size=count)
|
||||||
|
|
||||||
|
for idx in range(client_count):
|
||||||
|
group.units[idx].set_client()
|
||||||
|
|
||||||
|
return group
|
||||||
|
|
||||||
|
def _generate_group(self, name: str, side: Country, unit_type: FlyingType, count: int, client_count: int, at: db.StartingPosition):
|
||||||
|
if isinstance(at, Point):
|
||||||
|
return self._generate_inflight(name, side, unit_type, count, client_count, at)
|
||||||
|
elif issubclass(at, Airport):
|
||||||
|
return self._generate_at_airport(name, side, unit_type, count, client_count, at)
|
||||||
|
elif isinstance(at, ShipGroup):
|
||||||
|
return self._generate_at_carrier(name, side, unit_type, count, client_count, at)
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
|
||||||
|
def _generate_escort(self, side: Country, units: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition):
|
||||||
if len(self.escort_targets) == 0:
|
if len(self.escort_targets) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -82,11 +121,10 @@ class AircraftConflictGenerator:
|
|||||||
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=type,
|
||||||
count=count,
|
count=count,
|
||||||
client_count=clients.get(type, 0),
|
client_count=clients.get(type, 0),
|
||||||
at=location,
|
at=at)
|
||||||
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)
|
||||||
@ -98,52 +136,46 @@ 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: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
def generate_cas(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = 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():
|
||||||
group = self._generate_group(
|
group = self._generate_group(
|
||||||
name=namegen.next_cas_group_name(),
|
name=namegen.next_cas_group_name(),
|
||||||
side=self.conflict.attackers_side,
|
side=self.conflict.attackers_side,
|
||||||
unit=type,
|
unit_type=type,
|
||||||
count=count,
|
count=count,
|
||||||
client_count=clients.get(type, 0),
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
at=at and at or self._group_point(self.conflict.air_attackers_location))
|
||||||
airport=airport)
|
|
||||||
self.escort_targets.append(group)
|
self.escort_targets.append(group)
|
||||||
|
|
||||||
group.add_waypoint(self.conflict.position, CAS_ALTITUDE)
|
group.add_waypoint(self.conflict.position, CAS_ALTITUDE)
|
||||||
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: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
def generate_cas_escort(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||||
self._generate_escort(
|
self._generate_escort(
|
||||||
|
side=self.conflict.attackers_side,
|
||||||
units=attackers,
|
units=attackers,
|
||||||
clients=clients,
|
clients=clients,
|
||||||
airport=airport,
|
at=at and at or self._group_point(self.conflict.air_attackers_location))
|
||||||
side=self.conflict.attackers_side,
|
|
||||||
location=airport is None and self._group_point(self.conflict.air_attackers_location) or None
|
|
||||||
)
|
|
||||||
|
|
||||||
def generate_transport_escort(self, escort: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
def generate_transport_escort(self, escort: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||||
self._generate_escort(
|
self._generate_escort(
|
||||||
|
side=self.conflict.defenders_side,
|
||||||
units=escort,
|
units=escort,
|
||||||
clients=clients,
|
clients=clients,
|
||||||
airport=airport,
|
at=at and at or self._group_point(self.conflict.air_defenders_location))
|
||||||
side=self.conflict.defenders_side,
|
|
||||||
location=airport is None and self._group_point(self.conflict.air_defenders_location) or None
|
|
||||||
)
|
|
||||||
|
|
||||||
def generate_defense(self, defenders: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
def generate_defense(self, defenders: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = 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=type,
|
||||||
count=count,
|
count=count,
|
||||||
client_count=clients.get(type, 0),
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_defenders_location) or None,
|
at=at and at or self._group_point(self.conflict.air_defenders_location))
|
||||||
airport=airport)
|
|
||||||
|
|
||||||
group.task = FighterSweep.name
|
group.task = FighterSweep.name
|
||||||
group.load_task_default_loadout(FighterSweep)
|
group.load_task_default_loadout(FighterSweep)
|
||||||
@ -158,29 +190,25 @@ class AircraftConflictGenerator:
|
|||||||
group = self._generate_group(
|
group = self._generate_group(
|
||||||
name=namegen.next_transport_group_name(),
|
name=namegen.next_transport_group_name(),
|
||||||
side=self.conflict.defenders_side,
|
side=self.conflict.defenders_side,
|
||||||
unit=type,
|
unit_type=type,
|
||||||
count=count,
|
count=count,
|
||||||
client_count=0,
|
client_count=0,
|
||||||
at=self._group_point(self.conflict.air_defenders_location),
|
at=self._group_point(self.conflict.air_defenders_location))
|
||||||
airport=None
|
|
||||||
)
|
|
||||||
|
|
||||||
group.task = Transport.name
|
group.task = Transport.name
|
||||||
|
|
||||||
self.escort_targets.append(group)
|
self.escort_targets.append(group)
|
||||||
group.land_at(destination)
|
group.land_at(destination)
|
||||||
|
|
||||||
def generate_interception(self, interceptors: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
def generate_interception(self, interceptors: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = 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=type,
|
||||||
count=count,
|
count=count,
|
||||||
client_count=clients.get(type, 0),
|
client_count=clients.get(type, 0),
|
||||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
at=at and at or self._group_point(self.conflict.air_attackers_location))
|
||||||
airport=airport
|
|
||||||
)
|
|
||||||
|
|
||||||
group.task = FighterSweep.name
|
group.task = FighterSweep.name
|
||||||
group.load_task_default_loadout(FighterSweep)
|
group.load_task_default_loadout(FighterSweep)
|
||||||
|
|||||||
31
gen/shipgen.py
Normal file
31
gen/shipgen.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import typing
|
||||||
|
import pdb
|
||||||
|
import dcs
|
||||||
|
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
import globals
|
||||||
|
|
||||||
|
from .conflictgen import *
|
||||||
|
from .naming import *
|
||||||
|
|
||||||
|
from dcs.mission import *
|
||||||
|
from dcs.vehicles import *
|
||||||
|
from dcs.unitgroup import *
|
||||||
|
from dcs.unittype import *
|
||||||
|
from dcs.mapping import *
|
||||||
|
from dcs.point import *
|
||||||
|
from dcs.task import *
|
||||||
|
|
||||||
|
|
||||||
|
class ShipGenerator:
|
||||||
|
def __init__(self, mission: Mission, conflict: Conflict):
|
||||||
|
self.m = mission
|
||||||
|
self.conflict = conflict
|
||||||
|
|
||||||
|
def generate(self, at: Point) -> ShipGroup:
|
||||||
|
return self.m.ship_group(
|
||||||
|
country=self.conflict.attackers_side,
|
||||||
|
name=namegen.next_transport_group_name(),
|
||||||
|
_type=dcs.ships.CVN_74_John_C__Stennis,
|
||||||
|
position=at)
|
||||||
10
shop/db.py
10
shop/db.py
@ -17,6 +17,9 @@ PRICES = {
|
|||||||
A_10A: 18,
|
A_10A: 18,
|
||||||
A_10C: 20,
|
A_10C: 20,
|
||||||
|
|
||||||
|
F_A_18C: 18,
|
||||||
|
AV8BNA: 15,
|
||||||
|
|
||||||
Su_27: 30,
|
Su_27: 30,
|
||||||
Su_33: 33,
|
Su_33: 33,
|
||||||
F_15C: 30,
|
F_15C: 30,
|
||||||
@ -45,7 +48,7 @@ PRICES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, F_A_18C, AV8BNA],
|
||||||
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, ],
|
||||||
@ -53,14 +56,15 @@ UNIT_BY_TASK = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UNIT_BY_COUNTRY = {
|
UNIT_BY_COUNTRY = {
|
||||||
"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, ],
|
"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, F_A_18C, AV8BNA, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, S_3B_Tanker],
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitsDict = typing.Dict[UnitType, int]
|
UnitsDict = typing.Dict[UnitType, int]
|
||||||
PlaneDict = typing.Dict[PlaneType, int]
|
PlaneDict = typing.Dict[PlaneType, int]
|
||||||
ArmorDict = typing.Dict[VehicleType, int]
|
ArmorDict = typing.Dict[VehicleType, int]
|
||||||
AirDefenseDict = typing.Dict[AirDefence, int]
|
AirDefenseDict = typing.Dict[AirDefence, int]
|
||||||
|
StartingPosition = typing.Optional[typing.Union[ShipGroup, Airport, Point]]
|
||||||
|
|
||||||
|
|
||||||
def unit_task(unit: UnitType) -> Task:
|
def unit_task(unit: UnitType) -> Task:
|
||||||
|
|||||||
1
submodules/dcs
Submodule
1
submodules/dcs
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d982dfe594e16a45851050e8f63cec03c91aeed9
|
||||||
@ -29,6 +29,7 @@ class Base:
|
|||||||
self.armor = {}
|
self.armor = {}
|
||||||
self.aa = {}
|
self.aa = {}
|
||||||
self.commision_points = {}
|
self.commision_points = {}
|
||||||
|
self.strength = 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_planes(self) -> int:
|
def total_planes(self) -> int:
|
||||||
|
|||||||
@ -5,28 +5,36 @@ from .base import *
|
|||||||
|
|
||||||
|
|
||||||
class CaucasusTheater(ConflictTheater):
|
class CaucasusTheater(ConflictTheater):
|
||||||
soganlug = ControlPoint(caucasus.Soganlug, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
reference_points = {(-317948.32727306, 635639.37385346): (282.5, 319),
|
||||||
kutaisi = ControlPoint(caucasus.Kutaisi, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
(-355692.3067714, 617269.96285781): (269, 352), }
|
||||||
senaki = ControlPoint(caucasus.Senaki, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
|
||||||
kobuleti = ControlPoint(caucasus.Kobuleti, COAST_VERTICAL, SIZE_SMALL, IMPORTANCE_LOW)
|
|
||||||
batumi = ControlPoint(caucasus.Batumi, COAST_VERTICAL, SIZE_SMALL, IMPORTANCE_MEDIUM)
|
|
||||||
sukhumi = ControlPoint(caucasus.Sukhumi, COAST_VERTICAL, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
|
||||||
gudauta = ControlPoint(caucasus.Gudauta, COAST_VERTICAL, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
|
||||||
sochi = ControlPoint(caucasus.Sochi, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_HIGH)
|
|
||||||
|
|
||||||
maykop = ControlPoint(caucasus.Maykop, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
soganlug = ControlPoint.from_airport(caucasus.Soganlug, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
||||||
krasnodar = ControlPoint(caucasus.KrasnodarCenter, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
kutaisi = ControlPoint.from_airport(caucasus.Kutaisi, ALL_RADIALS, SIZE_SMALL, IMPORTANCE_LOW)
|
||||||
novorossiysk = ControlPoint(caucasus.Novorossiysk, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_HIGH)
|
senaki = ControlPoint.from_airport(caucasus.Senaki_Kolkhi, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
||||||
gelendzhik = ControlPoint(caucasus.Gelendzhik, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_HIGH)
|
kobuleti = ControlPoint.from_airport(caucasus.Kobuleti, COAST_VERTICAL, SIZE_SMALL, IMPORTANCE_LOW)
|
||||||
krymsk = ControlPoint(caucasus.Krymsk, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
batumi = ControlPoint.from_airport(caucasus.Batumi, COAST_VERTICAL, SIZE_SMALL, IMPORTANCE_MEDIUM)
|
||||||
anapa = ControlPoint(caucasus.Anapa, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
sukhumi = ControlPoint.from_airport(caucasus.Sukhumi_Babushara, COAST_VERTICAL, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
||||||
|
gudauta = ControlPoint.from_airport(caucasus.Gudauta, COAST_VERTICAL, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
||||||
|
sochi = ControlPoint.from_airport(caucasus.Sochi_Adler, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_HIGH)
|
||||||
|
|
||||||
beslan = ControlPoint(caucasus.Beslan, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
gelendzhik = ControlPoint.from_airport(caucasus.Gelendzhik, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_MEDIUM)
|
||||||
nalchik = ControlPoint(caucasus.Nalchik, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_MEDIUM)
|
maykop = ControlPoint.from_airport(caucasus.Maykop_Khanskaya, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
||||||
mineralnye = ControlPoint(caucasus.Mineralnye, ALL_RADIALS, SIZE_BIG, IMPORTANCE_HIGH)
|
krasnodar = ControlPoint.from_airport(caucasus.Krasnodar_Center, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
||||||
mozdok = ControlPoint(caucasus.Mozdok, ALL_RADIALS, SIZE_BIG, IMPORTANCE_HIGH)
|
novorossiysk = ControlPoint.from_airport(caucasus.Novorossiysk, COAST_VERTICAL, SIZE_BIG, IMPORTANCE_MEDIUM)
|
||||||
|
krymsk = ControlPoint.from_airport(caucasus.Krymsk, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
||||||
|
anapa = ControlPoint.from_airport(caucasus.Anapa_Vityazevo, ALL_RADIALS, SIZE_LARGE, IMPORTANCE_HIGH)
|
||||||
|
|
||||||
|
beslan = ControlPoint.from_airport(caucasus.Beslan, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
||||||
|
nalchik = ControlPoint.from_airport(caucasus.Nalchik, ALL_RADIALS, SIZE_REGULAR, IMPORTANCE_LOW)
|
||||||
|
mineralnye = ControlPoint.from_airport(caucasus.Mineralnye_Vody, ALL_RADIALS, SIZE_BIG, IMPORTANCE_MEDIUM)
|
||||||
|
mozdok = ControlPoint.from_airport(caucasus.Mozdok, ALL_RADIALS, SIZE_BIG, IMPORTANCE_MEDIUM)
|
||||||
|
|
||||||
|
carrier_1 = ControlPoint.carrier("Carrier", mapping.Point(-355810.6875, 516399.1875))
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
super(CaucasusTheater, self).__init__()
|
||||||
|
|
||||||
|
self.carrier_1.captured = True
|
||||||
self.soganlug.captured = True
|
self.soganlug.captured = True
|
||||||
|
|
||||||
self.add_controlpoint(self.soganlug, connected_to=[self.kutaisi, self.beslan])
|
self.add_controlpoint(self.soganlug, connected_to=[self.kutaisi, self.beslan])
|
||||||
@ -49,3 +57,5 @@ class CaucasusTheater(ConflictTheater):
|
|||||||
self.add_controlpoint(self.krymsk, connected_to=[self.novorossiysk, self.anapa, self.krasnodar])
|
self.add_controlpoint(self.krymsk, connected_to=[self.novorossiysk, self.anapa, self.krasnodar])
|
||||||
self.add_controlpoint(self.anapa, connected_to=[self.novorossiysk, self.krymsk])
|
self.add_controlpoint(self.anapa, connected_to=[self.novorossiysk, self.krymsk])
|
||||||
self.add_controlpoint(self.krasnodar, connected_to=[self.krymsk, self.maykop])
|
self.add_controlpoint(self.krasnodar, connected_to=[self.krymsk, self.maykop])
|
||||||
|
|
||||||
|
self.add_controlpoint(self.carrier_1)
|
||||||
|
|||||||
@ -20,7 +20,8 @@ COAST_HORIZONTAL = [315, 0, 45, ]
|
|||||||
|
|
||||||
|
|
||||||
class ConflictTheater:
|
class ConflictTheater:
|
||||||
controlpoints = [] # type: typing.List[ControlPoint]
|
controlpoints = None # type: typing.Collection[ControlPoint]
|
||||||
|
reference_points = None # type: typing.Dict
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.controlpoints = []
|
self.controlpoints = []
|
||||||
|
|||||||
@ -13,14 +13,15 @@ class ControlPoint:
|
|||||||
position = None # type: Point
|
position = None # type: Point
|
||||||
captured = False
|
captured = False
|
||||||
base: None # type: theater.base.Base
|
base: None # type: theater.base.Base
|
||||||
airport: None # type: Airport
|
at: None # type: db.StartPosition
|
||||||
|
|
||||||
def __init__(self, airport: Airport, radials: typing.Collection[int], size: int, importance: int):
|
def __init__(self, name: str, position: Point, at, radials: typing.Collection[int], size: int, importance: int):
|
||||||
import theater.base
|
import theater.base
|
||||||
|
|
||||||
self.name = airport.name
|
self.name = name
|
||||||
self.position = airport.position
|
self.position = position
|
||||||
self.airport = airport
|
self.at = at
|
||||||
|
|
||||||
self.size = size
|
self.size = size
|
||||||
self.importance = importance
|
self.importance = importance
|
||||||
self.captured = False
|
self.captured = False
|
||||||
@ -28,9 +29,22 @@ class ControlPoint:
|
|||||||
self.connected_points = []
|
self.connected_points = []
|
||||||
self.base = theater.base.Base()
|
self.base = theater.base.Base()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_airport(cls, airport: Airport, radials: typing.Collection[int], size: int, importance: int):
|
||||||
|
return cls(airport.name, airport.position, airport, radials, size, importance)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def carrier(cls, name: str, at: Point):
|
||||||
|
import theater.conflicttheater
|
||||||
|
return cls(name, at, at, theater.conflicttheater.ALL_RADIALS, theater.conflicttheater.SIZE_SMALL, 1)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_global(self):
|
||||||
|
return not self.connected_points
|
||||||
|
|
||||||
def connect(self, to):
|
def connect(self, to):
|
||||||
self.connected_points.append(to)
|
self.connected_points.append(to)
|
||||||
|
|
||||||
@ -61,5 +75,3 @@ class ControlPoint:
|
|||||||
position=self.position,
|
position=self.position,
|
||||||
size=self.size,
|
size=self.size,
|
||||||
radials=self.radials)
|
radials=self.radials)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,11 +19,12 @@ def generate_initial(theater: ConflictTheater, enemy: str):
|
|||||||
|
|
||||||
for task in [CAP, FighterSweep, CAS, AirDefence]:
|
for task in [CAP, FighterSweep, CAS, AirDefence]:
|
||||||
suitable_unittypes = db.find_unittype(task, enemy)
|
suitable_unittypes = db.find_unittype(task, enemy)
|
||||||
suitable_unittypes.sort(key=lambda x: db.PRICES[x])
|
suitable_unittypes.sort(key=lambda x: db.PRICES[x], reverse=True)
|
||||||
|
|
||||||
importance = cp.importance * 10 - 10
|
importance = IMPORTANCE_HIGH * 10 - cp.importance * 10
|
||||||
units_idx_start = int(importance * UNIT_VARIETY)
|
units_idx_start = int(importance)
|
||||||
units_idx_end = units_idx_start + UNIT_VARIETY
|
units_idx_end = units_idx_start + UNIT_VARIETY
|
||||||
|
print("{} - {}-{}".format(cp.name, units_idx_start, units_idx_end))
|
||||||
|
|
||||||
range_start = min(len(suitable_unittypes)-1, units_idx_start)
|
range_start = min(len(suitable_unittypes)-1, units_idx_start)
|
||||||
range_end = min(len(suitable_unittypes), units_idx_end)
|
range_end = min(len(suitable_unittypes), units_idx_end)
|
||||||
@ -31,5 +32,4 @@ def generate_initial(theater: ConflictTheater, enemy: str):
|
|||||||
|
|
||||||
typecount = max(math.floor(importance * UNIT_AMOUNT_FACTOR), 1)
|
typecount = max(math.floor(importance * UNIT_AMOUNT_FACTOR), 1)
|
||||||
units = {unittype: typecount for unittype in unittypes}
|
units = {unittype: typecount for unittype in unittypes}
|
||||||
print("{} - {}".format(cp.name, units))
|
|
||||||
cp.base.commision_units(units)
|
cp.base.commision_units(units)
|
||||||
|
|||||||
@ -15,10 +15,6 @@ class MainMenu(Menu):
|
|||||||
def __init__(self, window: Window, parent, game: Game):
|
def __init__(self, window: Window, parent, game: Game):
|
||||||
super(MainMenu, self).__init__(window, parent, game)
|
super(MainMenu, self).__init__(window, parent, game)
|
||||||
|
|
||||||
#self.image = PhotoImage(file="resources/caumap.gif")
|
|
||||||
#map = Label(window.left_pane, image=self.image)
|
|
||||||
#map.grid()
|
|
||||||
|
|
||||||
self.upd = OverviewCanvas(self.window.left_pane, self, game)
|
self.upd = OverviewCanvas(self.window.left_pane, self, game)
|
||||||
self.upd.update()
|
self.upd.update()
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from tkinter.ttk import *
|
|||||||
from ui.window import *
|
from ui.window import *
|
||||||
|
|
||||||
from game.game import *
|
from game.game import *
|
||||||
|
from theater.conflicttheater import *
|
||||||
|
|
||||||
|
|
||||||
class OverviewCanvas:
|
class OverviewCanvas:
|
||||||
@ -18,11 +19,11 @@ class OverviewCanvas:
|
|||||||
self.game = game
|
self.game = game
|
||||||
|
|
||||||
def cp_coordinates(self, cp: ControlPoint) -> (int, int):
|
def cp_coordinates(self, cp: ControlPoint) -> (int, int):
|
||||||
point_a = (-317948.32727306, 635639.37385346)
|
point_a = list(self.game.theater.reference_points.keys())[0]
|
||||||
point_a_img = 282.5, 319
|
point_a_img = self.game.theater.reference_points[point_a]
|
||||||
|
|
||||||
point_b = (-355692.3067714, 617269.96285781)
|
point_b = list(self.game.theater.reference_points.keys())[1]
|
||||||
point_b_img = 269, 352
|
point_b_img = self.game.theater.reference_points[point_b]
|
||||||
|
|
||||||
x_dist = point_a_img[0] - point_b_img[0]
|
x_dist = point_a_img[0] - point_b_img[0]
|
||||||
lon_dist = point_a[1] - point_b[1]
|
lon_dist = point_a[1] - point_b[1]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user