Bunco Simulator

Artifact [b5e7e7]

Artifact b5e7e7229628bc1d6412b0603292c5b9a1070d57dbe393b48f4762266f8efd52:


import bunco
from blessings import Terminal

t = Terminal()
g = bunco.Game("players.csv")

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)
    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())]
    round_str = "".join(rounds)
    print(f"{t.move_x(18)}{t.bold}{round_str}{t.normal}")

    # Print table of players and their scores each round
    for table in g.tables:
        print(f"  {t.blue}{table}")
        for player in table.players:
            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('')

g.play_one_round()
display_dashboard()

def do1():
    g.prep_next_round()
    g.play_one_round()
    display_dashboard()