display tokens in participant tables

This commit is contained in:
Maxime Réaux 2026-02-24 09:06:13 +01:00
parent 71e987304b
commit 81626171c8
4 changed files with 18 additions and 4 deletions

View file

@ -111,6 +111,7 @@ class CampaignController:
theme=camp_part.theme or "",
victory_points=score.victory_points,
narrative_points=dict(score.narrative_points),
tokens=war.get_influence_tokens(war_part.id),
rank_icon=icon_map.get(war_part_id),
)
)
@ -185,6 +186,7 @@ class CampaignController:
RefreshScope.WARS_TREE, item_type=ItemType.CAMPAIGN, item_id=campaign_id
)
# TODO fix spent tokens on tie cancel
def resolve_ties(
self, war: War, contexts: List[TieContext]
) -> Dict[str, Dict[str, bool]]:

View file

@ -124,6 +124,7 @@ class CampaignParticipantScoreDTO:
theme: str
victory_points: int
narrative_points: Dict[str, int]
tokens: int
rank_icon: QIcon | None = None
@ -135,4 +136,5 @@ class WarParticipantScoreDTO:
faction: str
victory_points: int
narrative_points: Dict[str, int]
tokens: int
rank_icon: QIcon | None = None

View file

@ -96,6 +96,7 @@ class WarController:
faction=war_part.faction or "",
victory_points=score.victory_points,
narrative_points=dict(score.narrative_points),
tokens=war.get_influence_tokens(war_part.id),
rank_icon=icon_map.get(war_part.id),
)
)
@ -160,6 +161,7 @@ class WarController:
RefreshScope.WARS_TREE, item_type=ItemType.WAR, item_id=war_id
)
# TODO fix spent tokens on tie cancel
def resolve_ties(
self, war: War, contexts: List[TieContext]
) -> Dict[str, Dict[str, bool]]:

View file

@ -369,8 +369,10 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
) -> None:
table = self.warParticipantsTable
table.clearContents()
base_cols = ["Player", "Faction", "Victory"]
headers = base_cols + [obj.name for obj in objectives]
base_cols = ["Player", "Faction", "Victory pts"]
headers = (
base_cols + [str(obj.name + " pts") for obj in objectives] + ["Tokens"]
)
table.setColumnCount(len(headers))
table.setHorizontalHeaderLabels(headers)
table.setRowCount(len(participants))
@ -382,6 +384,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
faction_item = QtWidgets.QTableWidgetItem(part.faction)
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
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, 1, faction_item)
table.setItem(row, 2, VP_item)
@ -391,6 +394,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
NP_item = QtWidgets.QTableWidgetItem(str(value))
table.setItem(row, col, NP_item)
col += 1
table.setItem(row, col, token_item)
table.resizeColumnsToContents()
def _on_major_changed(self, value: int) -> None:
@ -489,8 +493,10 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
) -> None:
table = self.campaignParticipantsTable
table.clearContents()
base_cols = ["Player", "Leader", "Theme", "Victory"]
headers = base_cols + [obj.name for obj in objectives]
base_cols = ["Player", "Leader", "Theme", "Victory pts"]
headers = (
base_cols + [str(obj.name + " pts") for obj in objectives] + ["Tokens"]
)
table.setColumnCount(len(headers))
table.setHorizontalHeaderLabels(headers)
table.setRowCount(len(participants))
@ -502,6 +508,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
lead_item = QtWidgets.QTableWidgetItem(part.leader)
theme_item = QtWidgets.QTableWidgetItem(part.theme)
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)
table.setItem(row, 0, name_item)
table.setItem(row, 1, lead_item)
@ -513,6 +520,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
NP_item = QtWidgets.QTableWidgetItem(str(value))
table.setItem(row, col, NP_item)
col += 1
table.setItem(row, col, token_item)
table.resizeColumnsToContents()
# Round page