Skip to content

Commit

Permalink
Fixed being able to call a draw on the turn immediately after laying …
Browse files Browse the repository at this point in the history
…off on your own meld.
  • Loading branch information
jporubci committed Oct 19, 2023
1 parent aba7dbf commit 1236751
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tong-its.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ async def main(state_info):

# Play a turn
while not server.end:

sabotage = False
# Send gamestate
await send_gamestate(ret_val, server, winner)

Expand Down Expand Up @@ -304,6 +304,8 @@ async def main(state_info):

# Disable player whose meld got added to from calling draw
server.players[message['player_id']].can_draw = False
if message['player_id'] == server.order[0]:
sabotage = True

# Disable player from calling draw
server.players[server.order[0]].can_draw = False
Expand All @@ -324,7 +326,7 @@ async def main(state_info):
server.discard += compose([message['card']])

# Enable player to call draw if they have an exposed meld
if server.players[server.order[0]].melds:
if server.players[server.order[0]].melds and not sabotage:
server.players[server.order[0]].can_draw = True

# Check if game is over
Expand Down Expand Up @@ -381,6 +383,9 @@ async def main(state_info):
# Bool to remember whether pick discard is valid
can_pick_discard = False

# Bool to remember if you sabotaged urself by laying off on ur own meld so now u cant actually call a draw next turn.
sabotage = False

# Display option to pick up from deck
print('0: Pick up a card from the top of the deck')

Expand Down Expand Up @@ -640,6 +645,8 @@ async def main(state_info):

# Disable player whose meld got added to from calling draw
server.players[message['player_id']].can_draw = False
if message['played_id'] == 0:
sabotage = True

# Disable player from calling draw
server.players[server.order[0]].can_draw = False
Expand Down Expand Up @@ -678,7 +685,7 @@ async def main(state_info):
server.discard.append(server.players[0].hand.pop(int(choice)))

# Enable you to call draw if they have an exposed meld
if server.players[0].melds:
if server.players[0].melds and not sabotage:
server.players[0].can_draw = True

# Check if game is over
Expand Down

0 comments on commit 1236751

Please sign in to comment.