Bunco Simulator

Diff

Differences From Artifact [10969e]:

To Artifact [314493]:


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
57
58
59

60
61
62
63
64
65






66
67
68
69
70
71
72
            result += 1 if die == desired_num else 0
    
    print(f"In round {current_round} {name} rolled {dice} = {result}")
    return result


class Player:


    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



    
    def __repr__(self):
        return f"<Player {self.name}:\t\t" \
            + f"\tscores\t\t{self.round_scores}>" \
            + f"\troll counts\t{self.round_roll_counts}>"

    def prep_new_round(self):
        self.round_scores.append(0)
        self.round_roll_counts.append(0)

        self.turn_progress = 0
        self.current_streak = 0

    def tick(self, current_round):
        result = TurnInProgress()







        if self.turn_progress < 25:
            # Grabbing the dice
            # TODO: Incorporate DEXTERITY stat
            self.turn_progress += random.randint(12,25)
        elif self.turn_progress < 50:
            # Rolling the dice
            # TODO: Incorporate ROLL SPEED stat







>
>












>
>
>









>






>
>
>
>
>
>







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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
            result += 1 if die == desired_num else 0
    
    print(f"In round {current_round} {name} rolled {dice} = {result}")
    return result


class Player:
    fuzzydie_holder = None

    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
        self.rolled_bunco = False
    
    def __repr__(self):
        return f"<Player {self.name}:\t\t" \
            + f"\tscores\t\t{self.round_scores}>" \
            + f"\troll counts\t{self.round_roll_counts}>"

    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 tick(self, current_round):
        result = TurnInProgress()

        if self.fuzzydie_holder is self:
            self.current_fuzzydie_streak += 1
            self.max_fuzzydie_streak = max(self.max_fuzzydie_streak, self.current_fuzzydie_streak)
        else:
            self.current_fuzzydie_streak = 0

        if self.turn_progress < 25:
            # Grabbing the dice
            # TODO: Incorporate DEXTERITY stat
            self.turn_progress += random.randint(12,25)
        elif self.turn_progress < 50:
            # Rolling the dice
            # TODO: Incorporate ROLL SPEED stat
80
81
82
83
84
85
86

87
88

89
90
91
92
93
94
95
            self.round_roll_counts[current_round - 1] += 1
            roll_result = roll_dice(self.name, current_round, self.round_roll_counts[current_round - 1])
            
            if roll_result > 0:
                self.current_streak += 1
                self.max_streak = max(self.current_streak, self.max_streak)
                self.round_scores[current_round - 1] += roll_result

                if roll_result == 21:
                    self.bunco_count += 1

            else:
                self.current_streak = 0
            
            result = roll_result
            self.turn_progress = 0
        return result








>


>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
            self.round_roll_counts[current_round - 1] += 1
            roll_result = roll_dice(self.name, current_round, self.round_roll_counts[current_round - 1])
            
            if roll_result > 0:
                self.current_streak += 1
                self.max_streak = max(self.current_streak, self.max_streak)
                self.round_scores[current_round - 1] += roll_result
                self.personal_roll_scores[current_round - 1] += roll_result
                if roll_result == 21:
                    self.bunco_count += 1
                    self.rolled_bunco = True
            else:
                self.current_streak = 0
            
            result = roll_result
            self.turn_progress = 0
        return result

209
210
211
212
213
214
215










216
217
218
219
220
221
222
        self.players = load_players(playerfile)
        self.tables = assign_teams(self.players)
        self.current_round = 1

    def tick(self):
        for table in self.tables:
            table.tick(self.current_round)











    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[self.current_round - 1]} points, streak {player.max_streak} buncos {player.bunco_count}")








>
>
>
>
>
>
>
>
>
>







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
        self.players = load_players(playerfile)
        self.tables = assign_teams(self.players)
        self.current_round = 1

    def tick(self):
        for table in self.tables:
            table.tick(self.current_round)
        
        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

    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[self.current_round - 1]} points, streak {player.max_streak} buncos {player.bunco_count}")