From bba23fca78d918b22dbb183196da5e93ed5cb141 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 15 Mar 2017 22:56:55 +0100 Subject: [PATCH] removed temp. development settings, increased constraints for 'change rules', management of post-auction suit choice --- TODO.txt | 11 +++++--- web/briskin5/Obj/briskin5.phh | 52 +++++++++++++++++++++++++---------- web/briskin5/Obj/rules.phh | 6 ++++ web/briskin5/briskin5.js | 5 ++++ 4 files changed, 55 insertions(+), 19 deletions(-) diff --git a/TODO.txt b/TODO.txt index 1fc2572..266c4ff 100644 --- a/TODO.txt +++ b/TODO.txt @@ -25,10 +25,13 @@ DONE . check of max points DONE . check of suit at the end of bet - - select rules dropdown 'selected' to the current rule or the current - - increase constraint for rules change - - cache data structure for tournments - . reload on SIGHUP + DONE - increase constraint for rules change + DONE - select rules dropdown 'selected' to the current rule or the current + + POSTPONED - no points multiplication for abandon + POSTPONED - cache data structure for tournments + POSTPONED . reload on SIGHUP + WIP * inherited info * Users Network construction diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index d3066be..ecc34f6 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -32,9 +32,7 @@ define('BIN5_PROXY_PATH', PROXY_PATH."/bin5"); require_once('rules.phh'); -// FIXME: JUST FOR DEVELOP -// define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_NO_DRAW); -define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_TOGETHER17); +define('BIN5_TOURNAMENT_CURRENT', BIN5_TOURNAMENT_NO_DRAW); $mlang_bin5_bin5 = array( // br, hr, b, /b, win, fri @@ -132,7 +130,14 @@ function multoval($mult) function dom_select_rules() { - printf(""); + $ret = "\n"; + + echo "$ret"; } class Card { @@ -653,18 +658,26 @@ class Bin5_table extends Table { do { if ($this->match_id != -1) { + // FIXME_LANG $msg = sprintf("Stai già giocando la partita con codice %d.", $this->match_id); break; } + if ($this->asta_card != -1 || $this->asta_pla_n < BIN5_PLAYERS_N) { + // FIXME_LANG + $msg = sprintf("La partita è già stata avviata."); + break; + } + $rules_id = (int)$rules_id_s; - // FIXME: from dynamic rules list - if ($rules_id != 1 && $rules_id != 2 && $rules_id != 4) { + if (! in_array($rules_id, rules_keys())) { + // FIXME_LANG $msg = "queste regole non esistono o non sono attive"; break; } if ($user->rules_get() == $rules_id) { + // FIXME_LANG $msg = "hai già richiesto di usare queste regole"; break; } @@ -738,13 +751,20 @@ class Bin5_table extends Table { } while (FALSE); $dt = date("H:i ", $curtime); - for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { - if ($ret == FALSE && $this->player[$i] != $user->idx) - continue; - $user_cur = &$bri->user[$this->player[$i]]; - $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; "; - $user_cur->comm[$user_cur->step % COMM_N] .= nickserv_msg($dt, $msg); - $user_cur->step_inc(); + if ($ret == TRUE) { + for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { + $user_cur = &$bri->user[$this->player[$i]]; + $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; "; + $user_cur->comm[$user_cur->step % COMM_N] .= nickserv_msg($dt, $msg); + $user_cur->step_inc(); + } + } + else { + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] = xcape(sprintf("rules_set(%d);", + $this->rules->id)); + $user->comm[$user->step % COMM_N] .= nickserv_msg($dt, $msg); + $user->step_inc(); } } // end function rules_change } // end class Bin5_table @@ -1585,8 +1605,10 @@ function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again) $ret .= $table->exitlock_show(&$bri->user, $table_pos); if (!$is_again) { /* GENERAL STATUS */ - $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', - $sendstep, $user->stat, $user->subst, $table_pos); + $user_rules = $user->rules_get(); + $ret .= sprintf('gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d; rules_set(%d);', + $sendstep, $user->stat, $user->subst, $table_pos, + ($user_rules == BIN5_USER_CONTINUE_INIT ? $table->rules->id_get() : $user_rules)); log_rd(sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;', $sendstep, $user->stat, $user->subst, $table_pos)); diff --git a/web/briskin5/Obj/rules.phh b/web/briskin5/Obj/rules.phh index 9543975..37dbe58 100644 --- a/web/briskin5/Obj/rules.phh +++ b/web/briskin5/Obj/rules.phh @@ -39,6 +39,12 @@ require_once("rules_old_rules.phh"); require_once("rules_no_draw.phh"); require_once("rules_together17.phh"); +// FIXME - DYNAMIC WITH CACHE AND RELOAD FROM DB +function rules_keys() +{ + return array(1,2,4); +} + function rules_id2name($id) { if ($id == 1) diff --git a/web/briskin5/briskin5.js b/web/briskin5/briskin5.js index 91fe98f..4b29178 100644 --- a/web/briskin5/briskin5.js +++ b/web/briskin5/briskin5.js @@ -358,3 +358,8 @@ function act_select_rules(rule_id) { send_mesg("chatt|/rules " + rule_id); } + +function rules_set(id) +{ + $('select_rules').value = id; +} -- 2.17.1