Unnecessary comments removed. Tcp comments are left to verify program correctness

This commit is contained in:
Kallfaktorn 2011-04-20 06:29:15 +02:00
parent 078ba9979e
commit c8e6bebce7
2 changed files with 0 additions and 31 deletions

View file

@ -42,11 +42,9 @@ received_command(Headers, Data) ->
Command = lists:nth(1, CommandList), Command = lists:nth(1, CommandList),
case Command of case Command of
"hello" -> "hello" ->
io:format("Set game token~n"),
pong_bot:set_game_token(Data), pong_bot:set_game_token(Data),
send_command("ready", ""); send_command("ready", "");
"defined" -> "defined" ->
io:format("Defined~n"),
ok; ok;
Command -> Command ->
pong_bot:ggsNetworkReceivedCommandWithArgs(Command, Data) pong_bot:ggsNetworkReceivedCommandWithArgs(Command, Data)
@ -88,20 +86,6 @@ extract_headers(Source) ->
HeaderList = string:tokens(Source, "\n"), HeaderList = string:tokens(Source, "\n"),
key_value_strings_to_dict(HeaderList). key_value_strings_to_dict(HeaderList).
%extract_data([]) ->
% [];
%extract_data([E|ES]) ->
% io:format("~n~s~n~n~n~n", [E]),
% KeyValueList = key_value_string_to_list(E),
% case length(KeyValueList) of
% 2 ->
% extract_data(ES);
% _ ->
% E
% end.
%%%Low-level internals.%%% %%%Low-level internals.%%%

View file

@ -61,15 +61,11 @@ ggsNetworkReceivedCommandWithArgs(Command, Args) ->
end. end.
welcome(Who_am_I) -> welcome(Who_am_I) ->
io:format("Welcome begin~n"),
io:format("I am player: ~s~n", [Who_am_I]),
case Who_am_I of case Who_am_I of
"1" -> "1" ->
io:format("I made myself into player 1~n"),
Me = gen_server:call({global, pong_bot}, player1), Me = gen_server:call({global, pong_bot}, player1),
gen_server:cast({global, pong_bot}, {me, Me}); gen_server:cast({global, pong_bot}, {me, Me});
"2" -> "2" ->
io:format("I made myself into player 2~n"),
Me = gen_server:call({global, pong_bot}, player2), Me = gen_server:call({global, pong_bot}, player2),
gen_server:cast({global, pong_bot}, {me, Me}) gen_server:cast({global, pong_bot}, {me, Me})
end. end.
@ -89,7 +85,6 @@ gameTick() ->
true -> true ->
case SendStart of case SendStart of
false -> false ->
io:format("Command start sent~n"),
ggs_network:send_command("start", ""), ggs_network:send_command("start", ""),
gen_server:cast({global, pong_bot}, {start, true}); gen_server:cast({global, pong_bot}, {start, true});
true -> true ->
@ -116,25 +111,20 @@ gameTick() ->
ball(Pos_s) -> ball(Pos_s) ->
io:format("Ball~n"),
PosList = string:tokens(Pos_s, ","), PosList = string:tokens(Pos_s, ","),
XStr = lists:nth(1,PosList), XStr = lists:nth(1,PosList),
YStr = lists:nth(2,PosList), YStr = lists:nth(2,PosList),
X = list_to_integer(XStr), X = list_to_integer(XStr),
Y = list_to_integer(YStr), Y = list_to_integer(YStr),
io:format("X~B~n", [X]),
io:format("Y~B~n", [Y]),
Pos = {X, Y}, Pos = {X, Y},
gen_server:cast({global, pong_bot}, {ball, Pos}). gen_server:cast({global, pong_bot}, {ball, Pos}).
player1_y(YStr) -> player1_y(YStr) ->
Y = list_to_integer(YStr), Y = list_to_integer(YStr),
io:format("Y in integer: ~B~n", [Y]),
gen_server:cast({global, pong_bot}, {player1_y, Y}). gen_server:cast({global, pong_bot}, {player1_y, Y}).
player2_y(YStr) -> player2_y(YStr) ->
Y = list_to_integer(YStr), Y = list_to_integer(YStr),
io:format("Y in integer: ~B~n", [Y]),
gen_server:cast({global, pong_bot}, {player2_y, Y}). gen_server:cast({global, pong_bot}, {player2_y, Y}).
game(WaitOrStart) -> game(WaitOrStart) ->
@ -162,9 +152,7 @@ view() ->
gen_server:call({global, pong_bot}, game_token). gen_server:call({global, pong_bot}, game_token).
handle_call(player1, _From, State) -> handle_call(player1, _From, State) ->
io:format("Player1 before~n"),
Player1 = dict:fetch(player1, State), Player1 = dict:fetch(player1, State),
io:format("Player1 after~n"),
{reply, Player1, State}; {reply, Player1, State};
handle_call(player2, _From, State) -> handle_call(player2, _From, State) ->
@ -192,13 +180,10 @@ handle_call(game_token, _From, State) ->
{reply, GameToken, State}; {reply, GameToken, State};
handle_call(view, _From, State) -> handle_call(view, _From, State) ->
io:format("View the state.~n"),
% StateFromList = lists:nth(1, State)
{reply, State, State}; {reply, State, State};
handle_call(socket, _From, State) -> handle_call(socket, _From, State) ->
Socket = dict:fetch(socket, State), Socket = dict:fetch(socket, State),
%Socket = lists:nth(1, SocketInList),
{reply, Socket, State}; {reply, Socket, State};
handle_call(paused, _From, State) -> handle_call(paused, _From, State) ->