list round choices ; fix UI
This commit is contained in:
parent
032ab2d2c4
commit
723723dea1
14 changed files with 683 additions and 99 deletions
|
|
@ -155,9 +155,9 @@ class Sector:
|
|||
self.id: str = str(uuid4())
|
||||
self.name: str = name
|
||||
self.round_id: str = round_id
|
||||
self.major_objective_id: str = major_id
|
||||
self.minor_objective_id: str = minor_id
|
||||
self.influence_objective_id: str = influence_id
|
||||
self.major_objective_id: str | None = major_id # ref to War.objectives
|
||||
self.minor_objective_id: str | None = minor_id # ref to War.objectives
|
||||
self.influence_objective_id: str | None = influence_id # ref to War.objectives
|
||||
|
||||
def set_id(self, new_id: str):
|
||||
self.id = new_id
|
||||
|
|
|
|||
|
|
@ -290,3 +290,15 @@ class Model:
|
|||
def remove_round(self, round_id: str):
|
||||
camp = self.get_campaign_by_round(round_id)
|
||||
camp.remove_round(round_id)
|
||||
|
||||
# Choices methods
|
||||
|
||||
def get_round_choices_data(self, round_id: str):
|
||||
camp = self.get_campaign_by_round(round_id)
|
||||
rnd = self.get_round(round_id)
|
||||
participants = camp.participants.values()
|
||||
sectors = [
|
||||
s for s in camp.sectors.values()
|
||||
if s.round_id == round_id
|
||||
]
|
||||
return camp, rnd, participants, sectors
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from __future__ import annotations
|
||||
from uuid import uuid4
|
||||
|
||||
class Round:
|
||||
def __init__(self):
|
||||
self.id: str = str(uuid4())
|
||||
self.sectors = {}
|
||||
self.choices = {}
|
||||
self.choices: dict[str, RoundChoice] = {}
|
||||
self.battles = {}
|
||||
self.is_over: bool = False
|
||||
|
||||
|
|
@ -14,6 +14,9 @@ class Round:
|
|||
def set_state(self, new_state: bool):
|
||||
self.is_over = new_state
|
||||
|
||||
def set_choice(self, participant_id: str, priority_sector_id: str | None, secondary_sector_id: str | None):
|
||||
self.choices[participant_id] = RoundChoice(participant_id, priority_sector_id, secondary_sector_id)
|
||||
|
||||
def toDict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
|
|
@ -31,4 +34,16 @@ class Round:
|
|||
# rnd.choices = data.get("choices", {})
|
||||
# rnd.battles = data.get("battles", {})
|
||||
rnd.set_state(data.get("is_over", False))
|
||||
return rnd
|
||||
return rnd
|
||||
|
||||
# Choices methods
|
||||
|
||||
def get_choice(self, participant_id: str) -> RoundChoice | None:
|
||||
return self.choices.get(participant_id)
|
||||
|
||||
|
||||
class RoundChoice:
|
||||
def __init__(self, participant_id: str, priority_sector_id: str | None = None, secondary_sector_id: str | None = None):
|
||||
self.participant_id: str = participant_id # ref to Campaign.participants
|
||||
self.priority_sector_id: str | None = priority_sector_id # ref to Campaign.sectors
|
||||
self.secondary_sector_id: str | None = secondary_sector_id # ref to Campaign.sectors
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue