summaryrefslogtreecommitdiff
path: root/cao-common.js
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-06-04 20:06:13 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-06-04 20:06:13 +0100
commitc5f0a0b71a9f287006868da2e2209b0622164812 (patch)
treed609e74bfd16b7d0f20b3944bf3cb374c800d9fd /cao-common.js
parentfa3f3c775848893bedefbcc5f00746429435d26b (diff)
display the cards played and allow to select one
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'cao-common.js')
-rw-r--r--cao-common.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/cao-common.js b/cao-common.js
index 6d24de8..909468f 100644
--- a/cao-common.js
+++ b/cao-common.js
@@ -10,12 +10,14 @@ var CAO = function() {
this.on_play_white_card_ok = function(idx) { /* to override */ };
this.on_collect_cards_ok = function() { /* to override */ };
this.on_show_played_card = function(idx, desc) { /* to override */ };
+ this.on_designate_card_ok = function(idx) { /* to override */ };
var request_queue = [];
var self = this;
var ws;
+ var played_cards = [];
var white_cards = {};
var black_card;
@@ -42,7 +44,7 @@ var CAO = function() {
};
ws.onerror = function(evt) {
- alert(evt);
+ console.log(evt);
this.on_socket_error(evt);
};
@@ -117,11 +119,18 @@ var CAO = function() {
for (i in response['result']) {
desc = response['result'][i];
- console.log(desc);
+ played_cards.push(desc);
self.on_show_played_card(i, desc);
}
}
break;
+ case 'designate_card':
+ if (response['status'] == 0) {
+ self.on_designate_card_ok(idx);
+
+ played_cards = [];
+ }
+ break;
default:
console.log(evt);
}
@@ -139,6 +148,18 @@ var CAO = function() {
};
};
+ this.gen_callback_played_card = function(index) {
+ return function() {
+ request = {
+ 'op': 'designate_card',
+ 'card_id': index,
+ };
+
+ request_queue.push('designate_card');
+ ws.send(JSON.stringify(request));
+ };
+ };
+
$('#btn_join').click(function() {
game_name = prompt('Name of the game');