match id visualization added
[brisk.git] / web / briskin5 / Obj / briskin5.phh
index 3cc4371..9701af9 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  brisk - briskin5.phh
  *
- *  Copyright (C) 2006-2012 Matteo Nastasi
+ *  Copyright (C) 2006-2013 Matteo Nastasi
  *                          mailto: nastasi@alternativeoutput.it
  *                                  matteo.nastasi@milug.org
  *                          web: http://www.alternativeoutput.it
@@ -30,9 +30,10 @@ define('BIN5_SHM_MAX', (BIN5_SHM_MIN + 1048576));
 define('BIN5_SHM_DLT', 32768);
 define('BIN5_PROXY_PATH', PROXY_PATH."/bin5");
 
-define('BIN5_RULES_FINISH',  0);
-define('BIN5_RULES_ABANDON', 1);
-define('BIN5_RULES_ALLPASS', 2);
+define('BIN5_RULES_OLDSCHEMA', -1);
+define('BIN5_RULES_FINISH',     0);
+define('BIN5_RULES_ABANDON',    1);
+define('BIN5_RULES_ALLPASS',    2);
 
 $mlang_bin5_bin5 = array(
                          // br, hr, b, /b, win, fri
@@ -56,10 +57,10 @@ $mlang_bin5_bin5 = array(
                                                'en' => 'lost'),
 
                          // br, hr, b, /b, win_name
-                         'info_alon' => array( 'it' => 'Nell\'ultima partita %3$s%5$s%4$s si è chiamato in mano,%1$s',
+                         'info_alon' => array( 'it' => 'Nell\'ultima partita %3$s%5$s%4$s si è chiamato in mano,%1$s',
                                                'en' => 'In the last hand %3$s%5$s%4$s play alone against each other,%1$s'),
                          // br, hr, b, /b, old_asta_pnt, old_pnt, winornot
-                         'info_aleaa' => array( 'it' => 'doveva fare %3$salmeno %5$d%4$s punti e ne ha fatti %3$s%6$d%4$s: ha %6$s.%1$s',
+                         'info_aleaa' => array( 'it' => 'doveva fare %3$salmeno %5$d%4$s punti e ne ha fatti %3$s%6$d%4$s: ha %3$s%7$s%4$s.%1$s',
                                                'en' => 'he/she had to do %3$sat least %5$d%4$s points and they had made %3$s%6$d%4$s: he/she had %3$s%7$s%4$s.%1$s'),
                          // br, hr, b, /b, old_pnt, winornot
                          'info_morea' => array( 'it' => 'doveva fare %3$spiù di 60%4$s punti e ne ha fatti %3$s%5$d%4$s: ha %3$s%6$s%4$s.%1$s',
@@ -90,6 +91,8 @@ $mlang_bin5_bin5 = array(
                                                'en' => ' The game worth <b>%s</b>.' ),
                          'info_yshuf'=> array( 'it' => 'Fai <b>tu</b> il mazzo, ',
                                                'en' => 'It\'s <b>your</b> shuffled the cards, '),
+                         'info_match'=> array( 'it' => 'Il codice della partita è <b>%d</b>.',
+                                               'en' => 'Match code is <b>%d</b>.'),
                          'btn_bkgame'=> array( 'it' => 'torna alla partita',
                                                'en' => 'back to the game'),
                          'call_wptn' => array( 'it' => '<br>con %d punti',
@@ -179,6 +182,8 @@ class Bin5_table extends Table {
     var $briscola;
     var $friend;            // the callee idx position at table
 
+    var $match_id;          // the id of the match on the database (-1 == just not saved)
+
     var $old_act;           // last action that trigs the end of the game
     var $old_mazzo;
     var $old_reason;
@@ -216,6 +221,8 @@ class Bin5_table extends Table {
        $thiz->friend    =  -1;
        $thiz->turn      =   0;
 
+       $thiz->match_id     = -1;
+
        $thiz->old_act      = -1;
        $thiz->old_mazzo    = -1;
        $thiz->old_reason   = "";
@@ -256,6 +263,8 @@ class Bin5_table extends Table {
        $thiz->briscola     = $from->briscola;
        $thiz->friend       = $from->friend;
 
+       $thiz->match_id     = $from->match_id;
+
        $thiz->old_act      = $from->old_act;
        $thiz->old_mazzo    = $from->old_mazzo;
        $thiz->old_reason   = $from->old_reason;
@@ -288,6 +297,9 @@ class Bin5_table extends Table {
         $thiz->mazzo    = rand(0,PLAYERS_N-1);
         $thiz->points_n = 0;
         $thiz->mult     = 0;
+
+        $thiz->match_id     = -1;
+
         $thiz->old_asta_win = -1;
         $thiz->old_reason = "";
 
@@ -552,7 +564,7 @@ class Bin5_table extends Table {
                     // return($pts);
                     break;
                 }
-            
+
                 if ($pro >= $this->asta_pnt)
                     $sig = 1;
                 else
@@ -1794,6 +1806,10 @@ function show_table_info(&$bri, &$table, $table_pos)
         $noty .= sprintf($mlang_bin5_bin5['info_mult'][$G_lang], multoval($multer) );
     }
     $noty .= "<hr><br>";
+    if ($table->match_id != -1) {
+        $noty .= sprintf($mlang_bin5_bin5['info_match'][$G_lang], $table->match_id);
+        $noty .= "<hr><br>";
+    }
     $ret .= show_notify($noty, 3000, $mlang_bin5_bin5['btn_bkgame'][$G_lang], 500, 400);
     /* NOTE: show_notify($noty, 3000, "torna alla partita", 500,
      *                   130 + ($table->points_n > 0 ? 50 : 0) +
@@ -1900,7 +1916,10 @@ function game_description($act, $form, $old_mult, $win = -1, $win_name = "?1?",
         $tg_bc = "";
     }
 
-    if ($act == BIN5_RULES_ALLPASS) {
+    if ($act == BIN5_RULES_OLDSCHEMA) {
+        return ("");
+    }
+    else if ($act == BIN5_RULES_ALLPASS) {
         return (sprintf($mlang_bin5_bin5['info_alpa'][$G_lang],
                         $tg_br, $tg_hr, $tg_bo, $tg_bc));
     }
@@ -1911,13 +1930,12 @@ function game_description($act, $form, $old_mult, $win = -1, $win_name = "?1?",
     }
     else {
         $wol = game_result($old_asta_pnt, $old_pnt);
-        
+
         $noty = "";
-        
+
         if ($win != $fri) { // not alone case
-            
             /* MLANG: "<hr>Nell'ultima mano ha chiamato <b>%s</b>, il socio era <b>%s</b>,<br>", "hanno fatto <b>cappotto</b> EBBRAVI!.<hr>", "dovevano fare <b>%s</b> punti e ne hanno fatti <b>%d</b>: hanno <b>%s</b>.<hr>", "<hr>Nell'ultima mano <b>%s</b> si &egrave; chiamato in mano,<br>", "ha fatto <b>cappotto</b> EBBRAVO!.<hr>", "doveva fare <b>%s</b> punti e ne ha fatti <b>%d</b>: ha <b>%s</b>.<hr>", ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt : 'pi&ugrave; di 60'), $table->old_pnt, ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso" */
-            
+
             $noty .= sprintf($mlang_bin5_bin5['info_part'][$G_lang],
                              $tg_br, $tg_hr, $tg_bo, $tg_bc,
                              $win_name,