Skip to content

Commit f35c327

Browse files
committed
Don't have nearest hand calculation recalculate buttons if match hasn't started
1 parent 285e0e5 commit f35c327

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/riichi_advanced/game/game_state.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,10 @@ defmodule RiichiAdvanced.GameState do
20572057
|> Map.put(:calculate_closest_american_hands_pid, nil)
20582058

20592059
# some conditions (namely "is_tenpai_american") might have changed based on closest american hands, so recalculate buttons
2060-
state = Buttons.recalculate_buttons(state)
2060+
# of course, only calculate this if the match has started
2061+
state = if Enum.all?(state.players, fn {_seat, player} -> "match_start" not in player.status end) do
2062+
Buttons.recalculate_buttons(state)
2063+
else state end
20612064
# note that this races the AI: the AI might act before closest_american_hands is calculated, so they may miss buttons that should be there
20622065
# TODO maybe fix this by pausing the game at the start of this particular async calculation, and unpausing after
20632066
state = broadcast_state_change(state, false)

0 commit comments

Comments
 (0)