Bunco Simulator

Check-in [1f732a]
Overview
Comment:Track bunco counts per round; log fuzzy die activity
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1f732a39133b3536e46272e1a43166f250a829a39cc49120f448da5668215bc0
User & Date: joel on 2018-11-21 21:18:43
Other Links: manifest | tags
Context
2018-11-21
22:18
Log the end of each round, player turn-finishing (substantially completes [73c0c06c42]) check-in: aeff9e user: joel tags: trunk
21:18
Track bunco counts per round; log fuzzy die activity check-in: 1f732a user: joel tags: trunk
20:54
Log tables moves by players in between rounds check-in: 9538c9 user: joel tags: trunk
Changes

Modified bunco.py from [3c213c] to [349421].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

    def __init__(self, name, dex, math, speed):
        self.name = name
        self.dex = dex
        self.math_comprehension = math
        self.roll_speed = speed
        self.max_streak = 0
        self.bunco_count = 0
        self.round_scores = [0]
        self.round_roll_counts = [0]
        self.personal_roll_scores = [0]
        self.turn_progress = 0
        self.current_streak = 0
        self.max_fuzzydie_streak = 0
        self.current_fuzzydie_streak = 0







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

    def __init__(self, name, dex, math, speed):
        self.name = name
        self.dex = dex
        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.turn_progress = 0
        self.current_streak = 0
        self.max_fuzzydie_streak = 0
        self.current_fuzzydie_streak = 0
40
41
42
43
44
45
46

47
48
49
50
51
52
53
    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.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
    







>







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    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.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
    
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

        if roll_score > 0:
            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.rolled_bunco = True
        else:
            self.current_streak = 0
        
        log_roll(self, self.current_roll, roll_score)
        return roll_score
        







|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

        if roll_score > 0:
            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.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)
        return roll_score
        
257
258
259
260
261
262
263











264
265




266
267
268
269
270
271
272
            table.tick()
        
        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 and Player.fuzzydie_holder not in bunco_rollers:
            Player.fuzzydie_holder = bunco_rollers[-1]




            for player in bunco_rollers:
                player.rolled_bunco = False # Reset flag
    
        self.increment_tick()
    
    @classmethod
    def current_tick(cls):







>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>







258
259
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
287
288
            table.tick()
        
        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 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()
    
    @classmethod
    def current_tick(cls):
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    def increment_round(cls):
        cls.cur_round += 1

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

    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])
        round_winners = self.tables[1].swap_for_winners(headtable_losers)








|







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
    def increment_round(cls):
        cls.cur_round += 1

    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 {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])
        round_winners = self.tables[1].swap_for_winners(headtable_losers)