game description grand refactoring
[brisk.git] / web / briskin5 / index_wr.php
index 6fdf64d..c44834c 100644 (file)
@@ -209,7 +209,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
 
                 /* $table->game_init(&$bri->user); */
 
-                if ($table->rules_engine(&$bri, BIN5_RULES_ABANDON, $user)) {
+                if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_ABANDON, $user)) {
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                         $user_cur = &$bri->user[$table->player[$i]];
 
@@ -315,7 +315,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         else if ($table->asta_pla_n == 0) {
                             log_wr("PASSANO TUTTI!");
 
-                            if ($table->rules_engine(&$bri, BIN5_RULES_ALLPASS, $user)) {
+                            if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_ALLPASS, $user)) {
                                 for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                                     $user_cur = &$bri->user[$table->player[$i]];
 
@@ -438,7 +438,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                 log_wr("CIC".$loggo);
 
                 /* se era il suo turno e la carta era sua ed era in mano */
-                if ($a_play >=0 && $a_play < (BIN5_PLAYERS_N == 5 ? 40 : 24) &&
+                if ($a_play >=0 && $a_play < (BIN5_CARD_HAND * BIN5_PLAYERS_N) &&
                     ($user->table_pos == (($table->gstart + $table->turn) % BIN5_PLAYERS_N)) &&
                     $table->card[$a_play]->stat == 'hand' &&
                     $table->card[$a_play]->owner == $user->table_pos) {
@@ -462,7 +462,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         $player_nex = $card_play . "is_my_time = true; remark_on();";
                         $player_oth = $card_play;
                     }
-                    else if ($table->turn <= (BIN5_PLAYERS_N * 8)) { /* manche finished */
+                    else if ($table->turn <= (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* manche finished */
                         $winner = calculate_winner($table);
                         log_wr("GSTART 3");
                         $table->gstart = $winner;
@@ -475,7 +475,7 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                             $player_nex = $card_play . $card_take;
                         else
                             $player_nex = "";
-                        if ($table->turn < (BIN5_PLAYERS_N * 8))  /* game NOT finished */
+                        if ($table->turn < (BIN5_PLAYERS_N * BIN5_CARD_HAND))  /* game NOT finished */
                             $player_nex .= "is_my_time = true; remark_on();";
                         $player_oth = $card_play . $card_take;
                     }
@@ -500,43 +500,10 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         $retar[$i] = $ret;
                     }
 
-                    if ($table->turn == (BIN5_PLAYERS_N * 8)) { /* game finished */
+                    if ($table->turn == (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* game finished */
                         log_wr(sprintf("GIOCO FINITO !!!"));
 
-
-                        /* ************************************************ */
-                        /*    PRIMA LA PARTE PER LO SHOW DI CHI HA VINTO    */
-                        /* ************************************************ */
-                        /* $pt_cur = calculate_points(&$table); */
-                        /* $table->game_next(1); */
-
-                        /* $plist = "$table->table_token|$user->table_orig|$table->player_n"; */
-                        /* $ucodes = array(); */
-                        /* for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { */
-                        /*     $user_cur = &$bri->user[$table->player[$i]]; */
-                        /*     $plist .= '|'.xcapelt($user_cur->name).'|'.$pt_cur[$i]; */
-                        /*     $ucodes[$i] = $user_cur->code_get(); */
-                        /* } */
-                        /* for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { */
-                        /*     $plist .= '|'.xcapelt($ucodes[$i]); */
-                        /* } */
-                        /* log_legal($curtime, $user->ip, $user, "STAT:BRISKIN5:FINISH_GAME", $plist); */
-                        /* if ($user->table_orig < TABLES_AUTH_N) { */
-                        /*     require_once("../Obj/dbase_".$G_dbasetype.".phh"); */
-
-                        /*     if (($bdb = BriskDB::create()) != FALSE) { */
-                        /*         $bdb->bin5_points_save($curtime, $table, $user->table_orig, $ucodes, $pt_cur); */
-                        /*         unset($bdb); */
-                        /*     } */
-                        /*     else { */
-                        /*         log_points($remote_addr, $curtime, $user, "STAT:BRISKIN5:FINISH_GAME", "DATABASE CONNECTION FAILED"); */
-                        /*     } */
-                        /*     log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist); */
-                        /* } */
-
-                        /* $table->game_init(&$bri->user); */
-
-                        if ($table->rules_engine(&$bri, BIN5_RULES_FINISH, $user)) {
+                        if ($table->rules_engine(&$bri, $curtime, BIN5_RULES_FINISH, $user)) {
                             for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                                 $user_cur = &$bri->user[$table->player[$i]];
                                 $retar[$i] .= show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, TRUE);
@@ -544,7 +511,6 @@ function bin5_index_wr_main(&$bri, $remote_addr_full, $get, $post, $cookie)
                         }
                     }
 
-
                     for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
                         $user_cur = &$bri->user[$table->player[$i]];