wip close round/campaign/war + refacto json None

This commit is contained in:
Maxime Réaux 2026-02-11 19:22:43 +01:00
parent 4c8086caf4
commit 6cbb7c6534
26 changed files with 474 additions and 108 deletions

View file

@ -11,6 +11,7 @@ from warchron.controller.dtos import (
WarParticipantDTO,
ObjectiveDTO,
)
from warchron.model.closure_service import ClosureService
from warchron.view.war_dialog import WarDialog
from warchron.view.objective_dialog import ObjectiveDialog
from warchron.view.war_participant_dialog import WarParticipantDialog
@ -44,6 +45,7 @@ class WarController:
for p in war_parts
]
self.app.view.display_war_participants(participants_for_display)
self.app.view.endWarBtn.setEnabled(not war.is_over)
def _validate_war_inputs(self, name: str, year: int) -> bool:
if not name.strip():
@ -86,6 +88,28 @@ class WarController:
return
self.app.model.update_war(war_id, name=name, year=year)
def close_war(self) -> None:
war_id = self.app.navigation.selected_war_id
if not war_id:
return
war = self.app.model.get_war(war_id)
if war.is_over:
return
try:
ties = ClosureService.close_war(war)
except RuntimeError as e:
QMessageBox.warning(self.app.view, "Cannot close war", str(e))
return
if ties:
QMessageBox.information(
self.app.view,
"Tie detected",
"War has unresolved ties.",
)
return
self.app.is_dirty = True
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
def set_major_value(self, value: int) -> None:
war_id = self.app.navigation.selected_war_id
if not war_id:
@ -109,7 +133,7 @@ class WarController:
# Objective methods
def _validate_objective_inputs(self, name: str, description: str) -> bool:
def _validate_objective_inputs(self, name: str, description: str | None) -> bool:
if not name.strip():
QMessageBox.warning(
self.app.view, "Invalid name", "Objective name cannot be empty."