Browse Source

added prototype of future test suite, bot plays with bots; TODO: bot must play via ws

Roman Dayneko 11 years ago
parent
commit
3f9ad00a44
1 changed files with 34 additions and 0 deletions
  1. 34 0
      apps/server/src/okey/test_okey_ng.erl

+ 34 - 0
apps/server/src/okey/test_okey_ng.erl

@@ -0,0 +1,34 @@
+-module(test_okey_ng).
+-compile(export_all).
+-include("include/requests.hrl").
+-include("include/settings.hrl").
+-include_lib("kvs/include/user.hrl").
+
+-define(GAMEID, 1000001).
+%-define(GAMEID, 5000220).
+
+main() -> 
+    User = #user{id = <<"testbot@bot.net">>, username = <<"testbot">>, surnames = [<<"bottest">>]},
+
+    kvs:add(User),
+    PlayerInfo = auth_server:user_info(<<"testbot@bot.net">>),
+%%    gas:info(?MODULE, "TEST BOT player info ~p", [PlayerInfo]),
+
+    {ok, BotPid} = game_okey_bot:start_link(self(), PlayerInfo, ?GAMEID),
+    erlang:monitor(process, BotPid),
+
+    game_okey_bot:join_game(BotPid),
+    
+    loop(BotPid).
+
+loop(BotPid) ->
+    gas:info("TEST OKEY NG listen to air"),
+    
+    receive 
+        {server, Msg} -> 
+            gas:info("TEST OKEY NG receive msg ~p", [Msg]),
+            game_okey_bot:sendmessage(BotPid, Msg),
+            loop(BotPid);
+        {'DOWN', _MonitorRef, _Type, _Object, _Info} -> ok;
+        UnknowMsg -> wf:info("Unknow message: ~p", [UnknowMsg]), loop(BotPid)
+    end.