diff options
author | Jeremie Taboada <taboada.jeremie@gmail.com> | 2015-06-05 02:43:37 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-06-08 17:01:47 +0100 |
commit | bdf81335e9ef693367ddbd25f40d327a565d69d6 (patch) | |
tree | 84b59201287ab890d2373d85d5fc54c6c71b24c5 /cao-mobile.js | |
parent | 2e3485c9d1f01327df9f192a74e572459e2f341c (diff) |
Continue implementation.
Diffstat (limited to 'cao-mobile.js')
-rw-r--r-- | cao-mobile.js | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/cao-mobile.js b/cao-mobile.js index 9294104..692dab3 100644 --- a/cao-mobile.js +++ b/cao-mobile.js @@ -5,6 +5,7 @@ $(document).ready(function() { var $judge_collect = $('[data-state="judge-collect"]'); var $judge_choose = $('[data-state="judge-choose"]'); var $player_choose = $('[data-state="player-choose"]'); + var $player_wait = $('[data-state="player-wait"]'); var $leave_room = $('#leave-room'); var $all = $("[data-state]"); var $join_btn = $("#join-btn"); @@ -12,6 +13,7 @@ $(document).ready(function() { var $black_card = $("#black-card"); var $played_card_number = $("#played-card-number"); var $header = $("header"); + var $white_cards = $('#white-cards'); $leave_room.click(function () { window.location.reload(); @@ -24,17 +26,29 @@ $(document).ready(function() { }); }; - cao.on_join_game_ok = function() { + cao.on_join_game_ok = function(game_state) { $header.show(); $home.removeClass("current"); $become_judge.addClass("current"); $become_judge_btn.on("click", function () { $game.addClass("current"); $all.hide(); - $become_judge.show(); - $become_judge_btn.on("click", function() { - cao.pick_black_card(); - }); + switch (game_state) { + case "waiting_collection": + $player_choose.show(); + $white_cards.removeClass("read-only"); + break; + case "waiting_designation": + $player_wait.show(); + $white_cards.addClass("read-only"); + break; + case "waiting_judge": + $become_judge.show(); + $become_judge_btn.on("click", function() { + cao.pick_black_card(); + }); + break; + } }; cao.on_card_played = function(card_number) { @@ -42,15 +56,15 @@ $(document).ready(function() { }; cao.on_show_white_card = function(idx, desc) { - var $white_cards = $('#white-cards'); var identifier = 'white-card-' + idx; var content = '<button class="read-only card" id="' + identifier + '">' + desc + '</button>'; $white_cards.append(content); + var self = this; $('#' + identifier).click(function () { var $this = $(this); - if (!$this.hasClass("read-only")) { + if (!$white_cards.hasClass("read-only")) { if ($this.hasClass("active")) { - this.gen_callback_white_card(idx); + self.gen_callback_white_card(idx); } else { $white_cards.find("> .card").removeClass("active"); $(this).addClass("active"); @@ -86,7 +100,9 @@ $(document).ready(function() { }; cao.on_judge_designed = function() { - // TODO + $all.hide(); + $player_choose.show(); + $white_cards.removeClass("read-only"); }; cao.on_judge_needed = function() { |