1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
import bunco
import xlsxwriter
import creds # local
from blessings import Terminal
from twilio.rest import Client
t = Terminal()
g = bunco.Game("players.csv")
enable_sms = False
last_status = 'Off to a great start!'
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 status(text):
global last_status
row = 6 + (len(g.tables) * 5)
print(t.move(row, 0), end='')
print(t.clear_eol, end='')
print_center(f"{t.bold_green}",f"[ {text} ]", t.normal)
print(t.clear_eos)
last_status = text
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)
print(f"{t.red}{'-'*t.width}{t.normal}\n")
# Print column headings for rounds
rounds = [str(n + 1).rjust(4) for n in range(g.current_round())]
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
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
73
74
75
76
77
78
|
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+
-
+
+
+
+
+
|
if player is bunco.fuzzydie_holder:
print(f"🎲",end='')
print(f"{t.move_x(3)}{t.cyan}{player}{t.normal}",end='')
for n in range(g.current_round()):
print(t.move_x(18+(4*n)),end='')
print(str(player.round_scores[n]).rjust(4),end='')
print('')
status(last_status)
def do1():
g.play_one_round()
display_dashboard()
g.play_one_round()
if enable_sms:
status("Sending results by SMS to players…")
for player in g.players:
sms(player.smsnumber, summary_text(player))
display_dashboard()
status("Prepping for next round…")
def do1():
g.prep_next_round()
g.play_one_round()
status("Ready for another round!")
display_dashboard()
def summary(n):
return summary_text(g.players[n])
def sms(number, message):
if enable_sms and number:
cli = Client(creds.SID, creds.token)
cli.messages.create(to=number, from_=creds.sender, body=message)
def summary_text(player):
for table in g.tables:
if player in table.players:
curtable = table
break
sitch = curtable.get_player_situation(player)
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
+
+
+
+
+
+
+
|
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)
def sms_table_move(player, wonlost, table_from, table_to):
if player.smsnumber:
message = f"Having {wonlost} the last round, you move from {table_from} to {table_to}."
sms(player.smsnumber, message)
bunco.table_move_callback = sms_table_move
def excel_sheet(title):
wb = xlsxwriter.Workbook('bunco.xlsx')
ws = wb.add_worksheet('Overview')
style = {}
col_heading = wb.add_format({'font_name': 'Back Issues BB',
|