diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-03-07 22:26:16 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-03-07 22:26:16 +0100 |
commit | f61604a8946ea0f6f003f43c3628bd84381d057f (patch) | |
tree | cdfe4ab5956e6575c84bcc8cc1fe2267ccb83f91 /tictactoe-2/apps/ttt_server/src/ttt_server.erl | |
parent | 911547d0e4e3838fa71cc3f71e5f472114e01431 (diff) | |
download | erlang-workshop-main.tar.gz erlang-workshop-main.tar.bz2 erlang-workshop-main.tar.xz erlang-workshop-main.zip |
Diffstat (limited to 'tictactoe-2/apps/ttt_server/src/ttt_server.erl')
-rw-r--r-- | tictactoe-2/apps/ttt_server/src/ttt_server.erl | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tictactoe-2/apps/ttt_server/src/ttt_server.erl b/tictactoe-2/apps/ttt_server/src/ttt_server.erl index 52a7957..ce59968 100644 --- a/tictactoe-2/apps/ttt_server/src/ttt_server.erl +++ b/tictactoe-2/apps/ttt_server/src/ttt_server.erl @@ -36,21 +36,15 @@ loop(State) -> loop(#ttt_state{ seq = Id + 1, games = orddict:append(Id, Game, State#ttt_state.games)}); - {Player, show, Id} -> + {Player, Cmd, Id} when (Cmd == show) or + (Cmd == join) or + (Cmd == status) or + (Cmd == stop) -> case orddict:find(Id, State#ttt_state.games) of error -> Player ! no_such_game; {ok, [Game]} -> - io:format("show: ~p~n", [Game]), - Game#ttt_game.pid ! {Player, show} - end, - loop(State); - {Player, join, Id} -> - case orddict:find(Id, State#ttt_state.games) of - error -> - Player ! no_such_game; - {ok, [Game]} -> - Game#ttt_game.pid ! {Player, join} + Game#ttt_game.pid ! {Player, Cmd} end, loop(State); dump -> |