Maxim Sokhatsky 11 лет назад
Родитель
Сommit
24709aff8a
2 измененных файлов с 20 добавлено и 1 удалено
  1. 17 0
      apps/face/src/index.erl
  2. 3 1
      apps/face/src/protocol.erl

+ 17 - 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(),
@@ -103,6 +113,7 @@ body() ->
       #button{ id = discard, body = <<"Discard">>, postback = discard, source=[discard_combo]},
       #button{ id = reveal, body = <<"Reveal">>, postback = reveal, source = [discard_combo]},#br{},
       #button{ id = is_saw_okey, body = <<"I Saw Okey">>, postback = i_saw_okey},
+      #button{ id = i_have_8_tashes, body = <<"I have 8 Tashes">>, postback = i_have_8_tashes},
       #button{ id = pause, body = <<"Pause">>, postback = pause},
       #button{ id = player_info, body = <<"PlayerInfo">>, postback = player_info}
     ].
@@ -156,6 +167,10 @@ event(i_saw_okey) ->
     wf:info("i_saw_okey!"),
     wf:wire(protocol:i_saw_okey(wf:to_list(?GAMEID)));
 
+event(i_have_8_tashes) ->
+    wf:info("i_gave_8_tashes!"),
+    wf:wire(protocol:i_have_8_tashes(wf:to_list(?GAMEID)));
+
 event(pause) ->
     Action  =
         case get(game_okey_pause) of 
@@ -291,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"),[])))).