Bunco Simulator

Diff

Differences From Artifact [87116e]:

To Artifact [481d05]:


21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+




















+







        self.math_comprehension = math
        self.roll_speed = speed
        self.max_streak = 0
        self.round_bunco_counts = [0]
        self.round_scores = [0]
        self.round_roll_counts = [0]
        self.personal_roll_scores = [0]
        self.round_wins = [0]
        self.turn_progress = 0
        self.current_streak = 0
        self.max_fuzzydie_streak = 0
        self.current_fuzzydie_streak = 0
        self.rolled_bunco = False
        self.current_roll = []
    
    def __repr__(self):
        return f"<Player {self.name}: " \
            + f"\tscores\t\t{self.round_scores}>" \
            + f"\troll counts\t{self.round_roll_counts}>"

    def __str__(self):
        return self.name

    def prep_new_round(self):
        self.round_scores.append(0)
        self.round_roll_counts.append(0)
        self.personal_roll_scores.append(0)
        self.round_bunco_counts.append(0)
        self.round_wins.append(0)
        self.turn_progress = 0
        self.current_streak = 0

    def score_last_roll(self):
        desired_num = Game.current_round() % 6
        desired_num = 6 if desired_num == 0 else desired_num
    
203
204
205
206
207
208
209




210
211
212
213
214
215
216
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222







+
+
+
+







            # Team 2 (odds) lost
            losers = self.players[1::2]
            # Player 2 move to spot 3
            self.players[3] = self.players[2]
        # Replace middle two players
        self.players[1:3] = new_players
        return losers

    def notch_wins(self):
        for player in self.winners():
            player.round_wins[Game.current_round() - 1] = 1
    
    def prep_new_round(self):
        self.team1_score = 0
        self.team2_score = 0
        self.active_player = -1
        for player in self.players:
            player.prep_new_round()
363
364
365
366
367
368
369


370
371
372
373
374
375
376
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384







+
+







        # Settle ties at each table by doing a roll-off as many times as needed
        for table in self.tables:
            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()
    
log_db = sqlite3.connect("bunco.sqlite")
log_dbc = log_db.cursor()

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