24 lines
816 B
Python
24 lines
816 B
Python
|
|
from warchron.model.war import War
|
||
|
|
from warchron.model.campaign import Campaign
|
||
|
|
from warchron.model.battle import Battle
|
||
|
|
from warchron.model.war_event import InfluenceGained
|
||
|
|
|
||
|
|
|
||
|
|
class InfluenceService:
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def apply_battle_result(war: War, campaign: Campaign, battle: Battle) -> None:
|
||
|
|
if battle.winner_id is None:
|
||
|
|
return
|
||
|
|
sector = campaign.sectors[battle.sector_id]
|
||
|
|
# if sector grants influence
|
||
|
|
if sector.influence_objective_id and war.influence_token:
|
||
|
|
participant = war.participants[battle.winner_id]
|
||
|
|
participant.events.append(
|
||
|
|
InfluenceGained(
|
||
|
|
participant_id=participant.id,
|
||
|
|
amount=1,
|
||
|
|
source=f"battle:{battle.sector_id}",
|
||
|
|
)
|
||
|
|
)
|