Bunco Simulator

Diff

Differences From Artifact [15d7f1]:

To Artifact [bdb21a]:


1
2
3
4
5


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Test
import csv, random, sqlite3

teammate_lookup = { 0: 2, 1: 3, 2: 0, 3: 1 }



def TurnInProgress():
    return -1

def roll_dice():
    dice = []
    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
        self.max_streak = 0
        self.round_bunco_counts = [0]





>
>










<
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17


18
19
20
21
22
23
24
# 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 = []
    for _ in range(3):
        dice.append(random.randint(1,6))
    return dice

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.round_bunco_counts = [0]
75
76
77
78
79
80
81

82
83
84
85
86
87
88
89
90
91
        else:
            self.current_streak = 0
        
        log_roll(self, self.current_roll, roll_score)
        return roll_score
        
    def tick(self):

        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







>


|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
        else:
            self.current_streak = 0
        
        log_roll(self, self.current_roll, roll_score)
        return roll_score
        
    def tick(self):
        global fuzzydie_holder
        result = TurnInProgress()

        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

        if self.turn_progress < 25:
            # Grabbing the dice
250
251
252
253
254
255
256

257
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
    cur_round = 1
    
    def __init__(self, playerfile):
        self.players = load_players(playerfile)
        self.tables = assign_teams(self.players)

    def tick(self):

        for table in self.tables:
            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







>










|

>




|


|
|
|

|







251
252
253
254
255
256
257
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
289
290
    cur_round = 1
    
    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]
        
        # 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 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 fuzzydie_holder:
                        log(luckyduck,f"{luckyduck} attempted to claim 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(fuzzydie_holder, f"{fuzzydie_holder} retained the fuzzy die!!")
            
            for player in bunco_rollers:
                player.rolled_bunco = False # Reset flag
    
        self.increment_tick()
    
    @classmethod