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
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
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.campaign_participant import CampaignParticipant
|
||||
|
|
@ -146,6 +146,15 @@ class Campaign:
|
|||
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(
|
||||
self,
|
||||
name: str,
|
||||
|
|
|
|||
|
|
@ -175,6 +175,14 @@ class War:
|
|||
def get_all_objectives(self) -> List[Objective]:
|
||||
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:
|
||||
if objective_id is None:
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue