Bunco Simulator

Diff

Differences From Artifact [b9a3c7]:

To Artifact [109c1e]:


71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

















































96
97
98
99
100
101
102
          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 excel_sheet(title):
    wb = xlsxwriter.Workbook('bunco.xlsx')
    ws = wb.add_worksheet('Overview')


    col_heading = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 12,
                                 'align': 'center'})
    title_style = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 14,
                                 'bold': True})
    row_heading = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 12})
    score_style = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'font_size': 14,
                                 'align': 'right',
                                 'num_format': '_(* #,##0_);_(* (#,##0);_(* "-"??_);_(@_)',
                                 'color': '#0070C0'})
    total_style = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'font_size': 14,
                                 'align': 'center',
                                 'bold': 'true'})

















































    
    ws.set_column('A:A', 30)
    
    ws.write('A1', title, title_style)
    ws.set_landscape()
    ws.fit_to_pages(1, 1)








>


















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
          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 excel_sheet(title):
    wb = xlsxwriter.Workbook('bunco.xlsx')
    ws = wb.add_worksheet('Overview')
    style = {}

    col_heading = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 12,
                                 'align': 'center'})
    title_style = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 14,
                                 'bold': True})
    row_heading = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 12})
    score_style = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'font_size': 14,
                                 'align': 'right',
                                 'num_format': '_(* #,##0_);_(* (#,##0);_(* "-"??_);_(@_)',
                                 'color': '#0070C0'})
    total_style = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'font_size': 14,
                                 'align': 'center',
                                 'bold': 'true'})

    style['player_title'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 28,
                                 'bold': True,
                                 'color': '#0096FF'})
    style['player_subtitle'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 16})
    style['score_col_head'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 12,
                                 'bold': 'true',
                                 'align': 'center'})
    style['score_row_head'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 16,
                                 'bold': 'true',
                                 'align': 'center'})
    style['score_num'] = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'font_size': 18,
                                 'align': 'right',
                                 'num_format': '_(* #,##0_);_(* (#,##0);_(* "-"??_);_(@_)',
                                 'color': '#833C0C'})
    style['score_total'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'align': 'right',
                                 'top': 1,
                                 'num_format': '_(* #,##0_);_(* (#,##0);_(* "-"??_);_(@_)'})
    style['wins'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'color': '#548235',
                                 'align': 'center'})
    style['losses'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'color': '#FF0000',
                                 'align': 'center'})
    style['wins_t'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'color': '#548235',
                                 'top': 1,
                                 'align': 'center'})
    style['losses_t'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'color': '#FF0000',
                                 'top': 1,
                                 'align': 'center'})
    style['stat_name'] = wb.add_format({'font_name': 'Milk Mustache BB', 
                                 'bold': 'true',
                                 'font_size': 16})
    style['stat_val'] = wb.add_format({'font_name': 'Back Issues BB', 
                                 'font_size': 18,
                                 'align': 'right'})
    
    ws.set_column('A:A', 30)
    
    ws.write('A1', title, title_style)
    ws.set_landscape()
    ws.fit_to_pages(1, 1)

128
129
130
131
132
133
134





135


























































        ws.write(row, end_col + 1, sum(player.round_scores), total_style)
        ws.write(row, end_col + 2, sum(player.round_wins), total_style)
        ws.write(row, end_col + 3, sum(losses), total_style)
        ws.write(row, end_col + 4, sum(player.round_bunco_counts), total_style)
        ws.write(row, end_col + 5, sum(player.round_roll_counts), total_style)






    wb.close()
































































>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

        ws.write(row, end_col + 1, sum(player.round_scores), total_style)
        ws.write(row, end_col + 2, sum(player.round_wins), total_style)
        ws.write(row, end_col + 3, sum(losses), total_style)
        ws.write(row, end_col + 4, sum(player.round_bunco_counts), total_style)
        ws.write(row, end_col + 5, sum(player.round_roll_counts), total_style)

        excel_score_sheet(wb, style, player, title)

    end_row = 3 + len(g.players)
    ws.write(end_row + 1, 0, "Prizes", title_style)
    
    wb.close()

def excel_score_sheet(workbook, styles, player, title):
    ws = workbook.add_worksheet(player.name)

    ws.set_column('A:A', 14)
    ws.set_column('B:C', 13)
    ws.set_column('D:D', 19)
    ws.set_column('E:F', 12)
    ws.set_portrait()
    ws.fit_to_pages(1, 1)

    ws.write('A1', player.name, styles['player_title'])
    ws.write('A2', f"{title} Score Sheet", styles['player_subtitle'])
    
    cols = ['Round', 'Rolls', 'Buncos?', 'Team Score', 'Win', 'Loss']
    for n, col in enumerate(cols):
        ws.write(3, n, col, styles['score_col_head'])

    for n in range(g.current_round()):
        row = 4 + n
        ws.write(row, 0, n + 1, styles['score_col_head'])
        ws.write(row, 1, player.round_roll_counts[n], styles['score_num'])
        ws.write(row, 3, player.round_scores[n], styles['score_num'])

        if player.round_bunco_counts[n] > 0:
            ws.write(row, 2, player.round_bunco_counts[n], styles['score_num'])
        if player.round_wins[n] > 0:
            ws.write(row, 4, "✓", styles['wins'])
        else:
            ws.write(row, 5, "✓", styles['losses'])

    end_row = 3 + g.current_round()

    # derive losses from wins
    losses = [int(not x) for x in player.round_wins]
    ws.write(end_row + 1, 0, '', styles['score_total'])
    ws.write(end_row + 1, 1, sum(player.round_roll_counts), styles['score_total'])
    ws.write(end_row + 1, 2, sum(player.round_bunco_counts), styles['score_total'])
    ws.write(end_row + 1, 3, sum(player.round_scores), styles['score_total'])
    ws.write(end_row + 1, 4, sum(player.round_wins), styles['wins_t'])
    ws.write(end_row + 1, 5, sum(losses), styles['losses_t'])

    stats = ['Longest time with fuzzy die',
             'Highest roll streak',
             f"Difference from average score of {g.average_total_score():.2f}",
             f"Difference from median score of {g.median_total_score():.2f}",
             "Average % of team score"]

    for n, stat in enumerate(stats):
        ws.write(end_row + 3 + n, 0, stat, styles['stat_name'])
    
    ws.write(end_row + 3, 5, f"{player.max_fuzzydie_streak // 60}:{player.max_fuzzydie_streak % 60:02}",
        styles['stat_val'])
    ws.write(end_row + 4, 5, player.max_streak, styles['stat_val'])
    ws.write(end_row + 5, 5, f"{sum(player.round_scores) - g.average_total_score():.2f}", styles['stat_val'])
    ws.write(end_row + 6, 5, f"{sum(player.round_scores) - g.median_total_score():.2f}", styles['stat_val'])
    ws.write(end_row + 7, 5, f"{player.average_contrib_pct():.2%}", styles['stat_val'])