compute campaign points from rounds
This commit is contained in:
parent
45c1d69a3f
commit
7c9c941864
9 changed files with 165 additions and 75 deletions
|
|
@ -15,10 +15,10 @@ from warchron.controller.dtos import (
|
|||
WarDTO,
|
||||
WarParticipantDTO,
|
||||
ObjectiveDTO,
|
||||
CampaignParticipantDTO,
|
||||
SectorDTO,
|
||||
ChoiceDTO,
|
||||
BattleDTO,
|
||||
CampaignParticipantScoreDTO,
|
||||
)
|
||||
from warchron.view.helpers import (
|
||||
format_campaign_label,
|
||||
|
|
@ -464,19 +464,33 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
table.resizeColumnsToContents()
|
||||
|
||||
def display_campaign_participants(
|
||||
self, participants: List[CampaignParticipantDTO]
|
||||
self,
|
||||
participants: List[CampaignParticipantScoreDTO],
|
||||
objectives: List[ObjectiveDTO],
|
||||
) -> None:
|
||||
table = self.campaignParticipantsTable
|
||||
table.clearContents()
|
||||
base_cols = ["Player", "Leader", "Theme", "Victory"]
|
||||
headers = base_cols + [obj.name for obj in objectives]
|
||||
table.setColumnCount(len(headers))
|
||||
table.setHorizontalHeaderLabels(headers)
|
||||
table.setRowCount(len(participants))
|
||||
for row, part in enumerate(participants):
|
||||
name_item = QtWidgets.QTableWidgetItem(part.player_name)
|
||||
lead_item = QtWidgets.QTableWidgetItem(part.leader)
|
||||
theme_item = QtWidgets.QTableWidgetItem(part.theme)
|
||||
name_item.setData(Qt.ItemDataRole.UserRole, part.id)
|
||||
VP_item = QtWidgets.QTableWidgetItem(str(part.victory_points))
|
||||
name_item.setData(Qt.ItemDataRole.UserRole, part.campaign_participant_id)
|
||||
table.setItem(row, 0, name_item)
|
||||
table.setItem(row, 1, lead_item)
|
||||
table.setItem(row, 2, theme_item)
|
||||
table.setItem(row, 3, VP_item)
|
||||
col = 4
|
||||
for obj in objectives:
|
||||
value = part.narrative_points.get(obj.id, 0)
|
||||
NP_item = QtWidgets.QTableWidgetItem(str(value))
|
||||
table.setItem(row, col, NP_item)
|
||||
col += 1
|
||||
table.resizeColumnsToContents()
|
||||
|
||||
# Round page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue