simplify unused objectives display and tie-break
This commit is contained in:
parent
9b28e85557
commit
0c6014e946
5 changed files with 31 additions and 11 deletions
|
|
@ -60,8 +60,7 @@ class CampaignController:
|
||||||
vp_icon_map = RankingIcon.compute_icons(
|
vp_icon_map = RankingIcon.compute_icons(
|
||||||
war, ContextType.CAMPAIGN, campaign_id, scores
|
war, ContextType.CAMPAIGN, campaign_id, scores
|
||||||
)
|
)
|
||||||
# TODO get only objectives used in major/minor (ignore token only)
|
for obj in war.get_objectives_used_as_maj_or_min():
|
||||||
for obj in war.get_all_objectives():
|
|
||||||
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
|
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
|
||||||
war,
|
war,
|
||||||
ContextType.CAMPAIGN,
|
ContextType.CAMPAIGN,
|
||||||
|
|
@ -94,7 +93,8 @@ class CampaignController:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
objectives = [
|
objectives = [
|
||||||
ObjectiveDTO(o.id, o.name, o.description) for o in war.get_all_objectives()
|
ObjectiveDTO(o.id, o.name, o.description)
|
||||||
|
for o in war.get_objectives_used_as_maj_or_min()
|
||||||
]
|
]
|
||||||
self.app.view.display_campaign_participants(rows, objectives)
|
self.app.view.display_campaign_participants(rows, objectives)
|
||||||
self.app.view.endCampaignBtn.setEnabled(not camp.is_over)
|
self.app.view.endCampaignBtn.setEnabled(not camp.is_over)
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ class CampaignClosureWorkflow(ClosureWorkflow):
|
||||||
TieResolver.apply_bids(war, tie, bids)
|
TieResolver.apply_bids(war, tie, bids)
|
||||||
TieResolver.resolve_tie_state(war, tie, bids)
|
TieResolver.resolve_tie_state(war, tie, bids)
|
||||||
ties = TieResolver.find_campaign_ties(war, campaign.id)
|
ties = TieResolver.find_campaign_ties(war, campaign.id)
|
||||||
# TODO get only objectives used in major/minor (ignore token only)
|
for obj in war.get_objectives_used_as_maj_or_min():
|
||||||
for objective_id in war.objectives:
|
objective_id = obj.id
|
||||||
ties = TieResolver.find_campaign_objective_ties(
|
ties = TieResolver.find_campaign_objective_ties(
|
||||||
war,
|
war,
|
||||||
campaign.id,
|
campaign.id,
|
||||||
|
|
@ -77,8 +77,8 @@ class WarClosureWorkflow(ClosureWorkflow):
|
||||||
TieResolver.apply_bids(war, tie, bids)
|
TieResolver.apply_bids(war, tie, bids)
|
||||||
TieResolver.resolve_tie_state(war, tie, bids)
|
TieResolver.resolve_tie_state(war, tie, bids)
|
||||||
ties = TieResolver.find_war_ties(war)
|
ties = TieResolver.find_war_ties(war)
|
||||||
# TODO get only objectives used in major/minor (ignore token only)
|
for obj in war.get_objectives_used_as_maj_or_min():
|
||||||
for objective_id in war.objectives:
|
objective_id = obj.id
|
||||||
ties = TieResolver.find_war_objective_ties(
|
ties = TieResolver.find_war_objective_ties(
|
||||||
war,
|
war,
|
||||||
objective_id,
|
objective_id,
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ class WarController:
|
||||||
for obj in objectives
|
for obj in objectives
|
||||||
]
|
]
|
||||||
self.app.view.display_war_objectives(objectives_for_display)
|
self.app.view.display_war_objectives(objectives_for_display)
|
||||||
|
limited_objectives_for_display: List[ObjectiveDTO] = [
|
||||||
|
ObjectiveDTO(id=obj.id, name=obj.name, description=obj.description)
|
||||||
|
for obj in war.get_objectives_used_as_maj_or_min()
|
||||||
|
]
|
||||||
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
||||||
rows: List[WarParticipantScoreDTO] = []
|
rows: List[WarParticipantScoreDTO] = []
|
||||||
vp_icon_map: dict[str, QIcon] = {}
|
vp_icon_map: dict[str, QIcon] = {}
|
||||||
|
|
@ -60,8 +64,7 @@ class WarController:
|
||||||
vp_icon_map = RankingIcon.compute_icons(
|
vp_icon_map = RankingIcon.compute_icons(
|
||||||
war, ContextType.WAR, war_id, scores
|
war, ContextType.WAR, war_id, scores
|
||||||
)
|
)
|
||||||
# TODO get only objectives used in major/minor (ignore token only)
|
for obj in war.get_objectives_used_as_maj_or_min():
|
||||||
for obj in war.get_all_objectives():
|
|
||||||
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
|
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
|
||||||
war,
|
war,
|
||||||
ContextType.WAR,
|
ContextType.WAR,
|
||||||
|
|
@ -90,7 +93,7 @@ class WarController:
|
||||||
objective_icons=objective_icons,
|
objective_icons=objective_icons,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.app.view.display_war_participants(rows, objectives_for_display)
|
self.app.view.display_war_participants(rows, limited_objectives_for_display)
|
||||||
self.app.view.endWarBtn.setEnabled(not war.is_over)
|
self.app.view.endWarBtn.setEnabled(not war.is_over)
|
||||||
|
|
||||||
def _validate_war_inputs(self, name: str, year: int) -> bool:
|
def _validate_war_inputs(self, name: str, year: int) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List, Set
|
||||||
|
|
||||||
from warchron.model.exception import ForbiddenOperation, RequiresConfirmation
|
from warchron.model.exception import ForbiddenOperation, RequiresConfirmation
|
||||||
from warchron.model.campaign_participant import CampaignParticipant
|
from warchron.model.campaign_participant import CampaignParticipant
|
||||||
|
|
@ -146,6 +146,15 @@ class Campaign:
|
||||||
for sect in self.sectors.values()
|
for sect in self.sectors.values()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_objectives_used_as_maj_or_min(self) -> List[str]:
|
||||||
|
obj_ids: Set[str] = set()
|
||||||
|
for sector in self.sectors.values():
|
||||||
|
if sector.major_objective_id:
|
||||||
|
obj_ids.add(sector.major_objective_id)
|
||||||
|
if sector.minor_objective_id:
|
||||||
|
obj_ids.add(sector.minor_objective_id)
|
||||||
|
return [obj_id for obj_id in obj_ids]
|
||||||
|
|
||||||
def add_sector(
|
def add_sector(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,14 @@ class War:
|
||||||
def get_all_objectives(self) -> List[Objective]:
|
def get_all_objectives(self) -> List[Objective]:
|
||||||
return list(self.objectives.values())
|
return list(self.objectives.values())
|
||||||
|
|
||||||
|
def get_objectives_used_as_maj_or_min(self) -> List[Objective]:
|
||||||
|
obj_ids: set[str] = set()
|
||||||
|
for camp in self.campaigns:
|
||||||
|
obj_ids.update(camp.get_objectives_used_as_maj_or_min())
|
||||||
|
return [
|
||||||
|
self.objectives[obj_id] for obj_id in obj_ids if obj_id in self.objectives
|
||||||
|
]
|
||||||
|
|
||||||
def get_objective_name(self, objective_id: str | None) -> str:
|
def get_objective_name(self, objective_id: str | None) -> str:
|
||||||
if objective_id is None:
|
if objective_id is None:
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue