Index: bunco.py ================================================================== --- bunco.py +++ bunco.py @@ -1,10 +1,12 @@ # Test import csv, random, sqlite3 teammate_lookup = { 0: 2, 1: 3, 2: 0, 3: 1 } +fuzzydie_holder = 'x' + def TurnInProgress(): return -1 def roll_dice(): dice = [] @@ -11,12 +13,10 @@ for _ in range(3): dice.append(random.randint(1,6)) return dice 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 @@ -77,13 +77,14 @@ log_roll(self, self.current_roll, roll_score) return roll_score def tick(self): + global fuzzydie_holder result = TurnInProgress() - if self.fuzzydie_holder is self: + if 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 @@ -252,10 +253,11 @@ def __init__(self, playerfile): self.players = load_players(playerfile) self.tables = assign_teams(self.players) def tick(self): + global fuzzydie_holder for table in self.tables: table.tick() bunco_rollers = [p for p in self.players if p.rolled_bunco is True] @@ -262,24 +264,25 @@ # 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: + if bunco_rollers[0] is not fuzzydie_holder: log("all",f"{bunco_rollers[0]} claimed the fuzzy die!") + fuzzydie_holder = bunco_rollers[0] 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: + if luckyduck is not 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!!") + if fuzzydie_holder not in bunco_rollers: + fuzzydie_holder = bunco_rollers[-1] + log(fuzzydie_holder, f"{fuzzydie_holder} siezed the fuzzy die!!") else: - log(Player.fuzzydie_holder, f"{Player.fuzzydie_holder} retained the fuzzy die!!") + log(fuzzydie_holder, f"{fuzzydie_holder} retained the fuzzy die!!") for player in bunco_rollers: player.rolled_bunco = False # Reset flag self.increment_tick()