From 648e67ab39b09ae4a82fe2548a6c63154b61e901 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 1 Mar 2017 18:42:15 +0100 Subject: [PATCH] add 'rules_change' functionality --- TODO.txt | 6 ++++++ web/briskin5/Obj/briskin5.phh | 37 +++++++++++++++++++++++------------ web/briskin5/Obj/rules.phh | 24 +++++++++++++++++++++++ web/briskin5/briskin5.js | 5 +++++ web/briskin5/index.php | 5 +++++ 5 files changed, 65 insertions(+), 12 deletions(-) diff --git a/TODO.txt b/TODO.txt index ce58d46..d37f4ba 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,12 @@ BUGS | ------+ + - cache data structure for tournments + . reload on SIGHUP + - new rules for 'together for fun' turnment + - select tournment dropdown menu (send a 'cont' like message for each change) + - show current rules + DONE - Not sequence of 3 same chars DONE . check server side with test DONE - Global vars checker diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index faf8c1b..51ff38a 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -114,16 +114,6 @@ $mlang_bin5_bin5 = array( $table_wellarr = Array( 'it' => 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.'), 'en' => Array ( 'EN 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.') ); -function rules_id2name($id) -{ - if ($id == 1) - return 'Rules_old_rules'; - else if ($id == 2) - return 'Rules_no_draw'; - - return 'Rules_unknown'; -} - function multoval($mult) { GLOBAL $G_lang; @@ -138,6 +128,10 @@ function multoval($mult) return (sprintf(($G_lang == 'en' ? "%d-ple" : "%d-plo"), $mult)); } +function dom_select_rules() +{ + printf(""); +} class Card { var $value; /* 0 - 39 card value */ @@ -738,7 +732,7 @@ class Bin5_table extends Table { /* reload of the page with the new layout */ for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) { $user_cur = &$bri->user[$this->player[$i]]; - $user_cur->continue_set(BIN5_USER_CONTINUE_ALREADY); + $user_cur->continue_set(BIN5_USER_CONTINUE_INIT); $user_cur->trans_step = $user_cur->step + 1; $user_cur->comm[$user_cur->step % COMM_N] = sprintf('gst.st_loc++; gst.st=%d; xstm.stop(); window.onunload = null ; window.onbeforeunload = null ; document.location.assign("index.php");|', $user_cur->step+1); @@ -774,6 +768,7 @@ class Bin5_table extends Table { define('BIN5_USER_FLAG_RING_ENDAUCT', 0x01); define('BIN5_USER_CONTINUE_INIT', -1); +define('BIN5_USER_RULES_INIT', -1); class Bin5_user extends User { var $asta_card; // var $asta_pnt; // @@ -782,7 +777,7 @@ class Bin5_user extends User { var $privflags; // Flags for briskin5 only var $continue; // Id of the match that the user would continue - + var $rules; // Id of rules required by user const BASE = "../"; function User() { @@ -799,6 +794,7 @@ class Bin5_user extends User { $thiz->exitislock = TRUE; $thiz->privflags = 0; $thiz->continue = BIN5_USER_CONTINUE_INIT; + $thiz->rules = BIN5_USER_RULES_INIT; return ($thiz); } @@ -819,6 +815,7 @@ class Bin5_user extends User { $this->exitislock = $from->exitislock; $this->privflags = $from->privflags; $this->continue = $from->continue; + $this->rules = $from->rules; } /* CLONE NOT USED @@ -854,6 +851,7 @@ class Bin5_user extends User { $thiz->handpt = -1; $thiz->exitislock = TRUE; $thiz->continue = BIN5_USER_CONTINUE_INIT; + $thiz->rules = BIN5_USER_RULES_INIT; log_wr("Bin5 constructor"); @@ -1100,6 +1098,15 @@ class Bin5_user extends User { return ($this->continue); } + function rules_set($rules_id) + { + $this->rules = $rules_id; + } + + function rules_get() { + return ($this->rules); + } + } // end class Bin5_user @@ -1345,6 +1352,12 @@ class Bin5 { $match_id = substr($user_mesg, 6); $table->match_continue($this, $user, $match_id); } + else if (strncmp($user_mesg, "/rules ", 7) == 0) { + log_main($user->sess." chatt_send BEGIN"); + + $rules_id = substr($user_mesg, 7); + $table->rules_change($this, $user, $rules_id); + } else { for ($i = 0 ; $i < ($user->stat == 'room' ? BIN5_MAX_PLAYERS : BIN5_PLAYERS_N) ; $i++) { if ($user->stat == 'room') { diff --git a/web/briskin5/Obj/rules.phh b/web/briskin5/Obj/rules.phh index f9a825f..4b14773 100644 --- a/web/briskin5/Obj/rules.phh +++ b/web/briskin5/Obj/rules.phh @@ -34,6 +34,30 @@ define('BIN5_RULES_ASTA', 3); require_once("rules_base.phh"); require_once("rules_old_rules.phh"); require_once("rules_no_draw.phh"); +require_once("rules_together17.phh"); +function rules_id2name($id) +{ + if ($id == 1) + return 'Rules_old_rules'; + else if ($id == 2) + return 'Rules_no_draw'; + else if ($id == 4) + return 'Rules_together17'; + + return 'Rules_unknown'; +} + +function rules_id2descr($id) +{ + if ($id == 1) + return 'regole vecchie con pareggio'; + else if ($id == 2) + return 'regole nuove senza pareggio'; + else if ($id == 4) + return 'regole del torneo "insieme per gioco"'; + + return 'Regole sconosciute'; +} ?> \ No newline at end of file diff --git a/web/briskin5/briskin5.js b/web/briskin5/briskin5.js index f67dd49..59acd54 100644 --- a/web/briskin5/briskin5.js +++ b/web/briskin5/briskin5.js @@ -353,3 +353,8 @@ function preferences_showhide() else $('preferences').style.visibility = 'hidden'; } + +function act_select_rules(rule_id) +{ + send_mesg("/rules " + rule_id); +} diff --git a/web/briskin5/index.php b/web/briskin5/index.php index 80bc798..deeeba5 100644 --- a/web/briskin5/index.php +++ b/web/briskin5/index.php @@ -117,6 +117,8 @@ window.onload = function() { window.onunload = onunload_cb; xstm.start(); + + addEvent($('select_rules'), "change", function() { act_select_rules(this.value); } ); // FIXME: add this setTimeout(preload_images into data stream to avoid // race on opened socket // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); @@ -301,6 +303,9 @@ window.onload = function() {


+
+ +
-- 2.17.1