Bunco Simulator

Diff

Differences From Artifact [894897]:

To Artifact [e250da]:


1

2
3
4
5
6
7
8
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

>







1
2
3
4
5
6
7
8
9
import bunco
import xlsxwriter
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
66
67
68
69
70
71
72


























































    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)
































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
67
68
69
70
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

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

    # Column headings for each round
    for n in range(g.current_round()):
        ws.write(2, n + 1, n + 1, col_heading)
    
    end_col = g.current_round()
    ws.set_column(1, end_col, 5)
    ws.set_column(end_col + 1, end_col + 5, 10)

    ws.write(2, end_col + 1, "Total", col_heading)
    ws.write(2, end_col + 2, "Wins", col_heading)
    ws.write(2, end_col + 3, "Losses", col_heading)
    ws.write(2, end_col + 4, "Buncos", col_heading)
    ws.write(2, end_col + 5, "Rolls", col_heading)

    # Write players and their scores for each round
    for n, player in enumerate(g.players):
        row = n + 3
        ws.write(row, 0, player.name, row_heading)

        for r in range(g.current_round()):
            col = r + 1
            ws.write(row, col, player.round_scores[r], score_style)

        ws.write(row, end_col + 1, sum(player.round_scores), 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()