Просмотр исходного кода

Merge branch 'master' of https://github.com/kakaranet/games

Conflicts:
	apps/face/src/index.erl
Roman Dayneko 11 лет назад
Родитель
Сommit
a88ec4d12a
4 измененных файлов с 0 добавлено и 123 удалено
  1. 0 91
      apps/face/src/index.erl
  2. 0 25
      apps/face/src/login.erl
  3. 0 6
      apps/face/src/n2o_game.erl
  4. 0 1
      apps/face/src/routes.erl

+ 0 - 91
apps/face/src/index.erl

@@ -1,91 +0,0 @@
--module(index).
--compile({parse_transform, shen}).
--compile(export_all).
--include_lib("n2o/include/wf.hrl").
--include_lib("server/include/requests.hrl").
--include_lib("server/include/settings.hrl").
--jsmacro([take/2]).
-
-take(GameId,Place) ->
-    ws:send(bert:encodebuf(bert:tuple(bert:atom('client'),
-        bert:tuple(bert:atom("game_action"),GameId,bert:atom("okey_take"),[{pile,Place}])))).
-
-main() -> 
-    case wf:user() of
-         undefined -> wf:redirect("/login"), #dtl{file="index",app=n2o_sample,bindings=[{title,""},{body,""}]};
-         _ -> #dtl{file = "index", app=n2o_sample,bindings=[{title,<<"N2O">>},{body,body()}]}
-     end.
-
-body() ->
-    [ #panel{ id=history },
-      #dropdown { id=drop, value="2", postback=combo, source=[drop], options=[
-        #option { label= <<"Option 1">>, value= <<"1">> },
-        #option { label= <<"Option 2">>, value= <<"2">> },
-        #option { label= <<"Option 3">>, value= <<"3">> }
-     ]},
-      #button{ id = attach, body = <<"Attach">>, postback = attach},
-      #button{ id = join, body = <<"Join">>, postback = join},
-      #button{ id = take, body = <<"Take">>, postback = take},
-      #dropdown { id=dropdown1, value="2", options=[
-                                                    #option { body="Option 1", value="1" },
-                                                    #option { body="Option 2", value="2" },
-                                                    #option { body="Option 3", value="3" }
-                                                   ]},
-      #button{ id = discard, body = <<"Discard">>, postback = discard}
-    ].
-
-event(init) ->
-    {ok,GamePid} = game_session:start_link(self()),
-    put(game_session,GamePid);
-
-event(combo) ->
-    wf:info("Combo: ~p",[wf:q(drop)]);
-
-event(attach) ->
-    Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'), Bert.tuple(Bert.atom('session_attach'), '" ++ ?TEST_TOKEN ++ "'))));",
-    wf:wire(Msg);
-
-event(join) ->
-    Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'), Bert.tuple(Bert.atom('join_game'), 1000001))));",
-    wf:wire(Msg);
-
-
-%%-record(game_action, {
-%%          game      :: 'GameId'(),
-%%          action    :: string(),
-%%          args = [] :: proplist()
-%%         }).
-
-%%-record(okey_take, {
-%%          pile :: integer() %% 0 or 1
-%%         }).
-
-
-
-event(take) ->
-    Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'),"
-        " Bert.tuple(Bert.atom('game_action'), 1000001, Bert.atom('okey_take'), {pile: 0} ) )));",
-    wf:wire(take("1000001","0"));
-
-%%-record('OkeyPiece', {
-%%          color = -1 :: integer(),           %% 1..4
-%%          value = -1 :: integer()            %% 1..13
-%%          %% color set to 1 and value set to zero mean that this is false okey
-%%         }).
-
-
-%%-record(okey_discard, {
-%%          tile :: #'OkeyPiece'{}
-%%         }).
-
-
-event(discard) ->
-    Color = "1", %%wf:q(cardcolor),
-    Value = "1", %%wf:q(cardvalue),
-    Msg = "ws.send(Bert.encodebuf(Bert.tuple(Bert.atom('client'),"
-        " Bert.tuple(Bert.atom('game_action'), 1000001, Bert.atom('okey_discard')," 
-        " [Bert.tuple(Bert.atom('tile'), Bert.tuple(Bert.atom('OkeyPiece'), " ++ Color ++ ", " ++ Value ++ "))]) )));",
-    wf:wire(Msg);
-
-event(Event) -> wf:info("Event: ~p", [Event]).
-

+ 0 - 25
apps/face/src/login.erl

@@ -1,25 +0,0 @@
--module(login).
--compile(export_all).
--include_lib("n2o/include/wf.hrl").
-
-title() -> [ <<"Login">> ].
-main() -> #dtl{file = "login", app=n2o_sample,bindings=[{title,title()},{body,body()}]}.
-
-body() ->
- [ #span{id=display}, #br{},
-            #span{body="Login: "}, #textbox{id=user}, #br{},
-            #span{body="Password: "}, #password{id=pass},
-            #button{id=login,body="Login",postback=login,source=[user,pass]} ].
-%    react:x().
-
-event(init) -> [];
-event(login) ->
-    User = wf:q(user),
-    wf:update(display,User),
-    wf:user(User),
-    <<"/ws/",X/binary>> = wf:path(?REQ),
-    case X of
-        <<>> -> wf:redirect("/index");
-        <<"login">> -> wf:redirect("/index");
-         _ -> wf:redirect("/static/spa/index.htm") end;
-event(_) -> [].

+ 0 - 6
apps/face/src/n2o_game.erl

@@ -23,12 +23,6 @@ init(_Transport, Req, _Opts, _Active) ->
     Req1 = wf:header(<<"Access-Control-Allow-Origin">>, <<"*">>, NewCtx#context.req),
     Req1 = wf:header(<<"Access-Control-Allow-Origin">>, <<"*">>, NewCtx#context.req),
     {ok, Req1, NewCtx}.
     {ok, Req1, NewCtx}.
 
 
-%% {'KamfMessage',23,game_event,[{game,undefined},{event,okey_tile_taken},{args,[{player,<<"dusler">>},{pile,0},{revealed,null},{pile_height,43}]}]}
-
-is_proplist([]) -> true;
-is_proplist([{K,_}|L]) when is_atom(K) -> is_proplist(L);
-is_proplist(_) -> false.
-
 stream(<<"ping">>, Req, State) ->
 stream(<<"ping">>, Req, State) ->
     wf:info("ping received~n"),
     wf:info("ping received~n"),
     {reply, <<"pong">>, Req, State};
     {reply, <<"pong">>, Req, State};

+ 0 - 1
apps/face/src/routes.erl

@@ -15,6 +15,5 @@ route_prefix(P) -> route(P).
 
 
 route(<<>>)              -> index;
 route(<<>>)              -> index;
 route(<<"index">>)       -> index;
 route(<<"index">>)       -> index;
-route(<<"login">>)       -> login;
 route(<<"favicon.ico">>) -> static_file;
 route(<<"favicon.ico">>) -> static_file;
 route(_) -> index.
 route(_) -> index.