Enable Team Tournaments, add Tournament Trees, implement temporary tree persistance #66
@ -36,7 +36,7 @@ class MatchInfo(Component):
|
||||
font_size=0.9
|
||||
),
|
||||
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),
|
||||
justify="left",
|
||||
font_size=0.9
|
||||
@ -52,7 +52,7 @@ class MatchInfo(Component):
|
||||
font_size=0.9
|
||||
),
|
||||
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),
|
||||
justify="right",
|
||||
font_size=0.9
|
||||
@ -177,14 +177,14 @@ class TournamentTreePage(Component):
|
||||
round_num = 0
|
||||
for round_ in json_data["rounds"]:
|
||||
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_
|
||||
):
|
||||
last_valid_round = round_
|
||||
round_num += 1
|
||||
|
||||
if last_valid_round is None:
|
||||
raise ValueError
|
||||
last_valid_round = json_data["rounds"][0]
|
||||
|
||||
match_infos = []
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
@ -200,16 +200,15 @@ class TournamentTreePage(Component):
|
||||
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)
|
||||
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(
|
||||
MatchInfo(
|
||||
opponent_1=team_1.name,
|
||||
opponent_2=team_2.name,
|
||||
winner=winner if isinstance(winner, str) else winner.name,
|
||||
opponent_1_seat=self._get_seat_for_team(team_1),
|
||||
opponent_2_seat=self._get_seat_for_team(team_2),
|
||||
)
|
||||
match_infos.append(
|
||||
MatchInfo(
|
||||
opponent_1=team_1.name if team_1 is not None else "",
|
||||
opponent_2=team_2.name if team_2 is not None else "",
|
||||
winner=winner if isinstance(winner, str) else winner.name,
|
||||
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) if team_2 is not None else "",
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise ValueError("Unknown participant type")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user