Index: bunco.py ================================================================== --- bunco.py +++ bunco.py @@ -212,10 +212,25 @@ self.team1_score = 0 self.team2_score = 0 self.active_player = -1 for player in self.players: player.prep_new_round() + + def get_player_situation(self, player): + player_index = self.players.index(player) + if player_index % 2 == 0: + opponents = self.players[1::2] + opponent_score = self.team2_score + else: + opponents = self.players[0::2] + opponent_score = self.team1_score + teammate = self.players[teammate_lookup[player_index]] + + return {'teammate': teammate, + 'opponents': opponents, + 'opponent_score': opponent_score} + def assign_teams(player_list): players_per_table = 4 tables = [] random.seed() Index: bunco_app.py ================================================================== --- bunco_app.py +++ bunco_app.py @@ -2,10 +2,13 @@ from blessings import Terminal t = Terminal() g = bunco.Game("players.csv") +def plural(str,n,suffix="s"): + return str + suffix if n > 1 else str + def print_center(before, string, after): col = int((t.width - len(string)) / 2) - 1 print(f"{t.move_x(col)}{before}{string}{after}") def display_dashboard(): @@ -35,5 +38,35 @@ def do1(): g.prep_next_round() g.play_one_round() display_dashboard() + +def summary(n): + return summary_text(g.players[n]) + +def summary_text(player): + for table in g.tables: + if player in table.players: + curtable = table + break + + sitch = curtable.get_player_situation(player) + + if player.round_scores[g.current_round()-1] > sitch['opponent_score']: + winloss = "beating" + else: + winloss = "losing to" + foe_names = " & ".join([str(opp) for opp in sitch['opponents']]) + + bunco_ct = player.round_bunco_counts[g.current_round()-1] + if bunco_ct > 0: + buncos = f" (& {bunco_ct} {plural('bunco',bunco_ct)}!)" + else: + buncos = "" + + ts = [f"Round {g.current_round()} @ {curtable} with {sitch['teammate']}:", + f"You made {player.round_roll_counts[g.current_round()-1]} rolls,", + f"adding {player.personal_roll_scores[g.current_round()-1]} pts{buncos}", + f"to your team score of {player.round_scores[g.current_round()-1]},", + f"{winloss} {foe_names}’s score of {sitch['opponent_score']}."] + return " ".join(ts)