summaryrefslogtreecommitdiff
path: root/cao-common.js
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-06-09 01:30:14 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-06-09 01:30:14 +0100
commit98559886b1c293e55b75122c76792ee8f7cb530e (patch)
tree29816361e86f49f2ce6f945585cec960706a9a6d /cao-common.js
parent00a675237958704ceea56b7e47a509e873d92705 (diff)
ui: handle the number of played cards properly
the number is stored in the cao object and can be retrieved by the mobile / desktop part. Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'cao-common.js')
-rw-r--r--cao-common.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/cao-common.js b/cao-common.js
index 1b1b309..050490c 100644
--- a/cao-common.js
+++ b/cao-common.js
@@ -18,6 +18,7 @@ var CAO = function() {
this.on_card_played = function() { /* to override */ };
this.on_cards_collected = function() { /* to override */ };
this.on_updated_score = function(new_score) { /* to override */ };
+ this.on_change_nbr_played_cards = function(nbr) { /* to override */ };
var request_queue = [];
@@ -26,6 +27,8 @@ var CAO = function() {
var self = this;
var ws;
+ var nbr_played_cards = 0;
+
var played_cards = [];
var white_cards = {};
var black_card;
@@ -39,6 +42,18 @@ var CAO = function() {
return judge;
};
+ this.reset_nbr_played_cards = function() {
+ nbr_played_cards = 0;
+
+ self.on_change_nbr_played_cards(nbr_played_cards);
+ };
+
+ this.incr_nbr_played_cards = function() {
+ ++nbr_played_cards;
+
+ self.on_change_nbr_played_cards(nbr_played_cards);
+ };
+
/* map_handle_response_ok {{{ */
map_handle_response_ok['join_game'] = function(result) {