390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
log('all', f"{table}: Team 1 {table.team1_score} pts, Team 2 {table.team2_score} pts")
while table.team1_score == table.team2_score:
log('all', f"{table} having a roll-off to resolve a tie")
table.roll_off()
log('all', f"{table}: Team 1 {table.team1_score} pts, Team 2 {table.team2_score} pts")
table.notch_wins()
def prizes(self):
prizelist = {}
scores = [sum(p.round_scores) for p in self.players]
wins = [sum(p.round_wins) for p in self.players]
losses = [Game.current_round() - w for w in wins]
buncos = [sum(p.round_bunco_counts) for p in self.players]
contrib_pcts = [p.average_contrib_pct() for p in self.players]
rolls = [sum(p.round_roll_counts) for p in self.players]
streaks = [p.max_streak for p in self.players]
fuzzy_streaks = [p.max_fuzzydie_streak for p in self.players]
avg_diffs = [sum(p.round_scores) - self.average_total_score() for p in self.players]
median_diffs = [sum(p.round_scores) - self.median_total_score() for p in self.players]
smallest_avg_diff = avg_diffs[list(map(abs,avg_diffs)).index(min(list(map(abs,avg_diffs))))]
smallest_median_diff = median_diffs[list(map(abs,median_diffs)).index(min(list(map(abs,median_diffs))))]
# Build a list of prizes and winners, allowing for ties
prizelist["Highest Score"] = f"{', '.join([str(p) for p in self.players if sum(p.round_scores) == max(scores)])} ({max(scores)})"
prizelist["Lowest Score"] = f"{', '.join([str(p) for p in self.players if sum(p.round_scores) == min(scores)])} ({min(scores)})"
prizelist["Most Wins"] = f"{', '.join([str(p) for p in self.players if sum(p.round_wins) == max(wins)])} ({max(wins)})"
prizelist["Most Losses"] = f"{', '.join([str(p) for p in self.players if Game.current_round() - sum(p.round_wins) == max(losses)])} ({max(losses)})"
prizelist["Most Buncos"] = f"{', '.join([str(p) for p in self.players if sum(p.round_bunco_counts) == max(buncos)])} ({max(buncos)})"
prizelist["Highest Team Contributor"] = f"{', '.join([str(p) for p in self.players if p.average_contrib_pct() == max(contrib_pcts)])} ({max(contrib_pcts):.2%})"
prizelist["Most Rolls"] = f"{', '.join([str(p) for p in self.players if sum(p.round_roll_counts) == max(rolls)])} ({max(rolls)})"
prizelist["Longest Roll Streak"] = f"{', '.join([str(p) for p in self.players if p.max_streak == max(streaks)])} ({max(streaks)})"
prizelist["Fewest Rolls"] = f"{', '.join([str(p) for p in self.players if sum(p.round_roll_counts) == min(rolls)])} ({min(rolls)})"
prizelist["Last Fuzzy Die Holder"] = fuzzydie_holder.name
prizelist["Longest Time with Fuzzy Die"] = f"{', '.join([str(p) for p in self.players if p.max_fuzzydie_streak == max(fuzzy_streaks)])} ({max(fuzzy_streaks)})"
prizelist["Most Average Total Score"] = f"{', '.join([str(p) for p in self.players if abs(sum(p.round_scores) - self.average_total_score()) == abs(smallest_avg_diff)])} ({smallest_avg_diff})"
prizelist["Closest to Median Total Score"] = f"{', '.join([str(p) for p in self.players if abs(sum(p.round_scores) - self.median_total_score()) == abs(smallest_median_diff)])} ({smallest_median_diff})"
return prizelist
log_db = sqlite3.connect("bunco.sqlite")
log_dbc = log_db.cursor()
def run_query(*args):
log_dbc.execute(*args)
log_db.commit()
|