fix canceled tie spent tokens
This commit is contained in:
parent
31a2ebb9dc
commit
097823fab0
4 changed files with 25 additions and 3 deletions
|
|
@ -186,7 +186,6 @@ class CampaignController:
|
|||
RefreshScope.WARS_TREE, item_type=ItemType.CAMPAIGN, item_id=campaign_id
|
||||
)
|
||||
|
||||
# TODO fix spent tokens on tie cancel
|
||||
def resolve_ties(
|
||||
self, war: War, contexts: List[TieContext]
|
||||
) -> Dict[str, Dict[str, bool]]:
|
||||
|
|
@ -208,6 +207,7 @@ class CampaignController:
|
|||
context_id=ctx.context_id,
|
||||
)
|
||||
if not dialog.exec():
|
||||
TieResolver.cancel_tie_break(war, ContextType.CAMPAIGN, ctx.context_id)
|
||||
raise ForbiddenOperation("Tie resolution cancelled")
|
||||
bids_map[ctx.context_id] = dialog.get_bids()
|
||||
return bids_map
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ class WarController:
|
|||
RefreshScope.WARS_TREE, item_type=ItemType.WAR, item_id=war_id
|
||||
)
|
||||
|
||||
# TODO fix spent tokens on tie cancel
|
||||
# TODO fix ignored campaign tie-breaks
|
||||
def resolve_ties(
|
||||
self, war: War, contexts: List[TieContext]
|
||||
|
|
@ -184,6 +183,7 @@ class WarController:
|
|||
context_id=ctx.context_id,
|
||||
)
|
||||
if not dialog.exec():
|
||||
TieResolver.cancel_tie_break(war, ContextType.WAR, ctx.context_id)
|
||||
raise ForbiddenOperation("Tie resolution cancelled")
|
||||
bids_map[ctx.context_id] = dialog.get_bids()
|
||||
return bids_map
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class ResultChecker:
|
|||
and ev.context_id == context_id
|
||||
):
|
||||
return ev.participant_id # None if confirmed draw
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -130,6 +130,29 @@ class TieResolver:
|
|||
)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def cancel_tie_break(
|
||||
war: War,
|
||||
context_type: ContextType,
|
||||
context_id: str,
|
||||
) -> None:
|
||||
war.events = [
|
||||
ev
|
||||
for ev in war.events
|
||||
if not (
|
||||
(
|
||||
isinstance(ev, InfluenceSpent)
|
||||
and ev.context_type == context_type
|
||||
and ev.context_id == context_id
|
||||
)
|
||||
or (
|
||||
isinstance(ev, TieResolved)
|
||||
and ev.context_type == context_type
|
||||
and ev.context_id == context_id
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def rank_by_tokens(
|
||||
war: War,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue