- }
- else if ($user->subst == 'game') {
- log_wr($sess, "state: table::game".$argz[0]);
-
- if ($argz[0] == 'play') {
- $a_play = $argz[1];
- $a_x = $argz[2];
- $a_y = $argz[3];
-
- if (strpos($a_x, "px") != FALSE)
- $a_x = substr($a_x,0,-2);
- if (strpos($a_y, "px") != FALSE)
- $a_y = substr($a_y,0,-2);
-
- $loggo = sprintf("A_play %s, table_pos %d == %d, mazzo %d, gstart %d, card_stat %d, card_own %d",
- $a_play, $user->table_pos, ($table->gstart % PLAYERS_N),
- $table->mazzo, $table->gstart,
- $table->card[$a_play]->stat, $table->card[$a_play]->owner);
- log_wr($sess, "CIC".$loggo);
-
- /* se era il suo turno e la carta era sua ed era in mano */
- if ($a_play >=0 && $a_play < 40 &&
- ($user->table_pos == (($table->gstart + $table->turn) % PLAYERS_N)) &&
- $table->card[$a_play]->stat == 'hand' &&
- $table->card[$a_play]->owner == $user->table_pos) {
- log_wr($sess, sprintf("User: %s Play: %d",$user->name, $a_play));
-
- /* Change the card status. */
- $table->card[$a_play]->play($a_x, $a_y);
-
- /*
- * !!!! TURN INCREMENTED BEFORE !!!!
- */
- $turn_cur = ($table->gstart + $table->turn) % PLAYERS_N;
- $table->turn++;
-
- $card_play = sprintf("card_play(%d,%d,%d,%d);|",
- $user->table_pos, $a_play, $a_x, $a_y);
- if (($table->turn % PLAYERS_N) != 0) { /* manche not finished */
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- $player_cur = "remark_off();";
- $player_nex = $card_play . "is_my_time = true; remark_on();";
- $player_oth = $card_play;
- }
- else if ($table->turn <= (PLAYERS_N * 8)) { /* manche finished */
- $winner = calculate_winner($table);
- log_wr($sess,"GSTART 3");
- $table->gstart = $winner;
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- log_wr($sess, sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name));
- $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|cards_hidetake($d);",
- $winner, $winner);
- $player_cur = "remark_off();" . $card_take . "|";
- if ($turn_cur != $turn_nex)
- $player_nex = $card_play . $card_take . "|";
- else
- $player_nex = "";
- if ($table->turn < (PLAYERS_N * 8)) /* game NOT finished */
- $player_nex .= "is_my_time = true; remark_on();";
- $player_oth = $card_play . $card_take;
- }
-
- log_wr($sess, sprintf("Turn Cur %d Turn Nex %d",$turn_cur, $turn_nex));
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $ret = sprintf('gst.st = %d; ', $user_cur->step+1);
-
-
- if ($i == $turn_cur) {
- $ret .= $player_cur;
- }
- if ($i == $turn_nex) {
- $ret .= $player_nex;
- }
- if ($i != $turn_cur && $i != $turn_nex) {
- $ret .= $player_oth;
- }
-
- $retar[$i] = $ret;
- }
-
-
-
-
- if ($table->turn == (PLAYERS_N * 8)) { /* game finished */
- log_wr($sess, sprintf("GIOCO FINITO !!!"));
-
- /* ************************************************ */
- /* PRIMA LA PARTE PER LO SHOW DI CHI HA VINTO */
- /* ************************************************ */
- calculate_points(&$table);
-
- $table->game_next();
- $table->game_init(&$bri->user);
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $retar[$i] .= show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, TRUE);
- }
- }
-
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $user_cur->comm[$user_cur->step % COMM_N] = $retar[$i];
- $user_cur->step++;
- }
-
- log_wr($sess, sprintf("TURN: %d",$table->turn));
- /* Have played all the players ? */
- /* NO: switch the focus and enable the next player to play. */
+ /******************
+ * *
+ * STAT: room *
+ * *
+ ******************/
+ else if ($user->stat == 'room') {
+ $user->laccwr = time();
+
+ if ($argz[0] == 'help') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_help[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 600, 500);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'passwdhowto') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_passwdhowto[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 600, 500);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'splash') {
+ GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
+ GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= show_notify_ex(str_replace("\n", " ", $G_splash_content[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], $G_splash_w, $G_splash_h, true, 0);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+ }
+ else if ($argz[0] == 'about') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_about[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+
+ else if ($argz[0] == 'placing') {
+
+ require_once("briskin5/Obj/briskin5.phh");
+ require_once("briskin5/Obj/placing.phh");
+
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify_ex(str_replace("\n", " ", placings_show($user)), 0, $mlang_indwr['btn_backtotab'][$G_lang], 800, 600, TRUE, 0);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+
+ }
+
+
+ else if ($argz[0] == 'roadmap') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_roadmap[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'whysupport') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_whysupport[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'chatt') {
+ $room->chatt_send(&$user, xcapemesg($mesg));
+ }
+ /**********************
+ * *
+ * SUBST: standup *
+ * *
+ **********************/
+ else if ($user->subst == 'standup') {
+
+ if ($argz[0] == 'sitdown') {
+ log_wr("SITDOWN command");
+
+ if ($user->the_end == TRUE) {
+ log_wr("INFO:SKIP:argz == sitdown && ->the_end == TRUE => ignore request.");
+ return FALSE;
+ }
+
+ // Take parameters
+ $table_idx = (int)$argz[1];
+ $table = &$room->table[$table_idx];
+
+ if ($G_shutdown || $table->wakeup_time > $curtime ||
+ ($table->auth_only && (($user->flags & USER_FLAG_AUTH) == 0)) ) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ /* MLANG: "<b>Il server sta per essere riavviato, non possono avere inizio nuove partite.</b>", "<b>Il tavolo a cui volevi sederti richiede autentifica.</b>", "<b>Il tavolo si è appena liberato, ci si potrà sedere tra %d secondi.</b>" */
+ if ($G_shutdown) {
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['shutmsg'][$G_lang]);
+ }
+ else if ($table->auth_only && (($user->flags & USER_FLAG_AUTH) == 0)) {
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mustauth'][$G_lang]);
+ }
+ else {
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, 0, "%s"],"%s%d%s");', $dt, NICKSERV, $mlang_indwr['tabwait_a'][$G_lang], $table->wakeup_time - $curtime, $mlang_indwr['tabwait_b'][$G_lang]);
+ }
+ $user->step_inc();
+ return TRUE;
+ }
+
+ /* TODO: refact to a function */
+ // if ($user->bantime > $user->laccwr) {
+ require_once("Obj/hardban.phh");
+
+ if (($bantime = Hardbans::check(($user->flags & USER_FLAG_AUTH ? $user->name : FALSE),
+ $user->ip, $user->sess)) != -1) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ /* MLANG: "<br>Ti sei alzato da un tavolo senza il consenso degli altri giocatori. <br><br>Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", "resta in piedi.", "<br>Tu o qualcuno col tuo stesso indirizzo IP si è alzato da un tavolo senza il consenso degli altri giocatori.<br><br>Dovrai aspettare ancora ".secstoword($bantime - $user->laccwr)." prima di poterti sedere nuovamente.<br><br>Se non sei stato tu ad alzarti e possiedi un login con password, autenticandoti con quello, potrai accedere." */
+ if ($user->flags & USER_FLAG_AUTH) {
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['badwake_a'][$G_lang].secstoword($user->bantime - $user->laccwr).$mlang_indwr['badwake_b'][$G_lang], 2000, $mlang_indwr['btn_stays'][$G_lang], 400, 100);
+ }
+ else {
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['badsit_a'][$G_lang].secstoword($bantime - $user->laccwr).$mlang_indwr['badsit_a'][$G_lang], 2000, $mlang_indwr['btn_stays'][$G_lang], 400, 180);
+ }
+ $user->step_inc();
+ return TRUE;
+ }
+
+ if ($table->player_n == PLAYERS_N) {
+ log_wr("WARN:FSM: Sitdown unreachable, table full.");
+ return FALSE;
+ }