From b4d0527b41fce4379c20febc3ddedf10019f4a23 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Thu, 18 Jan 2024 23:13:34 +0000 Subject: [PATCH] Fixed the funk --- lib/paxos.ex | 2 +- lib/server.ex | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/paxos.ex b/lib/paxos.ex index 2ff0d17..814c104 100644 --- a/lib/paxos.ex +++ b/lib/paxos.ex @@ -1,6 +1,6 @@ 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 is_pid(p), do: send(p, m) diff --git a/lib/server.ex b/lib/server.ex index 2eacf4a..8a8c335 100644 --- a/lib/server.ex +++ b/lib/server.ex @@ -97,10 +97,12 @@ defmodule Server do runfn do {:start_game, participants, pid_to_inform} -> - {state, game_id} = try_to_create_game(state, participants) - state = set_modifed(state, game_id) - safecast(pid_to_inform, {:start_game_ans, game_id}) - state + or_state is_list(participants) do + {state, game_id} = try_to_create_game(state, participants) + state = set_modifed(state, game_id) + safecast(pid_to_inform, {:start_game_ans, game_id}) + state + end {:get_game_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 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 get_hand_for_game_state(state.games[game_id].game_state) end