Create actions.py
parent
b7bd0a7037
commit
3d22b695e6
|
|
@ -0,0 +1,13 @@
|
|||
def draw_tile(state):
|
||||
if state.remaining_tiles == 0:
|
||||
raise ValueError("牌堆已空")
|
||||
tile = state.deck.pop(0)
|
||||
state.remaining_tiles -= 1
|
||||
state.hands[state.current_player][tile] += 1
|
||||
return tile
|
||||
|
||||
def discard_tile(state, tile):
|
||||
if state.hands[state.current_player][tile] == 0:
|
||||
raise ValueError("玩家没有这张牌")
|
||||
state.hands[state.current_player][tile] -= 1
|
||||
state.discards[state.current_player].append(tile)
|
||||
Loading…
Reference in New Issue