Browse Source

tashes out

Maxim Sokhatsky 11 years ago
parent
commit
9653438f32

+ 1 - 0
apps/server/src/okey/okey_table.erl

@@ -334,6 +334,7 @@ handle_parent_message(show_round_result, StateName,
     {Reason,Revealer,RevealerWon,WrongRejects} = case FinishInfo of
         {win_reveal, R, Wrong, _Color, _Okey, _Pairs} -> {win_reveal,R,true,Wrong};
         {fail_reveal, R} -> {fail_reveal,R,false,[]};
+%        {fail_reveal, R} -> {tashes_out,none,false,[]}; % check tashes out event
         tashes_out -> {tashes_out,none,false,[]};
         timeout -> {timeout,none,false,[]};
         set_timeout -> {timeout,none,false,[]};

+ 9 - 5
apps/web/priv/static/app/js/bootloader.js

@@ -278,6 +278,13 @@ function showRoundEnd(o)
 
 }
 
+function hideOverlay()
+{
+    $overlay.hide();
+    $("#Overlay-Results").empty();
+    if (scope.ended) scope.deck.fill([]);
+}
+
 function showRevealHand(o) {
 
     var player    = o.value[0][3][0].value[0][1],
@@ -291,11 +298,8 @@ function showRevealHand(o) {
         if (null == $reveal_deck.$el) {
             $overlay.append(svg(h));
             $reveal_deck = $("#RevealDeck");
-            $("#RevealDeckRoot").on("click",function () {
-                $overlay.hide();
-                $("#Overlay-Results").empty();
-                if (scope.ended) scope.deck.fill([]);
-            });
+            $("#RevealDeckRoot").on("click", hideOverlay);
+            $overlay.on("click", hideOverlay);
         }
 
         $reveal_deck.each(function(card){ card.$el && card.$el.remove(); });

+ 7 - 0
apps/web/priv/static/app/js/okey/okey.js

@@ -220,9 +220,15 @@ function PostLoad()
 
     scope.apiProvider.on("okey_round_ended", function(x) {
         var e = {detail: x.detail.json, raw: x.detail.bert};
+        var reason = dec(e.raw).value[0][3][1].value[0][1].value;
         var gameres = dec(e.raw).value[0][3][2].value[0][1];
         $("#Overlay-Results").empty();
         for (var i=0;i<gameres.length;i++) { gameresultRow(400,130,i,gameres); }
+        if (reason == "tashes_out") {
+            $("#Overlay-Results").empty();
+            $("#Overlay-Text").text("Tashes out");
+            $("#RevealDeckRoot").hide();
+        }
 
     });
 
@@ -255,6 +261,7 @@ function PostLoad()
 
     function pause(e) {
         $overlay.show();
+        $("#Overlay-Results").empty();
         $("#RevealDeckRoot").hide();
         for (var player in scope.playersMap) scope.playersMap[player].timer.pause();
         var player = scope.playersMap[e.detail[3]];