Bunco Simulator

Check-in [c760b2]
Overview
Comment:Move I/O out of game API into a proper app (closes [c68bc6d850])
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c760b26a2f687064920be461f084ce88b304083dbecc95373b1ed829d22016f6
User & Date: joel on 2018-11-21 23:02:34
Other Links: manifest | tags
References
2018-11-21
23:03 Closed ticket [c68bc6]: Make the game API “headless” plus 4 other changes artifact: f09e0f user: joel
Context
2018-11-22
03:07
Ensure team is properly credited when a player has to finish up after round ends check-in: d96413 user: joel tags: trunk
2018-11-21
23:02
Move I/O out of game API into a proper app (closes [c68bc6d850]) check-in: c760b2 user: joel tags: trunk
22:18
Log the end of each round, player turn-finishing (substantially completes [73c0c06c42]) check-in: aeff9e user: joel tags: trunk
Changes

Modified bunco.py from [3e3162] to [8b36c5].

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361

    def play_one_round(self):
        # Go until one of the head table teams reaches 21 pts
        while max(self.tables[0].team1_score, self.tables[0].team2_score) < 21:
            self.tick()

        log("all", "BUNCO!! A team at the Head Table has hit 21 points.")

        print("\n\n\t\tB U N C O !!!\n\n")
        
        # Finish up scoring for any players that have unscored rolls
        for player in self.players:
            if player.current_roll:
                print(f"Finishing up: {player}")
                log(player, f"{player} finishing up [their] turn")
                while player.current_roll:
                    player.tick()
                    self.increment_tick()
        
        # Settle ties at each table by doing a roll-off as many times as needed
        for table in self.tables:
            while table.team1_score == table.team2_score:
                print(f"Roll off! {table}")
                log('all', f"{table} having a roll-off to resolve a tie")
                table.roll_off()

        self.print_status()
    
log_db = sqlite3.connect("bunco.sqlite")
log_dbc = log_db.cursor()

def run_query(*args):
    log_dbc.execute(*args)
    log_db.commit()







<
<




<








<


<
<







328
329
330
331
332
333
334


335
336
337
338

339
340
341
342
343
344
345
346

347
348


349
350
351
352
353
354
355

    def play_one_round(self):
        # Go until one of the head table teams reaches 21 pts
        while max(self.tables[0].team1_score, self.tables[0].team2_score) < 21:
            self.tick()

        log("all", "BUNCO!! A team at the Head Table has hit 21 points.")


        
        # Finish up scoring for any players that have unscored rolls
        for player in self.players:
            if player.current_roll:

                log(player, f"{player} finishing up [their] turn")
                while player.current_roll:
                    player.tick()
                    self.increment_tick()
        
        # Settle ties at each table by doing a roll-off as many times as needed
        for table in self.tables:
            while table.team1_score == table.team2_score:

                log('all', f"{table} having a roll-off to resolve a tie")
                table.roll_off()


    
log_db = sqlite3.connect("bunco.sqlite")
log_dbc = log_db.cursor()

def run_query(*args):
    log_dbc.execute(*args)
    log_db.commit()

Added bunco_app.py version [9349c8].

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
import bunco

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

g.play_one_round()
print("\n\n\t\tB U N C O !!!\n\n")
g.print_status()