summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-06-23 15:18:38 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-06-23 15:18:38 +0100
commit349d467d9bae3e8d2cfd121ab63ad437a8e934bd (patch)
tree969a40b648c9a0b674ab5c608af9147252799762
parentf706345678fb53464b4aaa821fb21b9b48894150 (diff)
handle the case when no cards are collected
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rwxr-xr-xserver.py7
-rw-r--r--webapp/cao-common.js4
-rw-r--r--webapp/cao-mobile.js1
3 files changed, 8 insertions, 4 deletions
diff --git a/server.py b/server.py
index 5d117e9..162cd5d 100755
--- a/server.py
+++ b/server.py
@@ -39,11 +39,12 @@ def message_received_handler(client, server, message):
elif op == 'pick_black_card':
res = client['cao_client'].pick_black_card()
elif op == 'designate_card':
+ card_id = None
try:
card_id = int(json_msg['card_id'])
- except KeyError:
- res = cao_error('field `card_id\' is required')
- else:
+ except (KeyError, TypeError):
+ pass
+ finally:
res = client['cao_client'].designate_card(card_id)
elif op == 'play_white_card':
try:
diff --git a/webapp/cao-common.js b/webapp/cao-common.js
index 2742606..6d92de7 100644
--- a/webapp/cao-common.js
+++ b/webapp/cao-common.js
@@ -146,6 +146,10 @@ var CAO = function() {
});
self.on_show_played_card(i, desc);
}
+
+ if (!result.length) {
+ self.gen_callback_played_card(null)();
+ }
};
map_handle_response_ok['designate_card'] = function(result) {
diff --git a/webapp/cao-mobile.js b/webapp/cao-mobile.js
index 3a35b24..c733df8 100644
--- a/webapp/cao-mobile.js
+++ b/webapp/cao-mobile.js
@@ -143,7 +143,6 @@ $(document).ready(function() {
};
cao.on_designate_card_ok = function(idx) {
- console.log('will remove : [' + idx + ']');
$played_cards.empty();
$played_cards.hide();