Index: bunco.py ================================================================== --- bunco.py +++ bunco.py @@ -34,10 +34,12 @@ 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 @@ -46,25 +48,35 @@ 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"" \ + 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: @@ -82,12 +94,14 @@ 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 @@ -211,10 +225,20 @@ 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: