Browse Source

some elements is reseting at sround start; added i have 8 tashes protocol

Roman Dayneko 11 years ago
parent
commit
2086821bcc
2 changed files with 15 additions and 1 deletions
  1. 12 0
      apps/face/src/index.erl
  2. 3 1
      apps/face/src/protocol.erl

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

@@ -19,6 +19,16 @@
         }
        ).
 
+
+-define(RESET_ELEMENTS, 
+        [
+         {gosterge, #label{ id = gosterge, body="Gosterge: "}},
+         {p1right_combo, #dropdown{ id = p1right_combo, options = []}},
+         {p2right_combo, #dropdown{ id = p2right_combo, options = []}},
+         {p3right_combo, #dropdown{ id = p3right_combo, options = []}},
+         {p4right_combo, #dropdown{ id = p4right_combo, options = []}}
+        ]).
+
 user() -> 
     case wf:user() of undefined ->
         Imagionary = fake_users:imagionary_users(),
@@ -296,6 +306,8 @@ event({server, {game_event, _, okey_game_info, Args}}) ->
 %%  wf:info("okay_game_info ~p", [Args]),
     {_, PlayersInfo} = lists:keyfind(players, 1, Args),
     
+    [wf:update(ElementId, [Element]) || {ElementId, Element} <- ?RESET_ELEMENTS],
+
     PlayersTempl = 
           [
            #okey_player{label_id = player1, right_pile_combo_id = p1right_combo, left_label_id = player4},

+ 3 - 1
apps/face/src/protocol.erl

@@ -1,7 +1,7 @@
 -module(protocol).
 -compile({parse_transform, shen}).
 -compile(export_all).
--jsmacro([take/2,attach/1,join/1,discard/3,player_info/2,reveal/4,piece/2,logout/0,pause/2,i_saw_okey/1]).
+-jsmacro([take/2,attach/1,join/1,discard/3,player_info/2,reveal/4,piece/2,logout/0,pause/2,i_saw_okey/1,i_have_8_tashes/1]).
 
 attach(Token) -> ws:send(enc(tuple(atom('client'),tuple(atom("session_attach"), Token)))).
 join(Game) -> ws:send(enc(tuple(atom('client'),tuple(atom("join_game"), Game)))).
@@ -17,3 +17,5 @@ reveal(GameId, Color, Value, Hand) ->
         [{discarded, tuple(atom("OkeyPiece"), Color, Value)},{hand, Hand}])))).
 i_saw_okey(GameId) ->
     ws:send(enc(tuple(atom('client'),tuple(atom("game_action"),GameId,atom("okey_i_saw_okey"),[])))).
+i_have_8_tashes(GameId) ->
+    ws:send(enc(tuple(atom('client'),tuple(atom("game_action"),GameId,atom("okey_i_have_8_tashes"),[])))).