Bunco Simulator

Diff

Differences From Artifact [3c213c]:

To Artifact [349421]:


19
20
21
22
23
24

25
26
27
28
29
19
20
21
22
23

24
25
26
27
28
29





-
+





        self.name = name
        self.dex = dex
        self.math_comprehension = math
        self.roll_speed = speed
        self.max_streak = 0
        self.bunco_count = 0
        self.round_bunco_counts = [0]
        self.round_scores = [0]
        self.round_roll_counts = [0]
        self.personal_roll_scores = [0]
        self.turn_progress = 0
        self.current_streak = 0
42
43
44
45
46

47
48
49
50
51
42
43
44
45
46
47
48
49
50
51
52





+






    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.turn_progress = 0
        self.current_streak = 0

    def score_last_roll(self):
        desired_num = Game.current_round() % 6
67
68
69
70
71
72

73
74
75
76
77
68
69
70
71
72

73
74
75
76
77
78





-
+





            self.current_streak += 1
            self.max_streak = max(self.current_streak, self.max_streak)
            self.round_scores[Game.current_round() - 1] += roll_score
            self.personal_roll_scores[Game.current_round() - 1] += roll_score
            if roll_score == 21:
                self.bunco_count += 1
                self.round_bunco_counts[Game.current_round() - 1] += 1
                self.rolled_bunco = True
        else:
            self.current_streak = 0
        
        log_roll(self, self.current_roll, roll_score)
259
260
261
262
263











264
265






266
267
268
269
270
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275


276
277
278
279
280
281
282
283
284
285
286





+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+





        bunco_rollers = [p for p in self.players if p.rolled_bunco is True]
        
        # If multiple people rolled Bunco this tick, and one of them already has the
        # fuzzy die, they retain it.
        # Otherwise, the last person in the list gets the fuzzy die.
        if bunco_rollers:
            if len(bunco_rollers) == 1:
                if bunco_rollers[0] is not Player.fuzzydie_holder:
                    log("all",f"{bunco_rollers[0]} claimed the fuzzy die!")
                else:
                    log("all",f"{bunco_rollers[0]} rolled a Bunco but already has the fuzzy die!")
            else:
                for luckyduck in bunco_rollers:
                    if luckyduck is not Player.fuzzydie_holder:
                        log(luckyduck,f"{luckyduck} attempted to claim the fuzzy die!")
                
        if bunco_rollers and Player.fuzzydie_holder not in bunco_rollers:
            Player.fuzzydie_holder = bunco_rollers[-1]
                if Player.fuzzydie_holder not in bunco_rollers:
                    Player.fuzzydie_holder = bunco_rollers[-1]
                    log(Player.fuzzydie_holder, f"{Player.fuzzydie_holder} siezed the fuzzy die!!")
                else:
                    log(Player.fuzzydie_holder, f"{Player.fuzzydie_holder} retained the fuzzy die!!")
            
            for player in bunco_rollers:
                player.rolled_bunco = False # Reset flag
    
        self.increment_tick()
    
286
287
288
289
290
291

292
293
294
295
296
302
303
304
305
306

307
308
309
310
311
312





-
+






    def print_status(self):
        for n, table in enumerate(self.tables):
            print(f"== TABLE {n+1} == Team 1:{table.team1_score} pts, Team 2:{table.team2_score} pts")
            for player in table.players:
                print(f"    {player.name} {player.round_scores[Game.current_round() - 1]} points, streak {player.max_streak} buncos {player.bunco_count}")
                print(f"    {player.name} {player.round_scores[Game.current_round() - 1]} points, streak {player.max_streak} buncos {sum(player.round_bunco_counts)}")

    def prep_next_round(self):
        # losers from head table move to next table
        headtable_losers = self.tables[0].losers()
        log_table_move(headtable_losers, "lost", self.tables[0], self.tables[1])