minor fixes before rc

This commit is contained in:
Vasyl Horbachenko 2018-09-10 01:48:38 +03:00
parent 7a5361c057
commit fa5259d1f2
9 changed files with 20 additions and 29 deletions

View File

@ -61,7 +61,7 @@ class BaseAttackEvent(Event):
self.to_cp.captured = False
def player_defending(self, flights: ScrambledFlightsDict):
assert len(flights) == 1 and flights[CAP], "Invalid scrambled flights"
assert CAP in flights and len(flights) == 1, "Invalid scrambled flights"
cas = self.from_cp.base.scramble_cas(self.game.settings.multiplier)
escort = self.from_cp.base.scramble_sweep(self.game.settings.multiplier)
@ -83,7 +83,7 @@ class BaseAttackEvent(Event):
self.operation = op
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAP] and flights[CAS] and flights[PinpointStrike] and len(flights) == 3, "Invalid flights"
assert CAP in flights and CAS in flights and PinpointStrike in flights and len(flights) == 3, "Invalid flights"
op = BaseAttackOperation(game=self.game,
attacker_name=self.attacker_name,

View File

@ -68,10 +68,10 @@ class Event:
return self.operation.is_successfull(debriefing)
def player_attacking(self, flights: ScrambledFlightsDict):
pass
assert False
def player_defending(self, flights: ScrambledFlightsDict):
pass
assert False
def generate(self):
self.operation.is_awacs_enabled = self.is_awacs_enabled

View File

@ -70,7 +70,7 @@ class FrontlineAttackEvent(Event):
self.to_cp.base.affect_strength(-0.1)
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAS] and flights[PinpointStrike] and len(flights) == 2, "Invalid flights"
assert CAS in flights and PinpointStrike in flights and len(flights) == 2, "Invalid flights"
self.defenders = self.to_cp.base.assemble_attack()

View File

@ -35,20 +35,6 @@ class FrontlinePatrolEvent(Event):
def __str__(self):
return "Frontline CAP"
"""
def is_successfull(self, debriefing: Debriefing):
total_targets = sum(self.cas.values())
destroyed_targets = 0
for unit, count in debriefing.destroyed_units[self.defender_name].items():
if unit in self.cas:
destroyed_targets += count
if self.from_cp.captured:
return float(destroyed_targets) / total_targets >= self.SUCCESS_TARGETS_HIT_PERCENTAGE
else:
return float(destroyed_targets) / total_targets < self.SUCCESS_TARGETS_HIT_PERCENTAGE
"""
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])
alive_defenders = sum([v for k, v in debriefing.alive_units[self.defender_name].items() if db.unit_task(k) == PinpointStrike])
@ -76,7 +62,7 @@ class FrontlinePatrolEvent(Event):
pass
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAP] and flights[PinpointStrike] and len(flights) == 2, "Invalid flights"
assert CAP in flights and PinpointStrike in flights and len(flights) == 2, "Invalid flights"
self.cas = self.to_cp.base.scramble_cas(self.game.settings.multiplier)
self.escort = self.to_cp.base.scramble_sweep(self.game.settings.multiplier * self.ESCORT_FACTOR)

View File

@ -38,7 +38,7 @@ class InfantryTransportEvent(Event):
self.from_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[Embarking] and len(flights) == 1, "Invalid flights"
assert Embarking in flights and len(flights) == 1, "Invalid flights"
op = InfantryTransportOperation(
game=self.game,

View File

@ -8,6 +8,8 @@ from game.event import *
from game.event.frontlineattack import FrontlineAttackEvent
from game.operation.insurgentattack import InsurgentAttackOperation
from .event import *
class InsurgentAttackEvent(Event):
SUCCESS_FACTOR = 0.7
@ -39,7 +41,7 @@ class InsurgentAttackEvent(Event):
return not attackers_success
def player_defending(self, flights: ScrambledFlightsDict):
assert flights[CAS] and len(flights) == 1, "Invalid flights"
assert CAS in flights and len(flights) == 1, "Invalid flights"
suitable_unittypes = db.find_unittype(Reconnaissance, self.attacker_name)
random.shuffle(suitable_unittypes)
@ -56,6 +58,3 @@ class InsurgentAttackEvent(Event):
strikegroup=flights[CAS])
self.operation = op
def player_attacking(self, interceptors: db.PlaneDict, clients: db.PlaneDict):
assert False

View File

@ -69,7 +69,7 @@ class InterceptEvent(Event):
self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAP] and len(flights) == 1, "Invalid flights"
assert CAP in flights and len(flights) == 1, "Invalid flights"
escort = self.to_cp.base.scramble_sweep(self._enemy_scramble_multiplier())
@ -91,6 +91,8 @@ class InterceptEvent(Event):
self.operation = op
def player_defending(self, flights: ScrambledFlightsDict):
assert CAP in flights and len(flights) == 1, "Invalid flights"
interceptors = self.from_cp.base.scramble_interceptors(self.game.settings.multiplier)
self.transport_unit = random.choice(db.find_unittype(Transport, self.defender_name))

View File

@ -78,7 +78,7 @@ class NavalInterceptEvent(Event):
self.to_cp.base.affect_strength(-self.STRENGTH_INFLUENCE)
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAS] and len(flights) == 1, "Invalid flights"
assert CAS in flights and len(flights) == 1, "Invalid flights"
self.targets = {
random.choice(db.find_unittype(CargoTransportation, self.defender_name)): self._targets_count(),
@ -99,7 +99,7 @@ class NavalInterceptEvent(Event):
self.operation = op
def player_defending(self, flights: ScrambledFlightsDict):
assert flights[CAP] and len(flights) == 1, "Invalid flights"
assert CAP in flights and len(flights) == 1, "Invalid flights"
self.targets = {
random.choice(db.find_unittype(CargoTransportation, self.defender_name)): self._targets_count(),

View File

@ -22,6 +22,10 @@ class StrikeEvent(Event):
def is_successfull(self, debriefing: Debriefing):
return True
@property
def threat_description(self):
return "{} aircraft + AA".format(self.to_cp.base.scramble_count(self.game.settings.multiplier, CAP))
@property
def tasks(self):
if self.is_player_attacking:
@ -47,7 +51,7 @@ class StrikeEvent(Event):
self.to_cp.base.affect_strength(-self.SINGLE_OBJECT_STRENGTH_INFLUENCE * len(debriefing.destroyed_objects))
def player_attacking(self, flights: ScrambledFlightsDict):
assert flights[CAP] and flights[CAS] and len(flights) == 2, "Invalid flights"
assert CAP in flights and CAS in flights and len(flights) == 2, "Invalid flights"
op = StrikeOperation(
self.game,