log points to calculate classifics
[brisk.git] / web / briskin5 / index_wr.php
index 9d5b463..1ed5e59 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  brisk - index_wr.php
  *
- *  Copyright (C) 2006-2008 Matteo Nastasi
+ *  Copyright (C) 2006-2009 Matteo Nastasi
  *                          mailto: nastasi@alternativeoutput.it 
  *                                  matteo.nastasi@milug.org
  *                          web: http://www.alternativeoutput.it
@@ -120,27 +120,33 @@ else if ($user->stat == 'table') {
        $logout_cont = FALSE;
       }
     }
-    else 
-      $user->bantime = $user->laccwr + BAN_TIME;
+    else {
+      require_once("../Obj/hardban.phh");
+      Hardbans::add(($user->flags & USER_FLAG_AUTH ? $user->name : FALSE),
+                    $user->ip, $user->sess, $user->laccwr + BAN_TIME);
+    }
+    //      $user->bantime = $user->laccwr + BAN_TIME;
     
     if ($logout_cont == TRUE) {
       $bri->table_wakeup(&$user);
     }
   }
   else if ($argz[0] == 'exitlock') {
-    $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);
-    for ($ct = 0, $i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {   
-      $user_cur[$i] = &$bri->user[$table->player[$i]];
-      if ($user_cur[$i]->exitislock == FALSE)
-       $ct++;
-    }
-    for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
-      $ret = sprintf('gst.st = %d;', $user_cur[$i]->step+1);
-      $ret .= sprintf('exitlock_show(%d, %s);', $ct, 
-                    ($user_cur[$i]->exitislock ? 'true' : 'false'));
-      $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N] = $ret;
-      log_wr($user_cur[$i]->comm[$user_cur[$i]->step % COMM_N]);
-      $user_cur[$i]->step_inc();
+    if ($user->exitislock == TRUE) {
+      $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);
+      for ($ct = 0, $i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) { 
+        $user_cur[$i] = &$bri->user[$table->player[$i]];
+        if ($user_cur[$i]->exitislock == FALSE)
+          $ct++;
+      }
+      for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+        $ret = sprintf('gst.st = %d;', $user_cur[$i]->step+1);
+        $ret .= sprintf('exitlock_show(%d, %s);', $ct, 
+                        ($user_cur[$i]->exitislock ? 'true' : 'false'));
+        $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N] = $ret;
+        log_wr($user_cur[$i]->comm[$user_cur[$i]->step % COMM_N]);
+        $user_cur[$i]->step_inc();
+      }
     }
   }
   else if ($user->subst == 'asta') {
@@ -150,7 +156,7 @@ else if ($user->stat == 'table') {
       log_wr(sprintf("GIOCO FINITO !!!"));
     
       $table->mult *= 2; 
-      $table->old_reason = sprintf("Ha lasciato %s perch&eacute; aveva al massimo 2 punti.", xcape($user->name));
+      $table->old_reason = sprintf("Ha lasciato %s perché aveva al massimo 2 punti.", xcape($user->name));
 
       $table->game_next();
       $table->game_init(&$bri->user);
@@ -286,9 +292,11 @@ else if ($user->stat == 'table') {
                  $table->asta_pla[$i] = FALSE;
            }
            else {
-             //"gst.st = ".($user->step+1)."; dispose_asta(".($table->asta_card + 1).",".-($table->asta_pnt).", true); remark_off();";
-             $user->comm[$user->step % COMM_N] = sprintf( "gst.st = %d; dispose_asta(%d, %d, false); remark_off();", $user->step+1, $table->asta_card + 1,-($table->asta_pnt));
+              /*
+             $user->comm[$user->step % COMM_N] = sprintf( "gst.st = %d; dispose_asta(%d, %d, false); remark_off();", 
+                                                           $user->step+1, $table->asta_card + 1,-($table->asta_pnt));
              $user->step_inc();
+              */
              for ($i = 1 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
                $chooser = ($table->gstart + $i) % BRISKIN5_PLAYERS_N;
                if ($table->asta_pla[$chooser]) {
@@ -300,10 +308,11 @@ else if ($user->stat == 'table') {
 
            for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
              $user_cur = &$bri->user[$table->player[$i]];
-             $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
+             $ret = sprintf('gst.st = %d; %s dispose_asta(%d, %d, false);', $user_cur->step+1, $showst,
+                             $table->asta_card + 1,-($table->asta_pnt));
 
              if ($i == $chooser) {
-               $ret .= "choose_seed(". $table->asta_card."); \$(\"asta\").style.visibility = \"hidden\"; remark_on();";
+               $ret .= "choose_seed(". $table->asta_card."); remark_on();";
              }
              else {
                $ret .= "remark_off();";
@@ -324,7 +333,7 @@ else if ($user->stat == 'table') {
       if ($table->asta_win > -1 && 
          $user->table_pos == $table->asta_win) {
        $a_brisco = $argz[1];
-       if ($a_brisco >= 0 && $a_brisco < 40) {
+       if ($a_brisco >= 0 && $a_brisco < (BRISKIN5_PLAYERS_N == 5 ? 40 : 24)) {
          $table->briscola = $a_brisco;
          $table->friend   = $table->card[$a_brisco]->owner;
          log_wr("GSTART 2");
@@ -380,7 +389,7 @@ else if ($user->stat == 'table') {
       log_wr("CIC".$loggo);
                          
       /* se era il suo turno e la carta era sua ed era in mano */
-      if ($a_play >=0 && $a_play < 40 &&
+      if ($a_play >=0 && $a_play < (BRISKIN5_PLAYERS_N == 5 ? 40 : 24) &&
          ($user->table_pos == (($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N)) &&
          $table->card[$a_play]->stat == 'hand' &&
          $table->card[$a_play]->owner == $user->table_pos) {
@@ -445,14 +454,20 @@ else if ($user->stat == 'table') {
        if ($table->turn == (BRISKIN5_PLAYERS_N * 8)) { /* game finished */
          log_wr(sprintf("GIOCO FINITO !!!"));
 
-          $plist = "$table->table_token|$user->table|$table->player_n";
-          $curtime = time();
-          log_legal($curtime, $user->sess, $user->name, "STAT:FINISH_GAME", $plist);
 
          /* ************************************************ */
          /*    PRIMA LA PARTE PER LO SHOW DI CHI HA VINTO    */
          /* ************************************************ */
-         calculate_points(&$table);
+         $pt_cur = calculate_points(&$table);
+
+          $plist = "$table->table_token|$user->table_orig|$table->player_n";
+          $curtime = time();
+          for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+            $user_cur = &$bri->user[$table->player[$i]];
+            $plist .= '|'.xcapelt($user_cur->name).'|'.$pt_cur[$i];
+          }
+          log_legal($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
+          log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist);
 
          $table->game_next();
          $table->game_init(&$bri->user);