Compare commits
No commits in common. "789756d586fb0c48d381e357e1861cb61b1d67fb" and "71e987304b1bf47199b929a19e4582c75e4343a2" have entirely different histories.
789756d586
...
71e987304b
7 changed files with 10 additions and 65 deletions
|
|
@ -111,7 +111,6 @@ class CampaignController:
|
||||||
theme=camp_part.theme or "",
|
theme=camp_part.theme or "",
|
||||||
victory_points=score.victory_points,
|
victory_points=score.victory_points,
|
||||||
narrative_points=dict(score.narrative_points),
|
narrative_points=dict(score.narrative_points),
|
||||||
tokens=war.get_influence_tokens(war_part.id),
|
|
||||||
rank_icon=icon_map.get(war_part_id),
|
rank_icon=icon_map.get(war_part_id),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -207,7 +206,6 @@ class CampaignController:
|
||||||
context_id=ctx.context_id,
|
context_id=ctx.context_id,
|
||||||
)
|
)
|
||||||
if not dialog.exec():
|
if not dialog.exec():
|
||||||
TieResolver.cancel_tie_break(war, ContextType.CAMPAIGN, ctx.context_id)
|
|
||||||
raise ForbiddenOperation("Tie resolution cancelled")
|
raise ForbiddenOperation("Tie resolution cancelled")
|
||||||
bids_map[ctx.context_id] = dialog.get_bids()
|
bids_map[ctx.context_id] = dialog.get_bids()
|
||||||
return bids_map
|
return bids_map
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,6 @@ class CampaignParticipantScoreDTO:
|
||||||
theme: str
|
theme: str
|
||||||
victory_points: int
|
victory_points: int
|
||||||
narrative_points: Dict[str, int]
|
narrative_points: Dict[str, int]
|
||||||
tokens: int
|
|
||||||
rank_icon: QIcon | None = None
|
rank_icon: QIcon | None = None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -136,5 +135,4 @@ class WarParticipantScoreDTO:
|
||||||
faction: str
|
faction: str
|
||||||
victory_points: int
|
victory_points: int
|
||||||
narrative_points: Dict[str, int]
|
narrative_points: Dict[str, int]
|
||||||
tokens: int
|
|
||||||
rank_icon: QIcon | None = None
|
rank_icon: QIcon | None = None
|
||||||
|
|
|
||||||
|
|
@ -96,12 +96,11 @@ class WarController:
|
||||||
faction=war_part.faction or "",
|
faction=war_part.faction or "",
|
||||||
victory_points=score.victory_points,
|
victory_points=score.victory_points,
|
||||||
narrative_points=dict(score.narrative_points),
|
narrative_points=dict(score.narrative_points),
|
||||||
tokens=war.get_influence_tokens(war_part.id),
|
|
||||||
rank_icon=icon_map.get(war_part.id),
|
rank_icon=icon_map.get(war_part.id),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.app.view.display_war_participants(rows, objectives_for_display)
|
self.app.view.display_war_participants(rows, objectives_for_display)
|
||||||
self.app.view.endWarBtn.setEnabled(not war.is_over)
|
self.app.view.endCampaignBtn.setEnabled(not war.is_over)
|
||||||
|
|
||||||
def _validate_war_inputs(self, name: str, year: int) -> bool:
|
def _validate_war_inputs(self, name: str, year: int) -> bool:
|
||||||
if not name.strip():
|
if not name.strip():
|
||||||
|
|
@ -161,7 +160,6 @@ class WarController:
|
||||||
RefreshScope.WARS_TREE, item_type=ItemType.WAR, item_id=war_id
|
RefreshScope.WARS_TREE, item_type=ItemType.WAR, item_id=war_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO fix ignored campaign tie-breaks
|
|
||||||
def resolve_ties(
|
def resolve_ties(
|
||||||
self, war: War, contexts: List[TieContext]
|
self, war: War, contexts: List[TieContext]
|
||||||
) -> Dict[str, Dict[str, bool]]:
|
) -> Dict[str, Dict[str, bool]]:
|
||||||
|
|
@ -183,7 +181,6 @@ class WarController:
|
||||||
context_id=ctx.context_id,
|
context_id=ctx.context_id,
|
||||||
)
|
)
|
||||||
if not dialog.exec():
|
if not dialog.exec():
|
||||||
TieResolver.cancel_tie_break(war, ContextType.WAR, ctx.context_id)
|
|
||||||
raise ForbiddenOperation("Tie resolution cancelled")
|
raise ForbiddenOperation("Tie resolution cancelled")
|
||||||
bids_map[ctx.context_id] = dialog.get_bids()
|
bids_map[ctx.context_id] = dialog.get_bids()
|
||||||
return bids_map
|
return bids_map
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class Campaign:
|
||||||
def remove_campaign_participant(self, participant_id: str) -> None:
|
def remove_campaign_participant(self, participant_id: str) -> None:
|
||||||
if self.is_over:
|
if self.is_over:
|
||||||
raise ForbiddenOperation("Can't remove participant in a closed campaign.")
|
raise ForbiddenOperation("Can't remove participant in a closed campaign.")
|
||||||
rounds_blocking: List[Round] = []
|
rounds_blocking: list[Round] = []
|
||||||
for rnd in self.rounds:
|
for rnd in self.rounds:
|
||||||
if rnd.has_choice_with_participant(
|
if rnd.has_choice_with_participant(
|
||||||
participant_id
|
participant_id
|
||||||
|
|
@ -158,10 +158,6 @@ class Campaign:
|
||||||
) -> Sector:
|
) -> Sector:
|
||||||
if self.is_over:
|
if self.is_over:
|
||||||
raise ForbiddenOperation("Can't add sector in a closed campaign.")
|
raise ForbiddenOperation("Can't add sector in a closed campaign.")
|
||||||
if round_id is not None:
|
|
||||||
round = self.get_round(round_id)
|
|
||||||
if round.is_over:
|
|
||||||
raise ForbiddenOperation("Can't add sector with a closed round.")
|
|
||||||
sect = Sector(
|
sect = Sector(
|
||||||
name, round_id, major_id, minor_id, influence_id, mission, description
|
name, round_id, major_id, minor_id, influence_id, mission, description
|
||||||
)
|
)
|
||||||
|
|
@ -191,18 +187,11 @@ class Campaign:
|
||||||
mission: str | None,
|
mission: str | None,
|
||||||
description: str | None,
|
description: str | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# TODO raise error if sector used in a closed round (potential tokens)
|
||||||
if self.is_over:
|
if self.is_over:
|
||||||
raise ForbiddenOperation("Can't update sector in a closed campaign.")
|
raise ForbiddenOperation("Can't update sector in a closed campaign.")
|
||||||
sect = self.get_sector(sector_id)
|
sect = self.get_sector(sector_id)
|
||||||
old_round_id = sect.round_id
|
old_round_id = sect.round_id
|
||||||
if old_round_id is not None:
|
|
||||||
old_round = self.get_round(old_round_id)
|
|
||||||
if old_round.is_over:
|
|
||||||
raise ForbiddenOperation("Can't update sector used in a closed round.")
|
|
||||||
if round_id is not None:
|
|
||||||
new_round = self.get_round(round_id)
|
|
||||||
if new_round.is_over:
|
|
||||||
raise ForbiddenOperation("Can't update sector with a closed round.")
|
|
||||||
|
|
||||||
def apply_update() -> None:
|
def apply_update() -> None:
|
||||||
sect.set_name(name)
|
sect.set_name(name)
|
||||||
|
|
@ -216,7 +205,7 @@ class Campaign:
|
||||||
if old_round_id == round_id:
|
if old_round_id == round_id:
|
||||||
apply_update()
|
apply_update()
|
||||||
return
|
return
|
||||||
affected_rounds: List[Round] = []
|
affected_rounds: list[Round] = []
|
||||||
for rnd in self.rounds:
|
for rnd in self.rounds:
|
||||||
if rnd.id == old_round_id and (
|
if rnd.id == old_round_id and (
|
||||||
rnd.has_choice_with_sector(sector_id)
|
rnd.has_choice_with_sector(sector_id)
|
||||||
|
|
@ -246,14 +235,7 @@ class Campaign:
|
||||||
def remove_sector(self, sector_id: str) -> None:
|
def remove_sector(self, sector_id: str) -> None:
|
||||||
if self.is_over:
|
if self.is_over:
|
||||||
raise ForbiddenOperation("Can't remove sector in a closed campaign.")
|
raise ForbiddenOperation("Can't remove sector in a closed campaign.")
|
||||||
sect = self.get_sector(sector_id)
|
rounds_blocking: list[Round] = []
|
||||||
round_id = sect.round_id
|
|
||||||
if round_id is not None:
|
|
||||||
round = self.get_round(round_id)
|
|
||||||
if round.is_over:
|
|
||||||
raise ForbiddenOperation("Can't remove sector used in a closed round.")
|
|
||||||
|
|
||||||
rounds_blocking: List[Round] = []
|
|
||||||
for rnd in self.rounds:
|
for rnd in self.rounds:
|
||||||
if rnd.has_battle_with_sector(sector_id) or rnd.has_choice_with_sector(
|
if rnd.has_battle_with_sector(sector_id) or rnd.has_choice_with_sector(
|
||||||
sector_id
|
sector_id
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class ResultChecker:
|
||||||
and ev.context_id == context_id
|
and ev.context_id == context_id
|
||||||
):
|
):
|
||||||
return ev.participant_id # None if confirmed draw
|
return ev.participant_id # None if confirmed draw
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -130,29 +130,6 @@ class TieResolver:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def cancel_tie_break(
|
|
||||||
war: War,
|
|
||||||
context_type: ContextType,
|
|
||||||
context_id: str,
|
|
||||||
) -> None:
|
|
||||||
war.events = [
|
|
||||||
ev
|
|
||||||
for ev in war.events
|
|
||||||
if not (
|
|
||||||
(
|
|
||||||
isinstance(ev, InfluenceSpent)
|
|
||||||
and ev.context_type == context_type
|
|
||||||
and ev.context_id == context_id
|
|
||||||
)
|
|
||||||
or (
|
|
||||||
isinstance(ev, TieResolved)
|
|
||||||
and ev.context_type == context_type
|
|
||||||
and ev.context_id == context_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def rank_by_tokens(
|
def rank_by_tokens(
|
||||||
war: War,
|
war: War,
|
||||||
|
|
|
||||||
|
|
@ -369,10 +369,8 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
) -> None:
|
) -> None:
|
||||||
table = self.warParticipantsTable
|
table = self.warParticipantsTable
|
||||||
table.clearContents()
|
table.clearContents()
|
||||||
base_cols = ["Player", "Faction", "Victory pts"]
|
base_cols = ["Player", "Faction", "Victory"]
|
||||||
headers = (
|
headers = base_cols + [obj.name for obj in objectives]
|
||||||
base_cols + [str(obj.name + " pts") for obj in objectives] + ["Tokens"]
|
|
||||||
)
|
|
||||||
table.setColumnCount(len(headers))
|
table.setColumnCount(len(headers))
|
||||||
table.setHorizontalHeaderLabels(headers)
|
table.setHorizontalHeaderLabels(headers)
|
||||||
table.setRowCount(len(participants))
|
table.setRowCount(len(participants))
|
||||||
|
|
@ -384,7 +382,6 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
faction_item = QtWidgets.QTableWidgetItem(part.faction)
|
faction_item = QtWidgets.QTableWidgetItem(part.faction)
|
||||||
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
|
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
|
||||||
name_item.setData(Qt.ItemDataRole.UserRole, part.war_participant_id)
|
name_item.setData(Qt.ItemDataRole.UserRole, part.war_participant_id)
|
||||||
token_item = QtWidgets.QTableWidgetItem(str(part.tokens))
|
|
||||||
table.setItem(row, 0, name_item)
|
table.setItem(row, 0, name_item)
|
||||||
table.setItem(row, 1, faction_item)
|
table.setItem(row, 1, faction_item)
|
||||||
table.setItem(row, 2, VP_item)
|
table.setItem(row, 2, VP_item)
|
||||||
|
|
@ -394,7 +391,6 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
NP_item = QtWidgets.QTableWidgetItem(str(value))
|
NP_item = QtWidgets.QTableWidgetItem(str(value))
|
||||||
table.setItem(row, col, NP_item)
|
table.setItem(row, col, NP_item)
|
||||||
col += 1
|
col += 1
|
||||||
table.setItem(row, col, token_item)
|
|
||||||
table.resizeColumnsToContents()
|
table.resizeColumnsToContents()
|
||||||
|
|
||||||
def _on_major_changed(self, value: int) -> None:
|
def _on_major_changed(self, value: int) -> None:
|
||||||
|
|
@ -493,10 +489,8 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
) -> None:
|
) -> None:
|
||||||
table = self.campaignParticipantsTable
|
table = self.campaignParticipantsTable
|
||||||
table.clearContents()
|
table.clearContents()
|
||||||
base_cols = ["Player", "Leader", "Theme", "Victory pts"]
|
base_cols = ["Player", "Leader", "Theme", "Victory"]
|
||||||
headers = (
|
headers = base_cols + [obj.name for obj in objectives]
|
||||||
base_cols + [str(obj.name + " pts") for obj in objectives] + ["Tokens"]
|
|
||||||
)
|
|
||||||
table.setColumnCount(len(headers))
|
table.setColumnCount(len(headers))
|
||||||
table.setHorizontalHeaderLabels(headers)
|
table.setHorizontalHeaderLabels(headers)
|
||||||
table.setRowCount(len(participants))
|
table.setRowCount(len(participants))
|
||||||
|
|
@ -508,7 +502,6 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
lead_item = QtWidgets.QTableWidgetItem(part.leader)
|
lead_item = QtWidgets.QTableWidgetItem(part.leader)
|
||||||
theme_item = QtWidgets.QTableWidgetItem(part.theme)
|
theme_item = QtWidgets.QTableWidgetItem(part.theme)
|
||||||
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
|
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
|
||||||
token_item = QtWidgets.QTableWidgetItem(str(part.tokens))
|
|
||||||
name_item.setData(Qt.ItemDataRole.UserRole, part.campaign_participant_id)
|
name_item.setData(Qt.ItemDataRole.UserRole, part.campaign_participant_id)
|
||||||
table.setItem(row, 0, name_item)
|
table.setItem(row, 0, name_item)
|
||||||
table.setItem(row, 1, lead_item)
|
table.setItem(row, 1, lead_item)
|
||||||
|
|
@ -520,7 +513,6 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||||
NP_item = QtWidgets.QTableWidgetItem(str(value))
|
NP_item = QtWidgets.QTableWidgetItem(str(value))
|
||||||
table.setItem(row, col, NP_item)
|
table.setItem(row, col, NP_item)
|
||||||
col += 1
|
col += 1
|
||||||
table.setItem(row, col, token_item)
|
|
||||||
table.resizeColumnsToContents()
|
table.resizeColumnsToContents()
|
||||||
|
|
||||||
# Round page
|
# Round page
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue