Fixed the funk
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Andre Henriques 2024-01-18 23:13:34 +00:00
parent b015d8cabd
commit b4d0527b41
2 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
defmodule Utils do defmodule Utils do
@min_print_level 3 @min_print_level 0
def safecast(p, m) when p == nil, do: IO.puts('Trying to safecast #{m} with p as nil') def safecast(p, m) when p == nil, do: IO.puts('Trying to safecast #{m} with p as nil')
def safecast(p, m) when is_pid(p), do: send(p, m) def safecast(p, m) when is_pid(p), do: send(p, m)

View File

@ -97,10 +97,12 @@ defmodule Server do
runfn do runfn do
{:start_game, participants, pid_to_inform} -> {:start_game, participants, pid_to_inform} ->
{state, game_id} = try_to_create_game(state, participants) or_state is_list(participants) do
state = set_modifed(state, game_id) {state, game_id} = try_to_create_game(state, participants)
safecast(pid_to_inform, {:start_game_ans, game_id}) state = set_modifed(state, game_id)
state safecast(pid_to_inform, {:start_game_ans, game_id})
state
end
{:get_game_state, game_id, pid_to_inform} -> {:get_game_state, game_id, pid_to_inform} ->
state = get_game_state(state, game_id, pid_to_inform) state = get_game_state(state, game_id, pid_to_inform)
@ -157,7 +159,7 @@ defmodule Server do
name = state.name name = state.name
new_hand = if state.games[game_id].hand[state.name] == :- do new_hand = if state.games[game_id].hand[state.name] == :- do
state.games[game_id].game_state[move] Enum.at(state.games[game_id].game_state, move)
else else
get_hand_for_game_state(state.games[game_id].game_state) get_hand_for_game_state(state.games[game_id].game_state)
end end