mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
configure client slots on scramble + fixes
This commit is contained in:
@@ -62,7 +62,11 @@ class BaseMenu(Menu):
|
||||
|
||||
def sell(self, unit_type):
|
||||
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]
|
||||
self.game.budget += price
|
||||
self.base.commit_losses({unit_type: 1})
|
||||
|
||||
@@ -2,13 +2,15 @@ from tkinter import *
|
||||
from ui.window import *
|
||||
from ui.eventresultsmenu import *
|
||||
|
||||
from shop import db
|
||||
from game.game import *
|
||||
from game import event
|
||||
|
||||
|
||||
class EventMenu(Menu):
|
||||
aircraft_scramble_entries = None # type: typing.Dict[PlaneType, Entry]
|
||||
armor_scramble_entries = None # type: typing.Dict[Armor, Entry]
|
||||
aircraft_scramble_entries = None # type: typing.Dict[PlaneType , 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):
|
||||
super(EventMenu, self).__init__(window, parent, game)
|
||||
@@ -16,6 +18,7 @@ class EventMenu(Menu):
|
||||
self.event = event
|
||||
self.aircraft_scramble_entries = {}
|
||||
self.armor_scramble_entries = {}
|
||||
self.aircraft_client_entries = {}
|
||||
|
||||
self.frame = self.window.right_pane
|
||||
|
||||
@@ -31,11 +34,24 @@ class EventMenu(Menu):
|
||||
|
||||
def scrable_row(unit_type, unit_count):
|
||||
nonlocal row
|
||||
Label(self.frame, text="{} ({})".format(unit_type.id and unit_type.id or unit_type.name, unit_count)).grid(row=row)
|
||||
e = Entry(self.frame)
|
||||
e.grid(column=1, row=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.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
|
||||
|
||||
base = None # type: Base
|
||||
@@ -48,8 +64,12 @@ class EventMenu(Menu):
|
||||
for unit_type, count in base.aircraft.items():
|
||||
scrable_row(unit_type, count)
|
||||
|
||||
Button(self.frame, text="Commit", command=self.start).grid(row=row)
|
||||
Button(self.frame, text="Back", command=self.dismiss).grid(row=row)
|
||||
label("Armor")
|
||||
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):
|
||||
scrambled_aircraft = {}
|
||||
@@ -67,6 +87,13 @@ class EventMenu(Menu):
|
||||
elif task == FighterSweep:
|
||||
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 = {}
|
||||
for unit_type, field in self.armor_scramble_entries.items():
|
||||
value = field.get()
|
||||
@@ -78,18 +105,22 @@ class EventMenu(Menu):
|
||||
if self.game.is_player_attack(self.event):
|
||||
e.player_attacking(cas=scrambled_cas,
|
||||
escort=scrambled_sweep,
|
||||
armor=scrambled_armor)
|
||||
armor=scrambled_armor,
|
||||
clients=scrambled_clients)
|
||||
else:
|
||||
e.player_defending(interceptors=scrambled_aircraft)
|
||||
e.player_defending(interceptors=scrambled_aircraft,
|
||||
clients=scrambled_clients)
|
||||
elif type(self.event) is InterceptEvent:
|
||||
e = self.event # type: InterceptEvent
|
||||
if self.game.is_player_attack(self.event):
|
||||
e.player_attacking(interceptors=scrambled_aircraft)
|
||||
e.player_attacking(interceptors=scrambled_aircraft,
|
||||
clients=scrambled_clients)
|
||||
else:
|
||||
e.player_defending(escort=scrambled_aircraft)
|
||||
e.player_defending(escort=scrambled_aircraft,
|
||||
clients=scrambled_clients)
|
||||
elif type(self.event) is 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)
|
||||
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)
|
||||
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
|
||||
|
||||
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:
|
||||
if not event.informational:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user