X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Findex_wr.php;h=6c33bafecc7a33968569a4888977285a5163a96b;hb=8866b31f28b69c5dd2857960ddeea08bcb9725d5;hp=1dcb06e225551e2bc73f00b94e348c08bee579fd;hpb=c0343793fa79c053f3498a5b5eee1ef6ccb05d5e;p=brisk.git diff --git a/web/index_wr.php b/web/index_wr.php index 1dcb06e..6c33baf 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -46,8 +46,9 @@ $argz = explode('|', $mesg); if ($argz[0] == 'shutdown') { log_auth($user_cur->sess, "Shutdown session."); - + $tmp_sess = $user->sess; $user->sess = ""; + step_unproxy($tmp_sess); $user->name = ""; $user->the_end = FALSE; @@ -59,6 +60,11 @@ if ($argz[0] == 'shutdown') { else log_rd2($sess, "SHUTDOWN FROM WHAT ???"); } +/****************** + * * + * STAT: room * + * * + ******************/ else if ($user->stat == 'room') { $user->laccwr = time(); @@ -67,7 +73,7 @@ else if ($user->stat == 'room') { $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_help), 0, "torna ai tavoli", 600, 500); log_wr($sess, $user->comm[$user->step % COMM_N]); - $user->step++; + $user->step_inc(); } else if ($argz[0] == 'about') { @@ -75,100 +81,113 @@ else if ($user->stat == 'room') { $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_about), 0, "torna ai tavoli", 400, 200); log_wr($sess, $user->comm[$user->step % COMM_N]); - $user->step++; + $user->step_inc(); } - else if ($argz[0] == 'logout') { - $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();'); - $user->the_end = TRUE; - $user->step++; - } else if ($argz[0] == 'chatt') { $bri->chatt_send(&$user,$mesg); } - else if ($argz[0] == 'sitdown') { - if ($user->stat != 'room' || $user->subst != 'standup') { - log_wr($sess, "Warning ! sitdown out fsm"); - unlock_data($sem); - exit; - } - - if ($user->bantime > $user->laccwr) { - $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= show_notify("
Ti sei alzato da un tavolo senza il consenso degli altri giocatori. Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", 2000, "Torna in piedi.", 400, 100); - - $user->step++; - save_data($bri); - unlock_data($sem); - exit; - } + /********************** + * * + * SUBST: standup * + * * + **********************/ + else if ($user->subst == 'standup') { + + if ($argz[0] == 'sitdown') { + if ($user->the_end == TRUE) { + log_wr($sess, "INFO:SKIP:argz == sitdown && the_end == TRUE => ignore request."); + unlock_data($sem); + exit; + } + /* TODO: refact to a function */ + if ($user->bantime > $user->laccwr) { + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] .= show_notify("
Ti sei alzato da un tavolo senza il consenso degli altri giocatori. Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", 2000, "Torna in piedi.", 400, 100); + + $user->step_inc(); + save_data($bri); + unlock_data($sem); + exit; + } - // Take parameters - $table_idx = $argz[1]; - $table = &$bri->table[$table_idx]; + // Take parameters + $table_idx = $argz[1]; + $table = &$bri->table[$table_idx]; - if ($table->player_n == PLAYERS_N) { - log_wr($sess, "Warning ! unreachable, table full."); - unlock_data($sem); - exit; - } - - // set new status - $user->subst = "sitdown"; - $user->table = $table_idx; - $user->table_pos = $table->user_add($idx); - - if ($table->player_n == PLAYERS_N) { - // Start game for this table. - log_wr($sess, "Start game!"); + if ($table->player_n == PLAYERS_N) { + log_wr($sess, "WARN:FSM: Sitdown unreachable, table full."); + unlock_data($sem); + exit; + } + + // set new status + $user->subst = "sitdown"; + $user->table = $table_idx; + $user->table_pos = $table->user_add($idx); - $table->init(&$bri->user); - $table->game_init(&$bri->user); - $curtime = time(); - - for ($i = 0 ; $i < $table->player_n ; $i++) { - $user_cur = &$bri->user[$table->player[$i]]; - log_wr($sess, "Pre if!"); + if ($table->player_n == PLAYERS_N) { + // Start game for this table. + log_wr($sess, "Start game!"); - $ret = ""; - $ret .= sprintf('gst.st_loc++; gst.st=%d; the_end=true; window.onunload = null ; document.location.assign("table.php");|', $user_cur->step+1); + $table->init(&$bri->user); + $table->game_init(&$bri->user); + $curtime = time(); - $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->trans_step = $user_cur->step + 1; - log_wr($sess, "TRANS ATTIVATO"); - - $user_cur->stat = 'table'; - $user_cur->subst = 'asta'; - $user_cur->laccwr = $curtime; - $user_cur->step++; - - $user_cur->comm[$user_cur->step % COMM_N] = show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, FALSE); - $user_cur->step++; + for ($i = 0 ; $i < $table->player_n ; $i++) { + $user_cur = &$bri->user[$table->player[$i]]; + log_wr($sess, "Pre if!"); + + $ret = ""; + $ret .= sprintf('gst.st_loc++; gst.st=%d; the_end=true; window.onunload = null ; document.location.assign("table.php");|', $user_cur->step+1); + + $user_cur->comm[$user_cur->step % COMM_N] = $ret; + $user_cur->trans_step = $user_cur->step + 1; + log_wr($sess, "TRANS ATTIVATO"); + + + $user_cur->stat_set('table'); + $user_cur->subst = 'asta'; + $user_cur->laccwr = $curtime; + $user_cur->step_inc(); + + $user_cur->comm[$user_cur->step % COMM_N] = show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, FALSE); + $user_cur->step_inc(); + } } + + $bri->room_sitdown(&$user, $table_idx); + } + else if ($argz[0] == 'logout') { + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();'); + $user->the_end = TRUE; + $user->step_inc(); } - - $bri->room_sitdown(&$user, $table_idx); } - else if ($argz[0] == 'wakeup') { - if ($user->stat != 'room' || $user->subst != 'sitdown') { - log_wr($sess, "Warning ! wakeup out fsm."); - unlock_data($sem); - exit; + /********************** + * * + * SUBST: sitdown * + * * + **********************/ + else if ($user->subst == 'sitdown') { + if ($argz[0] == 'wakeup') { + $bri->room_wakeup(&$user); + } + else if ($argz[0] == 'logout') { + $bri->room_wakeup(&$user); + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();'); + $user->the_end = TRUE; + $user->step_inc(); } - - // set new status - - $user->subst = "standup"; - - $bri->room_wakeup(&$user); } } -/*************** - * * - * TABLE * - * * - ***************/ +/********************* + * * + * STAT: table * + * * + *********************/ else if ($user->stat == 'table') { $user->laccwr = time(); $table = &$bri->table[$user->table]; @@ -178,7 +197,7 @@ else if ($user->stat == 'table') { $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; $user->comm[$user->step % COMM_N] .= show_table_info(&$bri, &$table, $user->table_pos); log_wr($sess, $user->comm[$user->step % COMM_N]); - $user->step++; + $user->step_inc(); } else if ($argz[0] == 'chatt') { $bri->chatt_send(&$user,$mesg); @@ -196,11 +215,11 @@ else if ($user->stat == 'table') { $lockcalc = $table->exitlock_calc(&$bri->user, $user->table_pos); if ($lockcalc < 3) { $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= $table->exitlock_show(); + $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bri->user, $user->table_pos); $user->comm[$user->step % COMM_N] .= show_notify("
I dati presenti sul server non erano allineati con quelli inviati dal tuo browser, adesso lo sono. Riprova ora.", 2000, "Torna alla partita.", 400, 100); log_wr($sess, $user->comm[$user->step % COMM_N]); - $user->step++; + $user->step_inc(); $logout_cont = FALSE; } } @@ -220,11 +239,11 @@ else if ($user->stat == 'table') { } for ($i = 0 ; $i < PLAYERS_N ; $i++) { $ret = sprintf('gst.st = %d;', $user_cur[$i]->step+1); - $ret = sprintf('exitlock_show(%d, %s);', $ct, + $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($sess, $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N]); - $user_cur[$i]->step++; + $user_cur[$i]->step_inc(); } } else if ($user->subst == 'asta') { @@ -245,7 +264,7 @@ else if ($user->stat == 'table') { $ret = sprintf('gst.st = %d;', $user_cur->step+1); $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE); $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step++; + $user_cur->step_inc(); } } else if ($argz[0] == 'asta') { @@ -268,14 +287,11 @@ else if ($user->stat == 'table') { $again = FALSE; } else if ($a_card <= 9) { - if ($table->asta_card == 9) { - if ($a_card == 9 && $a_pnt <= 120 && $a_pnt > $table->asta_pnt) - $again = FALSE; - } - else { - if ($a_card >= 0 && $a_card <= 9 && $a_card > $table->asta_card) - $again = FALSE; - } + if ($a_card >= 0 && $a_card < 9 && $a_card > $table->asta_card) + $again = FALSE; + else if ($a_card == 9 && $a_pnt > ($table->asta_pnt >= 61 ? $table->asta_pnt : 60) && $a_pnt <= 120) + $again = FALSE; + if ($again == FALSE) { log_wr($sess, "NUOVI ORZI."); @@ -291,6 +307,11 @@ else if ($user->stat == 'table') { if ($again) { // Qualcosa non andato bene, rifare + $ret = sprintf('gst.st = %d; asta_pnt_set(%d);', $user->step+1, + ($table->asta_pnt > 60 ? $table->asta_pnt + 1 : 61) ); + $user->comm[$user->step % COMM_N] = $ret; + $user->step_inc(); + log_wr($sess, "Ripetere."); } else { @@ -335,7 +356,7 @@ else if ($user->stat == 'table') { $ret .= sprintf('dispose_asta(%d,%d, %s); remark_off();', $table->asta_card + 1, -($table->asta_pnt+1), ($user_cur->handpt <= 2 ? "true" : "false")); $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step++; + $user_cur->step_inc(); } } else if ($table->asta_pla_n == 0) { @@ -355,7 +376,7 @@ else if ($user->stat == 'table') { $ret = sprintf('gst.st = %d;', $user_cur->step+1); $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE); $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step++; + $user_cur->step_inc(); } } else { @@ -370,7 +391,7 @@ else if ($user->stat == 'table') { 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->step++; + $user->step_inc(); for ($i = 1 ; $i < PLAYERS_N ; $i++) { $chooser = ($table->gstart + $i) % PLAYERS_N; if ($table->asta_pla[$chooser]) { @@ -392,7 +413,7 @@ else if ($user->stat == 'table') { } $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step++; + $user_cur->step_inc(); } } } @@ -431,7 +452,7 @@ else if ($user->stat == 'table') { $ret .= "is_my_time = false; remark_off();"; $user_cur->comm[$user_cur->step % COMM_N] = $ret; - $user_cur->step++; + $user_cur->step_inc(); } /* TUTTE LE VARIABILI DI STATO PER PASSARE A GIOCARE E LE @@ -550,7 +571,7 @@ else if ($user->stat == 'table') { $user_cur = &$bri->user[$table->player[$i]]; $user_cur->comm[$user_cur->step % COMM_N] = $retar[$i]; - $user_cur->step++; + $user_cur->step_inc(); } log_wr($sess, sprintf("TURN: %d",$table->turn));