Merge pull request #27 from Khopa/combined_arms_slots

Combined arms slots
This commit is contained in:
Vasyl Horbachenko 2018-10-03 02:17:21 +03:00 committed by GitHub
commit 823c6a6137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 4 deletions

View File

@ -21,6 +21,7 @@ class Event:
silent = False
informational = False
is_awacs_enabled = False
ca_slots = 0
operation = None # type: Operation
difficulty = 1 # type: int
game = None # type: Game
@ -74,6 +75,7 @@ class Event:
def generate(self):
self.operation.is_awacs_enabled = self.is_awacs_enabled
self.operation.ca_slots = self.ca_slots
self.operation.prepare(self.game.theater.terrain, is_quick=False)
self.operation.generate()

View File

@ -27,6 +27,7 @@ class Operation:
trigger_radius = TRIGGER_RADIUS_MEDIUM
is_quick = None
is_awacs_enabled = False
ca_slots = 0
def __init__(self,
game,
@ -50,7 +51,6 @@ class Operation:
def initialize(self, mission: Mission, conflict: Conflict):
self.mission = mission
self.conflict = conflict
self.armorgen = ArmorConflictGenerator(mission, conflict)
self.airgen = AircraftConflictGenerator(mission, conflict, self.game.settings)
self.aagen = AAConflictGenerator(mission, conflict)
@ -90,6 +90,13 @@ class Operation:
if self.is_awacs_enabled:
self.briefinggen.append_frequency("AWACS", "133 MHz AM")
# combined arms
self.mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0
if self.game.player in [country.name for country in self.mission.coalition["blue"].countries.values()]:
self.mission.groundControl.blue_tactical_commander = self.ca_slots
else:
self.mission.groundControl.red_tactical_commander = self.ca_slots
# ground infrastructure
self.groundobjectgen.generate()
self.extra_aagen.generate()

View File

@ -45,6 +45,9 @@ class ArmorConflictGenerator:
group_size=1,
move_formation=PointAction.OffRoad)
vehicle: Vehicle = group.units[0]
vehicle.player_can_drive = True
if not to:
to = self.conflict.position.point_from_heading(0, 500)

View File

@ -9,7 +9,7 @@ from .styles import STYLES, RED
class EventMenu(Menu):
scramble_entries = None # type: typing.Dict[typing.Type[Task], typing.Dict[typing.Type[UnitType], typing.Tuple[Entry, Entry]]]
ca_slot_entry = None # type: Entry
error_label = None # type: Label
awacs = None # type: IntVar
@ -100,8 +100,15 @@ class EventMenu(Menu):
header("Support:")
# Options
awacs_enabled = self.game.budget >= AWACS_BUDGET_COST and NORMAL or DISABLED
Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=0, sticky=E)
Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=3, sticky=W, padx=5, pady=5)
Checkbutton(self.frame, var=self.awacs, state=awacs_enabled, **STYLES["radiobutton"]).grid(row=row, column=2, sticky=E)
Label(self.frame, text="AWACS ({}m)".format(AWACS_BUDGET_COST), **STYLES["widget"]).grid(row=row, column=0, sticky=W, pady=5)
row += 1
Label(self.frame, text="Combined Arms Slots", **STYLES["widget"]).grid(row=row, sticky=W)
self.ca_slot_entry = Entry(self.frame, width=2)
self.ca_slot_entry.insert(0, "0")
self.ca_slot_entry.grid(column=1, row=row, sticky=W, padx=5)
Button(self.frame, text="+", command=self.add_ca_slot, **STYLES["btn-primary"]).grid(column=2, row=row, padx=5, sticky=W)
row += 1
header("Ready?")
@ -124,6 +131,12 @@ class EventMenu(Menu):
return action
def add_ca_slot(self):
value = self.ca_slot_entry.get()
amount = int(value and value or "0")
self.ca_slot_entry.delete(0, END)
self.ca_slot_entry.insert(0, str(amount+1))
def client_one(self, task: typing.Type[Task], unit_type: UnitType) -> typing.Callable:
def action():
entry = self.scramble_entries[task][unit_type][1] # type: Entry
@ -140,6 +153,13 @@ class EventMenu(Menu):
else:
self.event.is_awacs_enabled = False
ca_slot_entry_value = self.ca_slot_entry.get()
try:
ca_slots = int(ca_slot_entry_value and ca_slot_entry_value or "0")
except:
ca_slots = 0
self.event.ca_slots = ca_slots
flights = {k: {} for k in self.event.tasks} # type: db.TaskForceDict
units_scramble_counts = {} # type: typing.Dict[typing.Type[UnitType], int]
tasks_scramble_counts = {} # type: typing.Dict[typing.Type[Task], int]