Overview
| Comment: | Resolve ties at end of round (fixes [f08d3a4db3]). Track table numbers. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
d7edd6aabdcf90f2e922fc12b97083ed |
| User & Date: | joel on 2018-11-20 04:34:02 |
| Other Links: | manifest | tags |
References
|
2018-11-20
| ||
| 04:35 | • Closed ticket [f08d3a]: Need to allow a roll-off in case of tied teams at end of round plus 4 other changes artifact: 53ac90 user: joel | |
Context
|
2018-11-21
| ||
| 01:34 | Track current round in the Player class; various streamlinings check-in: 81a7b3 user: joel tags: trunk | |
|
2018-11-20
| ||
| 04:34 | Resolve ties at end of round (fixes [f08d3a4db3]). Track table numbers. check-in: d7edd6 user: joel tags: trunk | |
| 04:06 | Refine separation of roll/read turn phases; fix scoring of unread rolls at end of round check-in: 5b68c7 user: joel tags: trunk | |
Changes
Modified bunco.py from [5ff744] to [22520d].
| ︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# Finished reading the numbers -- good job, eyeballs and brain!
result = self.score_last_roll(current_round)
self.current_roll = []
self.turn_progress = 0
return result
class Table:
def __init__(self):
self.team1_score = 0
self.team2_score = 0
self.players = []
self.active_player = -1
def __repr__(self):
names = ", ".join([p.name for p in self.players])
| > > > > | | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# Finished reading the numbers -- good job, eyeballs and brain!
result = self.score_last_roll(current_round)
self.current_roll = []
self.turn_progress = 0
return result
class Table:
table_count = 0
def __init__(self):
self.table_count += 1
self.table_number = self.table_count
self.team1_score = 0
self.team2_score = 0
self.players = []
self.active_player = -1
def __repr__(self):
names = ", ".join([p.name for p in self.players])
return f"<Table {self.table_number}: {names}>"
def tick(self, current_round):
if self.active_player == -1:
# First tick for the table this round
self.active_player = random.randint(1, len(self.players)) - 1
result = self.players[self.active_player].tick(current_round)
|
| ︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
self.team2_score += result
self.players[teammate[self.active_player + 1]-1].round_scores[current_round - 1] += result
else:
self.active_player += 1
if self.active_player > (len(self.players) - 1): self.active_player = 0
def losers(self):
if self.team1_score > self.team2_score:
return self.players[1::2]
else:
return self.players[0::2]
def winners(self):
| > > > > > > > > > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
self.team2_score += result
self.players[teammate[self.active_player + 1]-1].round_scores[current_round - 1] += result
else:
self.active_player += 1
if self.active_player > (len(self.players) - 1): self.active_player = 0
def roll_off(self, current_round):
"""Attempt to settle a tie by going round the table once"""
self.active_player = 0
# Let the first player go until they roll for 0 points
while self.active_player == 0:
self.tick(current_round)
# Now let the rest do the same
while self.active_player != 0:
self.tick(current_round)
def losers(self):
if self.team1_score > self.team2_score:
return self.players[1::2]
else:
return self.players[0::2]
def winners(self):
|
| ︙ | ︙ | |||
271 272 273 274 275 276 277 |
# Finish up scoring for any players that have unscored rolls
for player in self.players:
if player.current_roll:
print(f"Finishing up: {player}")
while player.current_roll:
player.tick(self.current_round)
| | > > > > > > | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# Finish up scoring for any players that have unscored rolls
for player in self.players:
if player.current_roll:
print(f"Finishing up: {player}")
while player.current_roll:
player.tick(self.current_round)
# Settle ties at each table by doing a roll-off as many times as needed
for table in self.tables:
while table.team1_score == table.team2_score:
print(f"Roll off! {table}")
table.roll_off(self.current_round)
self.print_status()
|