*
*/
-define( FTOK_PATH, "/var/lib/brisk");
+define(FTOK_PATH, "/var/lib/brisk");
+define(LEGAL_PATH, "/tmp/legal_brisk");
define(TABLES_N, 8);
define(PLAYERS_N, 3);
define(MAX_POINTS, 5);
define(STREAM_TIMEOUT, 20);
define(EXPIRE_TIME_RD, 180);
define(EXPIRE_TIME_SMAMMA, 360);
+// BAN_TIME da allineare anche in commons.js
+define(BAN_TIME, 900);
define(GARBAGE_TIMEOUT, 10);
define(NICKSERV, "<i>SERVER</i>");
define(BRISK_DEBUG, FALSE);
// define(DEBUGGING, "local");
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "0.4.6";
+$G_brisk_version = "0.6.2";
-$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.').',
+$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: "donate" e piccole rifiniture.',
'Se vuoi iscriverti alla <a target="_blank" href="http://www.milug.org/cgi-bin/mailman/listinfo/ml-briscola">Mailing List</a>, cliccala!' );
-$table_wellarr = Array ( 'Benvenuto al tavolo.');
+$table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.');
$G_room_help= '
<b>Descrizione</b><br>
Questa è un\'implementazione della briscola in cinque, così come è spiegata su
<a target=\\"_blank\\" href=\\"http://it.wikipedia.org/wiki/Briscola#Gioco_a_5\\">Wikipedia</a>; in breve è la variante con l\'asta prima sulla carta e poi sui punti.<br><br>
+<b>Configurazione del browser.</b><br>
+Occorre abilitare i cookies.<br>
+Se usate Internet Explorer dovete anche settare: strumenti->cronologia_esplorazioni->impostazioni ad \\"apertura alla pagina web\\".<br>
+<br>
<b>Uso del sito</b><br>
Potete sedervi a un tavolo o rimanere in piedi.<br>
Se al vostro tavolo si raggiungono i 5 giocatori inizia automaticamente la partita.<br>
All\'inizio vengono distribuite le carte e parte l\'asta; per partecipare all\'asta, quando sarà il vostro turno, potrete scegliere se andare avanti o passare cliccando sulle icone corrispondenti. Se si arriva ai punti, scrivete nella textbox il vostro rilancio e cliccate PUNTI.<br><br>
Chi vince l\'asta dovrà decidere il seme della carta scelta e inizierà la mano.<br>
Per giocare le carte dovrete trascinarle nel quadrato al centro del vostro schermo.<br><br>
-Il vostro turno è sempre segnalato da una cornice verde lampeggiante intorno quadrato al centro del vostro schermo.<br><br>
+Il vostro turno è sempre segnalato da una cornice verde lampeggiante intorno al quadrato al centro del vostro schermo.<br><br>
Durante la partita, se vorrete ricaricare la pagina, usate l\'apposito bottone \\"reload\\" in basso a destra.<br>
+Dopo che è iniziata una partita per uscirne dovete chiedere agli altri giocatori di sbloccarla cliccando sul lucchetto. Se non si segue questa prassi, una volta usciti, non vi potrete sedere a nessun tavolo per '.floor(BAN_TIME/60).' minuti.
<dl>
<dt><b>Comandi della chat</b>
<dd><b>/nick <i><nuovo_nickname></i></b> - cambio di nickname
$ret = array();
for ($i = 0 ; $i < 40 ; $i++) {
- $ret[$i] = new Card($i, 'bunch', 'no_owner');
+ $ret[$i] =& new Card($i, 'bunch', 'no_owner');
}
- return ($ret);
+ $oret = &$ret;
+ return ($oret);
}
function bunch_make()
var $sess; // session of the user
var $lacc; // last access (for the cleanup)
var $laccwr; // last access (for the cleanup)
+ var $bantime; // timeout to temporary ban
var $stat; // status (outdoor, room, table, game, ...)
var $subst; // substatus for each status
var $step; // step of the current status
$this->sess = $sess;
$this->lacc = time();
$this->laccwr = time();
+ $this->bantime = 0;
$this->stat = $stat;
$this->subst = $subst;
$this->step = 1;
$this->user = array();
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $this->user[$i] = new User("", "");
+ $this->user[$i] =& new User("", "");
}
for ($i = 0 ; $i < TABLES_N ; $i++)
- $this->table[$i] = new Table();
+ $this->table[$i] =& new Table();
$this->garbage_timeout = 0;
}
log_rd2($user_cur->sess, "AUTO LOGOUT.");
if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
- $this->room_wakeu
-p(&$user_cur);
+ $this->room_wakeup(&$user_cur);
else if ($user_cur->subst == 'standup')
$this->room_outstandup(&$user_cur);
else
$from_table = ($user->stat == "table");
if ($from_table) {
log_main("WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
- $lockcalc = $table->exitlock_calc(&$this->user, $table_pos);
- if ($lockcalc < 3) {
- // BAN TEMP!
-asdasdasdas
- }
for ($i = 0 ; $i < $table->player_n ; $i++) {
$user_cur = &$this->user[$table->player[$i]];
$user_mesg = substr($mesg,6);
- $dt = date("H:i ",time());
+ $timecur = time();
+
+ $dt = date("H:i ", $timecur);
if (strncmp($user_mesg, "/nick ", 6) == 0) {
log_main($user->sess, "chatt_send BEGIN");
$dt.xcape($user->name), xcape($user_mesg));
$user_cur->step++;
}
+ log_legal($timecur, $user->sess, $user->name,
+ ($user->stat == 'room' ? 'room' : 'table '.$user->table),$user_mesg);
}
}
if (strcmp($sess, $this->user[$i]->sess) == 0) {
// find it
$idx = $i;
- return ($this->user[$i]);
+ $ret = &$this->user[$i];
+ return ($ret);
}
}
log_main($sess, sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
if ($idx != -1 && $i == MAX_PLAYERS) {
/* SUCCESS */
+ $curtime = time();
if ($sess == "") {
$this->user[$idx]->sess = uniqid("");
$sess = $this->user[$idx]->sess;
$this->user[$idx]->name = $name_new;
$this->user[$idx]->stat = "room";
$this->user[$idx]->subst = "standup";
- $this->user[$idx]->laccwr = time();
+ $this->user[$idx]->lacc = $curtime;
+ $this->user[$idx]->laccwr = $curtime;
+ $this->user[$idx]->bantime = 0;
log_main("XXX", sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
fclose($fp);
}
+function log_legal($timecur, $sess, $name, $where, $mesg)
+{
+ GLOBAL $_SERVER;
+
+ $fp = fopen(LEGAL_PATH, 'a');
+ /* Unix time | session | nickname | IP | where was | mesg */
+ fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|\n", $timecur, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
+ fclose($fp);
+}
+
+
+
function init_data()
{
- $brisco = new brisco();
+ $brisco =& new brisco();
return $brisco;
}
shm_detach($shm);
- return ($bri);
+ $ret = &$bri;
+ return ($ret);
}
return (NULL);
return (sprintf('playsound("flasou", "%s");', $filename));
}
+function secstoword($secs)
+{
+ $mins = floor($secs / 60);
+ $secs = $secs % 60;
+ if ($mins > 0)
+ $ret = sprintf("%d minut%s%s", $mins, ($mins > 1 ? "i" : "o"), ($secs > 0 ? " e " : ""));
+
+ if ($secs > 0)
+ $ret .= sprintf("%d second%s", $secs, ($secs > 1 ? "i" : "o"));
+
+ return ($ret);
+}
+
?>