Bunco Simulator

Diff

Differences From Artifact [b5e7e7]:

To Artifact [894897]:


1
2
3
4
5
6



7
8
9
10
11
12
13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16






+
+
+







import bunco
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():
    print(t.clear,t.move(0,0))
    print_center(t.bold_red,"B U N C O   S I M U L A T O R", t.normal)
33
34
35
36
37
38
39






























36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
g.play_one_round()
display_dashboard()

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)