From 90af15a4f670d6e2fa7e7bc73210f4c0ac4ee3ba Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 4 Jun 2015 17:26:47 +0100 Subject: renamed files to prepare for the mobile version the files have been renamed from game to cao. Moreover, we now prepare them to adapt to the mobile version of the game. Signed-off-by: Olivier Gayot --- cao-common.css | 28 +++++++++ cao-common.js | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ cao-desktop.html | 31 ++++++++++ cao-mobile.html | 16 ++++++ game.html | 30 ---------- game.js | 171 ------------------------------------------------------- index.html | 2 +- style.css | 28 --------- 8 files changed, 247 insertions(+), 230 deletions(-) create mode 100644 cao-common.css create mode 100644 cao-common.js create mode 100644 cao-desktop.html create mode 100644 cao-mobile.html delete mode 100644 game.html delete mode 100644 game.js delete mode 100644 style.css diff --git a/cao-common.css b/cao-common.css new file mode 100644 index 0000000..c6ecbe6 --- /dev/null +++ b/cao-common.css @@ -0,0 +1,28 @@ +body { + background-color: #222222; + color: #dddddd; +} + +td { + border: 1px white solid; +} + +#black_card { + display: none; +} + +#white_cards { + display: none; +} + +#btn_join { + display: none; +} + +#btn_collect { + display: none; +} + +#btn_pick_black { + display: none; +} diff --git a/cao-common.js b/cao-common.js new file mode 100644 index 0000000..df42d9c --- /dev/null +++ b/cao-common.js @@ -0,0 +1,171 @@ +$(document).ready(function() { + request_queue = [] + var map_white_idx_row = {}; + + var ws = new WebSocket('ws://' + document.location.hostname + ':1236'); + + var self = this; + + ws.onopen = function() { + console.log('connection established'); + $('#btn_join').show(); + }; + + ws.onclose = function() { + }; + + ws.onmessage = function(evt) { + message = JSON.parse(evt.data); + + if (message['type'] == 'notification') { + handle_notification(message['content']); + } else { + handle_response(message['content']); + } + }; + + var handle_notification = function(msg) { + console.log('notification:'); + console.log(msg); + }; + + var handle_response = function(response) { + rq = request_queue.shift(); + + if (response['status'] != 0) { + alert(response['info']); + } + + switch (rq) { + case 'join_game': + console.log(response); + if (response['status'] != 0) { + break; + } + $('#btn_join').hide(); + $('#btn_pick_black').show(); + console.log('just joined the game'); + /* self.request_show_cards(); */ + /* XXX intentional fallback */ + case 'view_player_cards': + if (response['status'] == 0) { + $('#white_cards').show(); + for (i in response['result']) { + element = $('.card_desc').eq(i); + element.html(response['result'][i][1]); + element.dblclick(gen_callback_white_card(i)); + map_white_idx_row[response['result'][i][0]] = i; + } + } + break; + case 'pick_black_card': + if (response['status'] != 0) { + break; + } + $('#btn_collect').show(); + $('#btn_pick_black').hide(); + /* self.request_show_black_card(); */ + /* XXX intentional fallback */ + + case 'view_black_card': + if (response['status'] == 0) { + $('#black_card').show(); + $('#black_card').html(response['result']); + } + break; + case 'play_white_card': + if (response['status'] == 0) { + row = map_white_idx_row[response['result']['card_id']]; + + element = $('.card_desc').eq(row); + element.empty(); + element.dblclick(null) + } + break; + case 'collect_cards': + if (response['status'] != 0) { + break; + } + $('#btn_collect').hide(); + /* XXX intentional fallback */ + case 'view_played_cards': + if (response['status'] == 0) { + for (i in response['result']) { + console.log(response['result'][i]); + } + } + break; + default: + console.log(evt); + } + }; + + ws.onerror = function(evt) { + alert(evt); + }; + + var gen_callback_white_card = function(index) { + return function() { + request = { + 'op': 'play_white_card', + 'card_id': index, + }; + + request_queue.push('play_white_card'); + ws.send(JSON.stringify(request)); + }; + }; + + $('#btn_join').click(function() { + game_name = prompt('Name of the game'); + + request = { + 'op': 'join_game', + 'game_name': game_name, + }; + request_queue.push('join_game'); + ws.send(JSON.stringify(request)); + }); + + $('#btn_pick_black').click(function() { + request = { + 'op': 'pick_black_card', + }; + request_queue.push('pick_black_card'); + ws.send(JSON.stringify(request)); + }); + + $('#btn_collect').click(function() { + request = { + 'op': 'collect_cards', + }; + request_queue.push('collect_cards'); + ws.send(JSON.stringify(request)); + }); + + this.request_show_cards = function() { + request = { + 'op': 'view_player_cards', + }; + + request_queue.push('view_player_cards'); + console.log(request); + ws.send(JSON.stringify(request)); + }; + this.request_show_black_card = function() { + request = { + 'op': 'view_black_card', + }; + + request_queue.push('view_black_card'); + ws.send(JSON.stringify(request)); + }; + this.request_show_played_cards = function() { + request = { + 'op': 'view_played_cards', + }; + + request_queue.push('view_played_cards'); + ws.send(JSON.stringify(request)); + }; +}); diff --git a/cao-desktop.html b/cao-desktop.html new file mode 100644 index 0000000..521294a --- /dev/null +++ b/cao-desktop.html @@ -0,0 +1,31 @@ + + + + + Cards Against Originality (Revisited) + + + + + + + + + + +
+
+ + + + + + + + + + + +
+ + diff --git a/cao-mobile.html b/cao-mobile.html new file mode 100644 index 0000000..361cd70 --- /dev/null +++ b/cao-mobile.html @@ -0,0 +1,16 @@ + + + + + Cards Against Originality (Revisited) + + + + + + +
+ +
+ + diff --git a/game.html b/game.html deleted file mode 100644 index 48d7ee1..0000000 --- a/game.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Cards Against Originality (Revisited) - - - - - - - - - -
-
- - - - - - - - - - - -
- - diff --git a/game.js b/game.js deleted file mode 100644 index df42d9c..0000000 --- a/game.js +++ /dev/null @@ -1,171 +0,0 @@ -$(document).ready(function() { - request_queue = [] - var map_white_idx_row = {}; - - var ws = new WebSocket('ws://' + document.location.hostname + ':1236'); - - var self = this; - - ws.onopen = function() { - console.log('connection established'); - $('#btn_join').show(); - }; - - ws.onclose = function() { - }; - - ws.onmessage = function(evt) { - message = JSON.parse(evt.data); - - if (message['type'] == 'notification') { - handle_notification(message['content']); - } else { - handle_response(message['content']); - } - }; - - var handle_notification = function(msg) { - console.log('notification:'); - console.log(msg); - }; - - var handle_response = function(response) { - rq = request_queue.shift(); - - if (response['status'] != 0) { - alert(response['info']); - } - - switch (rq) { - case 'join_game': - console.log(response); - if (response['status'] != 0) { - break; - } - $('#btn_join').hide(); - $('#btn_pick_black').show(); - console.log('just joined the game'); - /* self.request_show_cards(); */ - /* XXX intentional fallback */ - case 'view_player_cards': - if (response['status'] == 0) { - $('#white_cards').show(); - for (i in response['result']) { - element = $('.card_desc').eq(i); - element.html(response['result'][i][1]); - element.dblclick(gen_callback_white_card(i)); - map_white_idx_row[response['result'][i][0]] = i; - } - } - break; - case 'pick_black_card': - if (response['status'] != 0) { - break; - } - $('#btn_collect').show(); - $('#btn_pick_black').hide(); - /* self.request_show_black_card(); */ - /* XXX intentional fallback */ - - case 'view_black_card': - if (response['status'] == 0) { - $('#black_card').show(); - $('#black_card').html(response['result']); - } - break; - case 'play_white_card': - if (response['status'] == 0) { - row = map_white_idx_row[response['result']['card_id']]; - - element = $('.card_desc').eq(row); - element.empty(); - element.dblclick(null) - } - break; - case 'collect_cards': - if (response['status'] != 0) { - break; - } - $('#btn_collect').hide(); - /* XXX intentional fallback */ - case 'view_played_cards': - if (response['status'] == 0) { - for (i in response['result']) { - console.log(response['result'][i]); - } - } - break; - default: - console.log(evt); - } - }; - - ws.onerror = function(evt) { - alert(evt); - }; - - var gen_callback_white_card = function(index) { - return function() { - request = { - 'op': 'play_white_card', - 'card_id': index, - }; - - request_queue.push('play_white_card'); - ws.send(JSON.stringify(request)); - }; - }; - - $('#btn_join').click(function() { - game_name = prompt('Name of the game'); - - request = { - 'op': 'join_game', - 'game_name': game_name, - }; - request_queue.push('join_game'); - ws.send(JSON.stringify(request)); - }); - - $('#btn_pick_black').click(function() { - request = { - 'op': 'pick_black_card', - }; - request_queue.push('pick_black_card'); - ws.send(JSON.stringify(request)); - }); - - $('#btn_collect').click(function() { - request = { - 'op': 'collect_cards', - }; - request_queue.push('collect_cards'); - ws.send(JSON.stringify(request)); - }); - - this.request_show_cards = function() { - request = { - 'op': 'view_player_cards', - }; - - request_queue.push('view_player_cards'); - console.log(request); - ws.send(JSON.stringify(request)); - }; - this.request_show_black_card = function() { - request = { - 'op': 'view_black_card', - }; - - request_queue.push('view_black_card'); - ws.send(JSON.stringify(request)); - }; - this.request_show_played_cards = function() { - request = { - 'op': 'view_played_cards', - }; - - request_queue.push('view_played_cards'); - ws.send(JSON.stringify(request)); - }; -}); diff --git a/index.html b/index.html index 92dc074..e0714fc 120000 --- a/index.html +++ b/index.html @@ -1 +1 @@ -game.html \ No newline at end of file +cao-desktop.html \ No newline at end of file diff --git a/style.css b/style.css deleted file mode 100644 index c6ecbe6..0000000 --- a/style.css +++ /dev/null @@ -1,28 +0,0 @@ -body { - background-color: #222222; - color: #dddddd; -} - -td { - border: 1px white solid; -} - -#black_card { - display: none; -} - -#white_cards { - display: none; -} - -#btn_join { - display: none; -} - -#btn_collect { - display: none; -} - -#btn_pick_black { - display: none; -} -- cgit v1.2.3