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
|
|
@ -13,6 +13,7 @@ from warchron.controller.dtos import (
|
|||
SectorDTO,
|
||||
RoundDTO,
|
||||
)
|
||||
from warchron.model.closure_service import ClosureService
|
||||
from warchron.view.campaign_dialog import CampaignDialog
|
||||
from warchron.view.campaign_participant_dialog import CampaignParticipantDialog
|
||||
from warchron.view.sector_dialog import SectorDialog
|
||||
|
|
@ -50,6 +51,7 @@ class CampaignController:
|
|||
for p in camp_parts
|
||||
]
|
||||
self.app.view.display_campaign_participants(participants_for_display)
|
||||
self.app.view.endCampaignBtn.setEnabled(not camp.is_over)
|
||||
|
||||
def _validate_campaign_inputs(self, name: str, month: int) -> bool:
|
||||
if not name.strip():
|
||||
|
|
@ -99,6 +101,28 @@ class CampaignController:
|
|||
return
|
||||
self.app.model.update_campaign(campaign_id, name=name, month=month)
|
||||
|
||||
def close_campaign(self) -> None:
|
||||
campaign_id = self.app.navigation.selected_campaign_id
|
||||
if not campaign_id:
|
||||
return
|
||||
camp = self.app.model.get_campaign(campaign_id)
|
||||
if camp.is_over:
|
||||
return
|
||||
try:
|
||||
ties = ClosureService.close_campaign(camp)
|
||||
except RuntimeError as e:
|
||||
QMessageBox.warning(self.app.view, "Cannot close campaign", str(e))
|
||||
return
|
||||
if ties:
|
||||
QMessageBox.information(
|
||||
self.app.view,
|
||||
"Tie detected",
|
||||
"Campaign has unresolved ties.",
|
||||
)
|
||||
return
|
||||
self.app.is_dirty = True
|
||||
self.app.navigation.refresh(RefreshScope.CURRENT_SELECTION_DETAILS)
|
||||
|
||||
# Campaign participant methods
|
||||
|
||||
def add_campaign_participant(self) -> None:
|
||||
|
|
@ -148,7 +172,12 @@ class CampaignController:
|
|||
# Sector methods
|
||||
|
||||
def _validate_sector_inputs(
|
||||
self, name: str, round_id: str, major_id: str, minor_id: str, influence_id: str
|
||||
self,
|
||||
name: str,
|
||||
round_id: str | None,
|
||||
major_id: str | None,
|
||||
minor_id: str | None,
|
||||
influence_id: str | None,
|
||||
) -> bool:
|
||||
|
||||
if not name.strip():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue