From 2b378e3eb7e3851f5e69d9705f9318f77481cba9 Mon Sep 17 00:00:00 2001
From: Olivier Gayot <duskcoder@gmail.com>
Date: Tue, 9 Jun 2015 03:10:24 +0100
Subject: ui: allow to get the played cards from the ifaces

the card descripts and their associated callbacks are saved in the page.

Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
---
 cao-common.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/cao-common.js b/cao-common.js
index e39317f..2742606 100644
--- a/cao-common.js
+++ b/cao-common.js
@@ -59,11 +59,16 @@ var CAO = function() {
         return white_cards[idx]['event'];
     };
 
+    this.get_played_card_event = function(idx) {
+        return played_cards[idx]['event'];
+    };
+
     this.change_state = function(state) {
         game_state = state;
 
         switch (state) {
             case 'waiting_judge':
+                played_cards = [];
                 self.reset_nbr_played_cards();
                 judge = false;
 
@@ -135,7 +140,10 @@ var CAO = function() {
         for (var i in result) {
             var desc = result[i];
 
-            played_cards.push(desc);
+            played_cards.push({
+                'desc': desc,
+                'event': self.gen_callback_played_card(i),
+            });
             self.on_show_played_card(i, desc);
         }
     };
@@ -144,8 +152,6 @@ var CAO = function() {
         self.change_state('waiting_judge');
 
         self.on_designate_card_ok();
-
-        played_cards = [];
     };
 
     /* }}} */
-- 
cgit v1.2.3