wip close round/campaign/war + refacto json None
This commit is contained in:
parent
4c8086caf4
commit
6cbb7c6534
26 changed files with 474 additions and 108 deletions
|
|
@ -1,13 +1,13 @@
|
|||
from typing import List, TYPE_CHECKING
|
||||
|
||||
from PyQt6.QtWidgets import QDialog
|
||||
from PyQt6.QtWidgets import QDialog, QMessageBox
|
||||
|
||||
from warchron.constants import ItemType, RefreshScope
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
from warchron.controller.dtos import ParticipantOption, SectorDTO, ChoiceDTO, BattleDTO
|
||||
|
||||
from warchron.model.closure_service import ClosureService
|
||||
from warchron.view.choices_dialog import ChoicesDialog
|
||||
from warchron.view.battles_dialog import BattlesDialog
|
||||
|
||||
|
|
@ -92,6 +92,7 @@ class RoundController:
|
|||
)
|
||||
)
|
||||
self.app.view.display_round_battles(battles_for_display)
|
||||
self.app.view.endRoundBtn.setEnabled(not rnd.is_over)
|
||||
|
||||
def add_round(self) -> None:
|
||||
if not self.app.navigation.selected_campaign_id:
|
||||
|
|
@ -102,6 +103,28 @@ class RoundController:
|
|||
RefreshScope.WARS_TREE, item_type=ItemType.ROUND, item_id=rnd.id
|
||||
)
|
||||
|
||||
def close_round(self) -> None:
|
||||
round_id = self.app.navigation.selected_round_id
|
||||
if not round_id:
|
||||
return
|
||||
rnd = self.app.model.get_round(round_id)
|
||||
if rnd.is_over:
|
||||
return
|
||||
try:
|
||||
ties = ClosureService.close_round(rnd)
|
||||
except RuntimeError as e:
|
||||
QMessageBox.warning(self.app.view, "Cannot close round", str(e))
|
||||
return
|
||||
if ties:
|
||||
QMessageBox.information(
|
||||
self.app.view,
|
||||
"Tie detected",
|
||||
"Round has unresolved ties. Resolution system not implemented yet.",
|
||||
)
|
||||
return
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
|
||||
|
||||
# Choice methods
|
||||
|
||||
def edit_round_choice(self, choice_id: str) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue