Download:
child 31:72639365f60a
parent 29:0f29304f36f4
30:efdf4524dafd
Anton Shestakov <engored@ya.ru>, Sun, 02 Mar 2014 22:10:59 +0900
Backout nicknames: would make more sense to have nicknames in lobby, not in a room.

2 файлов изменено, 2 вставок(+), 7 удалений(-) [+]
src/rps_bots.erl file | annotate | diff | comparison | revisions
src/rps_room.erl file | annotate | diff | comparison | revisions
--- a/src/rps_bots.erl Sun Mar 02 22:08:58 2014 +0900
+++ b/src/rps_bots.erl Sun Mar 02 22:10:59 2014 +0900
@@ -9,7 +9,6 @@
fool(joined) ->
receive
{room, Room} ->
- Room ! {nickname, self(), "fool"},
random:seed(now()),
fool(Room)
end;
@@ -31,7 +30,6 @@
copycat(joined) ->
receive
{room, Room} ->
- Room ! {nickname, self(), "copycat"},
copycat(Room, hd(get_rules()))
end.
@@ -51,7 +49,6 @@
gambler(joined) ->
receive
{room, Room} ->
- Room ! {nickname, self(), "gambler"},
Wins = dict:from_list([{C, 0} || C <- get_rules()]),
gambler(Room, Wins)
end.
--- a/src/rps_room.erl Sun Mar 02 22:08:58 2014 +0900
+++ b/src/rps_room.erl Sun Mar 02 22:10:59 2014 +0900
@@ -2,7 +2,7 @@
-import(rps3, [get_rules/0, winning_hand/1]).
-export([room/1]).
--record(state, {players=[], choices=[], nicknames=dict:new()}).
+-record(state, {players=[], choices=[]}).
% winner for 3 players is:
% rock, rock, rock -> undefined
@@ -41,10 +41,8 @@
lists:foreach(fun(Player) -> Player ! Msg end, Players),
room(Players);
-room(State=#state{choices=Choices, nicknames=Nicknames}) ->
+room(State=#state{choices=Choices}) ->
receive
- {nickname, Who, Nickname} ->
- room(State#state{nicknames=dict:store(Who, Nickname, Nicknames)});
{Hand, Who} ->
ObjectIsOk = lists:any(fun(X) -> X =:= Hand end, get_rules()),
ChoiceMade = lists:keymember(Who, 2, Choices),