title change when asta is finish, privflags added to manage preference
[brisk.git] / web / briskin5 / Obj / briskin5.phh
index beaeed6..28a502c 100644 (file)
@@ -49,7 +49,7 @@ $mlang_bin5_bin5 = array(
                                                'en' => 'they have <b>lost</b>'),
                          'info_yturn'=> array( 'it' => ' tocca a <b>te</b> giocare.',
                                                'en' => ' it\'s <b>your</b> turn.'),
-                         'info_turn' => array( 'it' => 'tocca a <b>$unam</b> giocare.',
+                         'info_turn' => array( 'it' => 'tocca a <b>%s</b> giocare.',
                                                'en' => 'it\'s the <b>%s</b>\'s turn.'),
                          'info_mult' => array( 'it' => ' La partita vale <b>%s</b>.',
                                                'en' => ' The game worth <b>%s</b>.' ),
@@ -195,7 +195,7 @@ class Table_briskin5 extends Table {
   */
 
   /* CLONE() NOT USED
-  function &clone(&$from)
+  function &myclone(&$from)
   {
     GLOBAL $G_false;
     
@@ -403,13 +403,14 @@ class Table_briskin5 extends Table {
 
 
 
-
+define(BIN5_USER_FLAG_RING_ENDAUCT, 0x01);
 
 class User_briskin5 extends User {
   var $asta_card;  // 
   var $asta_pnt;   //
   var $handpt;     // Total card points at the beginning of the current hand.
   var $exitislock; // Player can exit from the table ?
+  var $privflags;  // Flags for briskin5 only 
 
   function User() {
   }
@@ -425,6 +426,7 @@ class User_briskin5 extends User {
     $thiz->asta_pnt  = -1;
     $thiz->handpt = -1;
     $thiz->exitislock = TRUE;
+    $thiz->privflags = 0;
 
     return ($thiz);
   }
@@ -443,10 +445,11 @@ class User_briskin5 extends User {
     $this->asta_pnt   = $from->asta_pnt;
     $this->handpt     = $from->handpt;
     $this->exitislock = $from->exitislock;
+    $this->privflags  = $from->privflags;
   }
 
   /* CLONE NOT USED
-  function &clone(&$from)
+  function &myclone(&$from)
   {
     GLOBAL $G_false;
     
@@ -461,7 +464,7 @@ class User_briskin5 extends User {
   
   function &spawn(&$from, $table, $table_pos)
   {
-    GLOBAL $G_false;
+    GLOBAL $G_false, $CO_bin5_pref_ring_endauct;
     
     if (($thiz =& new User_briskin5()) == FALSE)
       return ($G_false);
@@ -473,6 +476,10 @@ class User_briskin5 extends User {
     $thiz->handpt = -1;
     $thiz->exitislock = TRUE;
 
+    log_wr("Briskin5 constructor");
+
+    $this->privflags  = ($CO_bin5_pref_ring_endauct == "true" ? BIN5_USER_FLAG_RING_ENDAUCT : 0) | 0;
+
     $thiz->table_orig = $table;
     $thiz->table      = 0;
     $thiz->table_pos  = $table_pos;
@@ -951,11 +958,12 @@ function locshm_exists($tok)
     
 }
 
-
+// rendiamo qui l'elenco dei punti come return della func
 function calculate_points(&$table)
 {
   GLOBAL $G_all_points; 
 
+  $ret = array();
   $pro = 0;
 
   if ($table->asta_pnt == 60)
@@ -979,13 +987,15 @@ function calculate_points(&$table)
   
   if ($table->asta_pnt == 61 && $pro == 60) { // PATTA !
     $table->points[$table->points_n % MAX_POINTS] = array();
-    for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) 
+    for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
       $table->points[$table->points_n % MAX_POINTS][$i] = 0;
+      $ret[$i] = 0;
+    }
     $table->points_n++;
     $table->old_pnt = $pro;
     $table->mult *= 2;
 
-    return;
+    return($ret);
   }
 
   if ($pro >= $table->asta_pnt) 
@@ -1010,10 +1020,13 @@ function calculate_points(&$table)
     
     $table->points[$table->points_n % MAX_POINTS][$i] = $pt;
     $table->total[$i] += $pt;
+    $ret[$i] = $pt;
   }
   $table->points_n++;
   $table->old_pnt = $pro;
   $table->mult = 1;
+  
+  return($ret);
 }
 
 /* show table 
@@ -1163,6 +1176,7 @@ function show_table(&$room, &$user, $sendstep, $is_transition, $is_again)
     }
     if (BRISKIN5_PLAYERS_N == 3)
        $showst .= ",-2,-2";
+    $ret .= sprintf('document.title = "Brisk - Tavolo %d (asta)";', $user->table_orig);
     $ret .= sprintf('show_astat(%s);', $showst);
 
     if ($table->asta_win != -1 && $table->asta_win == $table_pos) {
@@ -1384,6 +1398,7 @@ function table_wellcome($user)
 
 function briscola_show($room, $table, $user)
 {
+  GLOBAL $G_lang, $mlang_bin5_bin5;
   $ptnadd = "";
   $ret = "";