removed old duplicated strings
[brisk.git] / web / briskin5 / Obj / briskin5.phh
index d3066be..76e3c72 100644 (file)
@@ -32,9 +32,7 @@ define('BIN5_PROXY_PATH', PROXY_PATH."/bin5");
 
 require_once('rules.phh');
 
-// FIXME: JUST FOR DEVELOP
-// define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_NO_DRAW);
-define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_TOGETHER17);
+define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_NO_DRAW);
 
 $mlang_bin5_bin5 = array(
                          // br, hr, b, /b, win, fri
@@ -55,53 +53,6 @@ $mlang_bin5_bin5 = array(
                          'info_match'=> array( 'it' => 'Il codice della partita è <b>%d</b>.',
                                                'en' => 'Match code is <b>%d</b>.'),
 
-
-
-                         // br, hr, b, /b, win, fri
-                         'info_part' => array( 'it' => 'Ha chiamato %3$s%5$s%4$s (punti torneo %7$d), il socio era %3$s%6$s%4$s,%1$s',
-                                               'en' => 'The declarer was %3$s%5$s%4$s (tournment points %7$d), the partner was %3$s%6$s%4$s,%1$s'),
-                         // br, hr, b, /b
-                         'info_capp' => array( 'it' => 'hanno fatto %3$scappotto%4$s EBBRAVI!.%1$s',
-                                               'en' => 'and they made %3Dscapot%4$s WELL DONE!.%1$s'),
-
-                         // br, hr, b, /b, old_asta_pnt, old_pnt, winornot
-                         'info_alea' => array( 'it' => 'dovevano fare %3$salmeno %5$d%4$s punti e ne hanno fatti %3$s%6$d%4$s: hanno %7$s.%1$s',
-                                               'en' => 'they had to do %3$sat least %5$d%4$s points and they had made %3$s%6$d%4$s: they have %7$s.%1$s'),
-                         // br, hr, b, /b, old_pnt, winornot
-                         'info_more' => array( 'it' => 'dovevano fare %3$spiù di 60%4$s punti e ne hanno fatti %3$s%5$d%4$s: hanno %6$s.%1$s',
-                                               'en' => 'they had to do %3$sover 60%4$s points and they had made %3$s%5$d%4$s: they have %3$s%6$s%4$s.%1$s'),
-                         'info_win'  => array( 'it' => 'vinto',
-                                               'en' => 'win'),
-                         'info_peer' => array( 'it' => 'pareggiato',
-                                               'en' => 'drew'),
-                         'info_lost' => array( 'it' => 'perso',
-                                               'en' => 'lost'),
-
-                         // br, hr, b, /b, win_name
-                         'info_alon' => array( 'it' => '%3$s%5$s%4$s si è chiamato in mano (punti torneo %6$d),%1$s',
-                                               'en' => '%3$s%5$s%4$s play alone against each other (tournment points %6$d),%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 %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',
-                                                'en' => 'he/she had to do %3$smore than 60%4$s points and they had made %3$s%5$d%4$s: he/she had %3$s%6$s%4$s.%1$s'),
-                         // br, hr, b, /b
-                         'info_acap' => array( 'it' => 'ha fatto %3$scappotto%4$s EBBRAVO!.%1$s',
-                                               'en' => 'and he/she made %3$scapot%4$s WELL DONE!.%1$s'),
-
-                         // br, hr, b, /b
-                         'info_omul' => array( 'it' => '%1$sLa partita valeva %3$s%5$s%4$s.%1$s',
-                                               'en' => '%1$sEN: The game was worth %3$s%5$s%4$s.%1$s' ),
-
-                         // br, hr, b, /b
-                         'info_alpa' => array( 'it' => '%1$sHanno passato %3$stutti%4$s.%1$s',
-                                               'en' => '%1$sEN: Hanno passato %3$stutti%4$s.%1$s' ),
-
-                         // br, hr, b, /b, aband-name
-                         'info_aban' => array( 'it' => ' Ha lasciato %3$s%5$s%4$s perché aveva al massimo %3$s2 punti%4$s.',
-                                               'en' => ' EN: Ha lasciato %3$s%5$s%4$s perché aveva al massimo %3$s2 punti%4$s.'),
-
                          'btn_bkgame'=> array( 'it' => 'torna alla partita',
                                                'en' => 'back to the game'),
                          'call_wptn' => array( 'it' => '<br>con %d punti',
@@ -132,7 +83,14 @@ function multoval($mult)
 
 function dom_select_rules()
 {
-    printf("<select id='select_rules'><option value='1'>Vecchie regole: con pareggio</option><option value='2' selected>Nuove regole: senza pareggio</option><option value='4'>torneo \"insieme per gioco\"</option></select>");
+    $ret = "<select id='select_rules'>\n";
+    foreach (rules_keys() as $key) {
+        $value = rules_id2descr($key);
+        $ret .= sprintf("<option value='%d'>%s</option>\n", $key, $value);
+    }
+    $ret .= "</select>\n";
+
+    echo "$ret";
 }
 
 class Card {
@@ -653,18 +611,26 @@ class Bin5_table extends Table {
 
         do {
             if ($this->match_id != -1) {
+                // FIXME_LANG
                 $msg = sprintf("Stai già giocando la partita con codice %d.", $this->match_id);
                 break;
             }
 
+            if ($this->asta_card != -1 || $this->asta_pla_n < BIN5_PLAYERS_N) {
+                // FIXME_LANG
+                $msg = sprintf("La partita è già stata avviata.");
+                break;
+            }
+
             $rules_id = (int)$rules_id_s;
-            // FIXME: from dynamic rules list
-            if ($rules_id != 1 && $rules_id != 2 && $rules_id != 4) {
+            if (! in_array($rules_id, rules_keys())) {
+                // FIXME_LANG
                 $msg = "queste regole non esistono o non sono attive";
                 break;
             }
 
             if ($user->rules_get() == $rules_id) {
+                // FIXME_LANG
                 $msg = "hai già richiesto di usare queste regole";
                 break;
             }
@@ -738,13 +704,20 @@ class Bin5_table extends Table {
         } while (FALSE);
 
         $dt = date("H:i ", $curtime);
-        for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
-            if ($ret == FALSE && $this->player[$i] != $user->idx)
-                continue;
-            $user_cur = &$bri->user[$this->player[$i]];
-            $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
-            $user_cur->comm[$user_cur->step % COMM_N] .= nickserv_msg($dt, $msg);
-            $user_cur->step_inc();
+        if ($ret == TRUE) {
+            for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
+                $user_cur = &$bri->user[$this->player[$i]];
+                $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+                $user_cur->comm[$user_cur->step % COMM_N] .= nickserv_msg($dt, $msg);
+                $user_cur->step_inc();
+            }
+        }
+        else {
+            $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+            $user->comm[$user->step % COMM_N] = xcape(sprintf("rules_set(%d);",
+                                                              $this->rules->id));
+            $user->comm[$user->step % COMM_N] .= nickserv_msg($dt, $msg);
+            $user->step_inc();
         }
     } // end function rules_change
 } // end class Bin5_table
@@ -1585,8 +1558,10 @@ function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again)
     $ret .= $table->exitlock_show(&$bri->user, $table_pos);
     if (!$is_again) {
         /* GENERAL STATUS */
-        $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;',
-                         $sendstep, $user->stat, $user->subst, $table_pos);
+        $user_rules = $user->rules_get();
+        $ret .= sprintf('gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d; rules_set(%d);',
+                        $sendstep, $user->stat, $user->subst, $table_pos,
+                        ($user_rules == BIN5_USER_CONTINUE_INIT ? $table->rules->id_get() : $user_rules));
 
         log_rd(sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', $sendstep, $user->stat, $user->subst, $table_pos));