Enable Team Tournaments, add Tournament Trees, implement temporary tree persistance #66

Merged
Typhus merged 7 commits from feature/enable-starting-tournaments-and-displaying-tournament-tree into main 2026-04-18 14:42:28 +00:00
Showing only changes of commit db237b3535 - Show all commits

View File

@ -36,7 +36,7 @@ class MatchInfo(Component):
font_size=0.9 font_size=0.9
), ),
Text( Text(
text=f"({self.opponent_1_seat})", text=f"({self.opponent_1_seat})" if self.opponent_1_seat else "Freilos",
style=TextStyle(fill=self.session.theme.background_color), style=TextStyle(fill=self.session.theme.background_color),
justify="left", justify="left",
font_size=0.9 font_size=0.9
@ -52,7 +52,7 @@ class MatchInfo(Component):
font_size=0.9 font_size=0.9
), ),
Text( Text(
text=f"({self.opponent_2_seat})", text=f"({self.opponent_2_seat})" if self.opponent_2_seat else "Freilos",
style=TextStyle(fill=self.session.theme.background_color), style=TextStyle(fill=self.session.theme.background_color),
justify="right", justify="right",
font_size=0.9 font_size=0.9
@ -177,14 +177,14 @@ class TournamentTreePage(Component):
round_num = 0 round_num = 0
for round_ in json_data["rounds"]: for round_ in json_data["rounds"]:
if all( if all(
match["opponent_1_id"] is not None and match["opponent_2_id"] is not None match["opponent_1_id"] is not None or match["opponent_2_id"] is not None
for match in round_ for match in round_
): ):
last_valid_round = round_ last_valid_round = round_
round_num += 1 round_num += 1
if last_valid_round is None: if last_valid_round is None:
raise ValueError last_valid_round = json_data["rounds"][0]
match_infos = [] match_infos = []
if self.tournament.participant_type == ParticipantType.PLAYER: if self.tournament.participant_type == ParticipantType.PLAYER:
@ -200,14 +200,13 @@ class TournamentTreePage(Component):
team_1: Optional[Team] = next(filter(lambda t: t.id == match["opponent_1_id"], self.teams), None) team_1: Optional[Team] = next(filter(lambda t: t.id == match["opponent_1_id"], self.teams), None)
team_2: Optional[Team] = next(filter(lambda t: t.id == match["opponent_2_id"], self.teams), None) team_2: Optional[Team] = next(filter(lambda t: t.id == match["opponent_2_id"], self.teams), None)
winner: Union[str, Team] = next(filter(lambda t: t.id == match["winner"], self.teams), "") winner: Union[str, Team] = next(filter(lambda t: t.id == match["winner"], self.teams), "")
if team_1 is not None and team_2 is not None:
match_infos.append( match_infos.append(
MatchInfo( MatchInfo(
opponent_1=team_1.name, opponent_1=team_1.name if team_1 is not None else "",
opponent_2=team_2.name, opponent_2=team_2.name if team_2 is not None else "",
winner=winner if isinstance(winner, str) else winner.name, winner=winner if isinstance(winner, str) else winner.name,
opponent_1_seat=self._get_seat_for_team(team_1), opponent_1_seat=self._get_seat_for_team(team_1) if team_1 is not None else "",
opponent_2_seat=self._get_seat_for_team(team_2), opponent_2_seat=self._get_seat_for_team(team_2) if team_2 is not None else "",
) )
) )
else: else: