X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2Findex_wr.php;h=5045a54af7c61bfb28b7c7c96a8b59d9498e1e3a;hb=f6a01481a38713553a82314f845bf39fddaa998d;hp=a63b5da486196da59a81708e7c35d6a0d7c3fdc0;hpb=65aebe05fe1746e138532abbe287e411b4ec65e9;p=brisk.git diff --git a/web/briskin5/index_wr.php b/web/briskin5/index_wr.php index a63b5da..5045a54 100644 --- a/web/briskin5/index_wr.php +++ b/web/briskin5/index_wr.php @@ -2,7 +2,7 @@ /* * brisk - index_wr.php * - * Copyright (C) 2006-2008 Matteo Nastasi + * Copyright (C) 2006-2011 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -20,10 +20,11 @@ * not, write to the Free Software Foundation, Inc, 59 Temple Place - * Suite 330, Boston, MA 02111-1307, USA. * - * $Id$ - * */ + +$G_base = "../"; + require_once("../Obj/brisk.phh"); // require_once("../Obj/proxyscan.phh"); require_once("Obj/briskin5.phh"); @@ -49,6 +50,8 @@ log_wr('COMM: '.$mesg); if ($table_idx < 0 || $table_idx >= TABLE_N) exit; +log_mop(0, 'bin::index_wr.php: COMM: '.xcapemesg($mesg)); + $sem = Briskin5::lock_data($table_idx); if (($bri = &Briskin5::load_data($table_idx,$table_token)) == FALSE) { @@ -67,8 +70,9 @@ if (($user = &$bri->get_user($sess, &$idx)) == FALSE) { $argz = explode('|', $mesg); log_wr('POSTSPLIT: '.$argz[0]); +log_mop($user->step, 'bin::index_wr.php: after get_user()'); -if ($argz[0] == 'shutdown') { +if (false && $argz[0] == 'shutdown') { log_auth($user_cur->sess, "Shutdown session. delegate to room gc the autologout"); log_rd2("bin5/index_wr.php: AUTO LOGOUT."); @@ -99,6 +103,16 @@ else if ($user->stat == 'table') { else if ($argz[0] == 'chatt') { $bri->chatt_send(&$user,$mesg); } + else if ($argz[0] == 'preferences_update') { + GLOBAL $CO_bin5_pref_ring_endauct; + + log_wr("PER DI TABLEINFO"); + + if ($CO_bin5_pref_ring_endauct == "true") + $user->privflags |= BIN5_USER_FLAG_RING_ENDAUCT; + else + $user->privflags &= ~BIN5_USER_FLAG_RING_ENDAUCT; + } else if ($argz[0] == 'logout') { $remcalc = $argz[1]; @@ -132,19 +146,21 @@ else if ($user->stat == 'table') { } } 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') { @@ -153,7 +169,7 @@ else if ($user->stat == 'table') { log_wr(sprintf("GIOCO FINITO !!!")); - $table->mult *= 2; + $table->mult += 1; $table->old_reason = sprintf("Ha lasciato %s perché aveva al massimo 2 punti.", xcape($user->name)); $table->game_next(); @@ -266,7 +282,7 @@ else if ($user->stat == 'table') { log_wr(sprintf("GIOCO FINITO !!!")); $table->old_reason = "Hanno passato tutti."; - $table->mult *= 2; + $table->mult += 1; $table->game_next(); $table->game_init(&$bri->user); @@ -331,7 +347,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"); @@ -345,6 +361,11 @@ else if ($user->stat == 'table') { $user_cur->subst = 'game'; $ret = sprintf('gst.st = %d; subst = "game";', $user_cur->step+1); + if ($user_cur->privflags & BIN5_USER_FLAG_RING_ENDAUCT) { + // $ret .= "var de_che= 33;"; + $ret .= playsound("ringbell.mp3"); + } + $ret .= sprintf('document.title = "Brisk - Tavolo %d";', $user->table_orig); /* bg of caller cell */ $ret .= briscola_show($bri, $table, $user_cur); @@ -387,7 +408,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) { @@ -452,14 +473,32 @@ 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, "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(); + $ucodes = array(); + for ($i = 0 ; $i < BRISKIN5_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 < BRISKIN5_PLAYERS_N ; $i++) { + $plist .= '|'.xcapelt($ucodes[$i]); + } + log_legal($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist); + if ($user->table_orig < TABLES_AUTH_N) { + require_once("../Obj/dbase_".$G_dbasetype.".phh"); + + log_points($curtime, $user, "STAT:BRISKIN5:FINISH_GAME", $plist); + $bdb = new BriskDB(); + $bdb->bin5_points_save($curtime, $table->table_token, $user->table_orig, $ucodes, $pt_cur); + unset($bdb); + } $table->game_next(); $table->game_init(&$bri->user); @@ -491,6 +530,7 @@ else if ($user->stat == 'table') { } log_wr("before save data"); Briskin5::save_data($bri); +log_mop($user->step, 'bin::index_wr.php: after save_data()'); Briskin5::unlock_data($sem); exit;