@@ -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)