Merge branch 'rewrite' of github.com:jeena/GGS into rewrite

This commit is contained in:
Kallfaktorn 2011-02-16 21:19:48 +01:00
commit e8db6fb211
3 changed files with 33 additions and 21 deletions

View file

@ -42,11 +42,7 @@ respawn_table(_Token) ->
%% @doc Removes a player from coordinator. %% @doc Removes a player from coordinator.
remove_player(_From, _Player) -> remove_player(_From, _Player) ->
<<<<<<< HEAD
helpers:not_implemented(). helpers:not_implemented().
=======
not_implemented.
>>>>>>> jonte_rewrite
%% gen_server callbacks %% gen_server callbacks

View file

@ -31,7 +31,6 @@ start_link(Port) ->
%% Reason = String %% Reason = String
stop(_Reason) -> helpers:not_implemented(). stop(_Reason) -> helpers:not_implemented().
%% gen_server callbacks %% gen_server callbacks
%% @doc Initiate the dispatcher. This is called from gen_server %% @doc Initiate the dispatcher. This is called from gen_server

View file

@ -1,5 +1,3 @@
%% @doc This module represents a Player with a Socket and a Token
-module(ggs_table). -module(ggs_table).
-export([ -export([
start_link/1, start_link/1,
@ -9,28 +7,47 @@
notify/3 notify/3
]). ]).
%% @doc This module represents a Player with a Socket and a Token
% @doc returns a new table % @doc returns a new table
start_link(_Token) -> start_link(Token, Socket) ->
helpers:not_implemented(). spawn_link(fun(Token, Socket) ->
GameVM = ggs_gamevm:start_link();
loop(Token, Socket, GameVM, [])
).
% @doc adds a player to a table % @doc adds a player to a table
add_player(_Table, _Player) -> add_player(Table, Player) ->
helpers:not_implemented(). ggs_logger:not_implemented().
% @doc removes player form a table % @doc removes player form a table
remove_player(_Table, _Player) -> remove_player(Table, Player) ->
helpers:not_implemented(). ggs_logger:not_implemented().
% @doc stops the table process % @doc stops the table process
stop(_Table, _Msg) -> stop(Table) ->
helpers:not_implemented(). Table ! {'EXIT', self(), normal}
% @doc notifies the table with a message from a player % @doc notifies the table with a message from a player
notify(_Table, _Player, _Message) -> notify(Table, Player, Message) ->
helpers:not_implemented(). Table ! {notify, Player, Message}.
% loop % loop
loop(Token, Socket, GameVM, PlayerList) ->
receive
% private helpers {add_player, Player} ->
NewPlayerList = list:append(PlayerList, [Player]),
loop(Token, Socket, GameVM, NewPlayerList);
{remove_player, Player} ->
NewPlayerList = list:delete(Player, PlayerList),
loop(Token, Socket, GameVM, NewPlayerList);
{notify, Player, Message} ->
case Message of
{server, define, Args} ->
ggs_gamevm:define(GameVM, Args),
loop(Token, Socket, GameVM, PlayerList);
{game, Command, Args} ->
ggs_gamevm:user_command(GameVM, Player, Command, Args),
loop(Token, Socket, GameVM, PlayerList);
end
end.