mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
prompt window with logs on raised exception; minor UI updates; minor fixes
This commit is contained in:
@@ -463,6 +463,9 @@ def unitdict_split(unit_dict: UnitsDict, count: int):
|
||||
|
||||
|
||||
def unitdict_restrict_count(unit_dict: UnitsDict, total_count: int) -> UnitsDict:
|
||||
if total_count == 0:
|
||||
return {}
|
||||
|
||||
groups = list(unitdict_split(unit_dict, total_count))
|
||||
if len(groups) > 0:
|
||||
return groups[0]
|
||||
|
||||
@@ -17,7 +17,7 @@ class AntiAAStrikeEvent(Event):
|
||||
targets = None # type: db.ArmorDict
|
||||
|
||||
def __str__(self):
|
||||
return "Anti-AA strike from {} at {}".format(self.from_cp, self.to_cp)
|
||||
return "Anti-AA strike"
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
total_targets = sum(self.targets.values())
|
||||
|
||||
@@ -16,7 +16,7 @@ class BaseAttackEvent(Event):
|
||||
STRENGTH_RECOVERY = 0.55
|
||||
|
||||
def __str__(self):
|
||||
return "Base attack from {} to {}".format(self.from_cp, self.to_cp)
|
||||
return "Base attack"
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
alive_attackers = sum([v for k, v in debriefing.alive_units[self.attacker_name].items() if db.unit_task(k) == PinpointStrike])
|
||||
|
||||
@@ -25,7 +25,7 @@ class FrontlineAttackEvent(Event):
|
||||
return "{} vehicles".format(self.to_cp.base.assemble_count())
|
||||
|
||||
def __str__(self):
|
||||
return "Frontline attack from {} at {}".format(self.from_cp, self.to_cp)
|
||||
return "Frontline attack"
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
alive_attackers = sum([v for k, v in debriefing.alive_units[self.attacker_name].items() if db.unit_task(k) == PinpointStrike])
|
||||
|
||||
@@ -23,7 +23,7 @@ class FrontlinePatrolEvent(Event):
|
||||
return "{} aircraft + ? CAS".format(self.to_cp.base.scramble_count(self.game.settings.multiplier * self.ESCORT_FACTOR, CAP))
|
||||
|
||||
def __str__(self):
|
||||
return "Frontline CAP from {} at {}".format(self.from_cp, self.to_cp)
|
||||
return "Frontline CAP"
|
||||
|
||||
"""
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
|
||||
@@ -16,7 +16,7 @@ class InfantryTransportEvent(Event):
|
||||
STRENGTH_INFLUENCE = 0.3
|
||||
|
||||
def __str__(self):
|
||||
return "Frontline transport troops to {}".format(self.to_cp)
|
||||
return "Frontline transport troops"
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
return True
|
||||
|
||||
@@ -19,7 +19,7 @@ class InsurgentAttackEvent(Event):
|
||||
return ""
|
||||
|
||||
def __str__(self):
|
||||
return "Destroy insurgents at {}".format(self.to_cp)
|
||||
return "Destroy insurgents"
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
killed_units = sum([v for k, v in debriefing.destroyed_units[self.attacker_name].items() if db.unit_task(k) == PinpointStrike])
|
||||
|
||||
@@ -20,7 +20,7 @@ class InterceptEvent(Event):
|
||||
transport_unit = None # type: FlyingType
|
||||
|
||||
def __str__(self):
|
||||
return "Intercept from {} at {}".format(self.from_cp, self.to_cp)
|
||||
return "Intercept"
|
||||
|
||||
def _enemy_scramble_multiplier(self) -> float:
|
||||
is_global = self.from_cp.is_global or self.to_cp.is_global
|
||||
|
||||
@@ -24,7 +24,7 @@ class NavalInterceptEvent(Event):
|
||||
return max(int(factor), 1)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Naval intercept at {}".format(self.to_cp)
|
||||
return "Naval intercept"
|
||||
|
||||
@property
|
||||
def threat_description(self):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import typing
|
||||
import random
|
||||
import math
|
||||
@@ -171,7 +172,7 @@ class Game:
|
||||
if points_to_spend > 0:
|
||||
unittypes = self.commision_unit_types(cp, for_task)
|
||||
d = {random.choice(unittypes): points_to_spend}
|
||||
print("Commision {}: {}".format(cp, d))
|
||||
logging.info("Commision {}: {}".format(cp, d))
|
||||
cp.base.commision_units(d)
|
||||
|
||||
@property
|
||||
@@ -204,10 +205,13 @@ class Game:
|
||||
def initiate_event(self, event: Event):
|
||||
assert event in self.events
|
||||
|
||||
logging.info("Generating {} (regular)".format(event))
|
||||
event.generate()
|
||||
logging.info("Generating {} (quick)".format(event))
|
||||
event.generate_quick()
|
||||
|
||||
def finish_event(self, event: Event, debriefing: Debriefing):
|
||||
logging.info("Finishing event {}".format(event))
|
||||
event.commit(debriefing)
|
||||
if event.is_successfull(debriefing):
|
||||
self.budget += event.bonus()
|
||||
@@ -215,7 +219,7 @@ class Game:
|
||||
if event in self.events:
|
||||
self.events.remove(event)
|
||||
else:
|
||||
print("finish_event: event not in the events!")
|
||||
logging.info("finish_event: event not in the events!")
|
||||
|
||||
def is_player_attack(self, event):
|
||||
if isinstance(event, Event):
|
||||
@@ -224,6 +228,7 @@ class Game:
|
||||
return event.name == self.player
|
||||
|
||||
def pass_turn(self, no_action=False, ignored_cps: typing.Collection[ControlPoint]=None):
|
||||
logging.info("Pass turn")
|
||||
for event in self.events:
|
||||
event.skip()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user