fix participants in round choices + battles
This commit is contained in:
parent
47b01e0b69
commit
7210ddc927
2 changed files with 32 additions and 19 deletions
|
|
@ -204,7 +204,7 @@ class Controller:
|
||||||
camp = self.model.get_campaign_by_round(round_id)
|
camp = self.model.get_campaign_by_round(round_id)
|
||||||
self.view.show_round_details(index=camp.get_round_index(round_id))
|
self.view.show_round_details(index=camp.get_round_index(round_id))
|
||||||
participants = self.model.get_round_participants(round_id)
|
participants = self.model.get_round_participants(round_id)
|
||||||
sectors = camp.get_all_sectors()
|
sectors = camp.get_sectors_in_round(round_id)
|
||||||
choices_for_display = []
|
choices_for_display = []
|
||||||
for part in participants:
|
for part in participants:
|
||||||
choice = rnd.get_choice(part.id)
|
choice = rnd.get_choice(part.id)
|
||||||
|
|
@ -232,16 +232,20 @@ class Controller:
|
||||||
battle = rnd.get_battle(sect.id)
|
battle = rnd.get_battle(sect.id)
|
||||||
if not battle:
|
if not battle:
|
||||||
battle = self.model.create_battle(round_id=rnd.id, sector_id=sect.id)
|
battle = self.model.create_battle(round_id=rnd.id, sector_id=sect.id)
|
||||||
player_1_name = (
|
if battle.player_1_id:
|
||||||
self.model.get_player_name(battle.player_1_id)
|
camp_part = camp.participants[battle.player_1_id]
|
||||||
if battle.player_1_id
|
player_1_name = self.model.get_participant_name(
|
||||||
else ""
|
camp_part.war_participant_id
|
||||||
)
|
)
|
||||||
player_2_name = (
|
else:
|
||||||
self.model.get_player_name(battle.player_2_id)
|
player_1_name = ""
|
||||||
if battle.player_2_id
|
if battle.player_2_id:
|
||||||
else ""
|
camp_part = camp.participants[battle.player_2_id]
|
||||||
)
|
player_2_name = self.model.get_participant_name(
|
||||||
|
camp_part.war_participant_id
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
player_2_name = ""
|
||||||
battles_for_display.append(
|
battles_for_display.append(
|
||||||
(
|
(
|
||||||
camp.get_sector_name(battle.sector_id),
|
camp.get_sector_name(battle.sector_id),
|
||||||
|
|
@ -689,13 +693,13 @@ class Controller:
|
||||||
choice = rnd.get_choice(choice_id)
|
choice = rnd.get_choice(choice_id)
|
||||||
if not choice:
|
if not choice:
|
||||||
return
|
return
|
||||||
part = camp.participants[choice.participant_id]
|
participant = camp.participants[choice.participant_id]
|
||||||
player = self.model.get_player(part.id)
|
player = self.model.get_player_from_campaign_participant(participant)
|
||||||
part_opt = ParticipantOption(id=player.id, name=player.name)
|
part_opt = ParticipantOption(id=participant.id, name=player.name)
|
||||||
dialog = ChoicesDialog(
|
dialog = ChoicesDialog(
|
||||||
self.view,
|
self.view,
|
||||||
participants=[part_opt],
|
participants=[part_opt],
|
||||||
default_participant_id=part.id,
|
default_participant_id=participant.id,
|
||||||
sectors=sectors,
|
sectors=sectors,
|
||||||
default_priority_id=choice.priority_sector_id,
|
default_priority_id=choice.priority_sector_id,
|
||||||
default_secondary_id=choice.secondary_sector_id,
|
default_secondary_id=choice.secondary_sector_id,
|
||||||
|
|
@ -705,7 +709,7 @@ class Controller:
|
||||||
return
|
return
|
||||||
self.model.update_choice(
|
self.model.update_choice(
|
||||||
round_id=round_id,
|
round_id=round_id,
|
||||||
participant_id=part.id,
|
participant_id=participant.id,
|
||||||
priority_sector_id=dialog.get_priority_id(),
|
priority_sector_id=dialog.get_priority_id(),
|
||||||
secondary_sector_id=dialog.get_secondary_id(),
|
secondary_sector_id=dialog.get_secondary_id(),
|
||||||
comment=dialog.get_comment(),
|
comment=dialog.get_comment(),
|
||||||
|
|
@ -725,9 +729,9 @@ class Controller:
|
||||||
return
|
return
|
||||||
sect = camp.sectors[battle.sector_id]
|
sect = camp.sectors[battle.sector_id]
|
||||||
part_opts: list[ParticipantOption] = []
|
part_opts: list[ParticipantOption] = []
|
||||||
for part in participants:
|
for participant in participants:
|
||||||
player = self.model.get_player(part.id)
|
player = self.model.get_player_from_campaign_participant(participant)
|
||||||
part_opts.append(ParticipantOption(id=part.id, name=player.name))
|
part_opts.append(ParticipantOption(id=participant.id, name=player.name))
|
||||||
dialog = BattlesDialog(
|
dialog = BattlesDialog(
|
||||||
self.view,
|
self.view,
|
||||||
sectors=[sect],
|
sectors=[sect],
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,9 @@ class Model:
|
||||||
return part
|
return part
|
||||||
raise KeyError("Participant not found")
|
raise KeyError("Participant not found")
|
||||||
|
|
||||||
|
def get_player_from_war_participant(self, war_part: WarParticipant) -> Player:
|
||||||
|
return self.get_player(war_part.player_id)
|
||||||
|
|
||||||
def update_war_participant(self, participant_id: str, *, faction: str):
|
def update_war_participant(self, participant_id: str, *, faction: str):
|
||||||
war = self.get_war_by_war_participant(participant_id)
|
war = self.get_war_by_war_participant(participant_id)
|
||||||
war.update_war_participant(participant_id, faction=faction)
|
war.update_war_participant(participant_id, faction=faction)
|
||||||
|
|
@ -314,6 +317,12 @@ class Model:
|
||||||
return part
|
return part
|
||||||
raise KeyError("Participant not found")
|
raise KeyError("Participant not found")
|
||||||
|
|
||||||
|
def get_player_from_campaign_participant(
|
||||||
|
self, camp_part: CampaignParticipant
|
||||||
|
) -> Player:
|
||||||
|
war_part = self.get_war_participant(camp_part.war_participant_id)
|
||||||
|
return self.get_player(war_part.player_id)
|
||||||
|
|
||||||
def update_campaign_participant(
|
def update_campaign_participant(
|
||||||
self,
|
self,
|
||||||
participant_id: str,
|
participant_id: str,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue