CONFIG_FILE="$HOME/.brisk_install"
apache_conf="/etc/apache2/sites-available/default"
+card_hand=3
players_n=3
tables_n=44
tables_auth_n=12
echo "$1 -h"
echo "$1 chk - run lintian on all ph* files."
echo "$1 pkg - build brisk packages."
- echo "$1 [-W] [-n 3|5] [-t <(n>=4)>] [-T <auth_tab>] [-A <apache-conf>] [-a <auth_file_name>] [-f <conffile>] [-p <outconf>] [-U <usock_path>] [-u <sys_user>] [-d <TRUE|FALSE>] [-w <web_dir>] [-k <ftok_dir>] [-l <legal_path>] [-y <proxy_path>] [-P <prefix_path>]"
+ echo "$1 [-W] [-n 3|5] [-c 3|8] [-t <(n>=4)>] [-T <auth_tab>] [-A <apache-conf>] [-a <auth_file_name>] [-f <conffile>] [-p <outconf>] [-U <usock_path>] [-u <sys_user>] [-d <TRUE|FALSE>] [-w <web_dir>] [-k <ftok_dir>] [-l <legal_path>] [-y <proxy_path>] [-P <prefix_path>]"
echo " -h this help"
echo " -f use this config file"
echo " -p save preferences in the file"
echo " -W web files only"
echo " -A apache_conf - def. $apache_conf"
+ echo " -c number cards in hand - def. $card_hand"
echo " -n number of players - def. $players_n"
echo " -t number of tables - def. $tables_n"
echo " -T number of auth-only tables - def. $tables_auth_n"
-A*) apache_conf="$(get_param "-A" "$1" "$2")"; sh=$?;;
-f*) conffile="$(get_param "-f" "$1" "$2")"; sh=$?;;
-p*) outconf="$(get_param "-p" "$1" "$2")"; sh=$?;;
+ -c*) card_hand="$(get_param "-c" "$1" "$2")"; sh=$?;;
-n*) players_n="$(get_param "-n" "$1" "$2")"; sh=$?;;
-t*) tables_n="$(get_param "-t" "$1" "$2")"; sh=$?;;
-T*) tables_auth_n="$(get_param "-T" "$1" "$2")"; sh=$?;;
#
echo " outconf: \"$outconf\""
echo " apache_conf:\"$apache_conf\""
+echo " card_hand: $card_hand"
echo " players_n: $players_n"
-echo " tables_n: $tables_n"
+echo " tables_n: $tables_n"
echo " tables_auth_n: $tables_auth_n"
echo " brisk_auth_conf: \"$brisk_auth_conf\""
echo " brisk_debug:\"$brisk_debug\""
echo "# Produced automatically by brisk::INSTALL.sh"
echo "#"
echo "apache_conf=$apache_conf"
+ echo "card_hand=$card_hand"
echo "players_n=$players_n"
echo "tables_n=$tables_n"
echo "tables_auth_n=$tables_auth_n"
#
ftokk_path="${ftok_path}k"
+if [ $card_hand -lt 3 -o $card_hand -gt 8 ]; then
+ echo "card_hand ($card_hand) out of range (3 <= c <= 8)"
+ exit 1
+fi
+
if [ $players_n -ne 3 -a $players_n -ne 5 ]; then
echo "players_n ($players_n) out of range (3|5)"
exit 1
fi
# .js substitutions
+sed -i "s/CARD_HAND *= *[0-9]\+/CARD_HAND = $card_hand/g" $(find ${web_path}__ -type f -name '*.js' -exec grep -l 'CARD_HAND *= *[0-9]\+' {} \;)
sed -i "s/PLAYERS_N *= *[0-9]\+/PLAYERS_N = $players_n/g" $(find ${web_path}__ -type f -name '*.js' -exec grep -l 'PLAYERS_N *= *[0-9]\+' {} \;)
sed -i "s/^var G_send_time *= *[0-9]\+/var G_send_time = $send_time/g" $(find ${web_path}__ -type f -name '*.js' -exec grep -l '^var G_send_time *= *[0-9]\+' {} \;)
# .ph[pho] substitutions
sed -i "s/define *( *'PLAYERS_N', *[0-9]\+ *)/define('PLAYERS_N', $players_n)/g" $(find ${web_path}__ -type f -name '*.ph*' -exec grep -l "define *( *'PLAYERS_N', *[0-9]\+ *)" {} \;)
+sed -i "s/define *( *'BIN5_CARD_HAND', *[0-9]\+ *)/define('BIN5_CARD_HAND', $card_hand)/g" $(find ${web_path}__ -type f -name '*.ph*' -exec grep -l "define *( *'BIN5_CARD_HAND', *[0-9]\+ *)" {} \;)
+
sed -i "s/define *( *'BIN5_PLAYERS_N', *[0-9]\+ *)/define('BIN5_PLAYERS_N', $players_n)/g" $(find ${web_path}__ -type f -name '*.ph*' -exec grep -l "define *( *'BIN5_PLAYERS_N', *[0-9]\+ *)" {} \;)
sed -i "s@define *( *'FTOK_PATH',[^)]*)@define('FTOK_PATH', \"$ftok_path\")@g" $(find ${web_path}__ -type f -name '*.ph*' -exec grep -l "define *( *'FTOK_PATH',[^)]*)" {} \;)
*
*/
define('BIN5_PLAYERS_N', 3);
+define('BIN5_CARD_HAND', 3); // normal value 8
define('BIN5_MAX_PLAYERS', BIN5_PLAYERS_N);
// define(BIN5_SHM_MIN', (50000 * BIN5_MAX_PLAYERS));
define('BIN5_SHM_MIN', 32768);
// {
// $ret = array();
//
- // for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
- // // for ($i = 0 ; $i < 40 ; $i++) {
+ // for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
+ // // for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
// $ret[$i] =& new Card($i, 'bunch', 'no_owner');
// }
//
{
$ret = array();
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
$this->card[$i] = new Card($i, 'bunch', 'no_owner');
}
}
mt_srand(make_seed());
- for ($i = (BIN5_PLAYERS_N == 5 ? 40 : 24) - 1 ; $i >= 0 ; $i--)
+ for ($i = (BIN5_CARD_HAND * BIN5_PLAYERS_N) - 1 ; $i >= 0 ; $i--)
$rest[$i] = $i;
- for ($i = (BIN5_PLAYERS_N == 5 ? 40 : 24) - 1 ; $i >= 0 ; $i--) {
+ for ($i = (BIN5_CARD_HAND * BIN5_PLAYERS_N) - 1 ; $i >= 0 ; $i--) {
$rn = rand(0, $i);
if ($rn == 0)
$tot = 0;
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
// for ($i = 0 ; $i < 40 ; $i++) {
if ($this->card[$i]->owner != $idx)
continue;
$this->old_reason = "";
// count points for the temporary 2 teams
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
$ctt = $this->card[$i]->value % 10;
$own = $this->card[$i]->owner;
if ($own == $this->asta_win || $own == $this->friend)
$table->old_mult = $table->mult;
// count points for the temporary 2 teams
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
// for ($i = 0 ; $i < 40 ; $i++) {
$ctt = $table->card[$i]->value % 10;
$own = $table->card[$i]->owner;
if ($is_transition) { // && $user->subst == "asta" superfluo
$ret .= "|";
- for ($i = 0 ; $i < 8 ; $i++) {
+ for ($i = 0 ; $i < BIN5_CARD_HAND ; $i++) {
for ($e = 0 ; $e < BIN5_PLAYERS_N ; $e++) {
$ct = 0;
- for ($o = 0 ; $o < (BIN5_PLAYERS_N == 5 ? 40 : 24) && $ct < $i+1 ; $o++) {
+ for ($o = 0 ; $o < (BIN5_CARD_HAND * BIN5_PLAYERS_N) && $ct < $i+1 ; $o++) {
// for ($o = 0 ; $o < 40 && $ct < $i+1 ; $o++) {
if ($table->card[$o]->owner == (($e + $table->gstart) % BIN5_PLAYERS_N)) {
$ct++;
$ontabl = array(-1,-1,-1,-1,-1);
$cards = array();
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
// for ($i = 0 ; $i < 40 ; $i++) {
if ($table->card[$i]->stat == 'hand') {
if ($table->card[$i]->owner == $table_pos) {
$oursarg = "";
for ($i = 0 ; $i < $inhand[$table_pos] ; $i++)
$oursarg .= ($i == 0 ? "" : ", ").$cards[$i];
- for ($i = $inhand[$table_pos] ; $i < 8 ; $i++)
+ for ($i = $inhand[$table_pos] ; $i < BIN5_CARD_HAND ; $i++)
$oursarg .= ($i == 0 ? "" : ", ")."-1";
$ret .= sprintf('card_setours(%s);', $oursarg);
for ($i = 0 ; $i < BIN5_PLAYERS_N ; $i++) {
/* Qui sotto al posto di + 1 c'era + ->gstart ... credo in modo errato */
$ret .= sprintf('cards_dispose(%d,%d,%d);', $i,
- ($inhand[$i] <= 8 ? $inhand[$i] : 8) , $taked[$i]);
+ ($inhand[$i] <= BIN5_CARD_HAND ? $inhand[$i] : BIN5_CARD_HAND), $taked[$i]);
if ($ontabl[$i] != -1) {
$ret .= sprintf('card_place(%d,%d,%d,%d,%d);',$i, $inhand[$i],
$cur_val = 100;
$cur_seed = $table->briscola - ($table->briscola % 10);
- for ($i = 0 ; $i < (BIN5_PLAYERS_N == 5 ? 40 : 24) ; $i++) {
+ for ($i = 0 ; $i < (BIN5_CARD_HAND * BIN5_PLAYERS_N) ; $i++) {
// for ($i = 0 ; $i < 40 ; $i++) {
if ($table->card[$i]->stat != "table")
continue;
show_astat(-2,-2,-2,-2,-2);
set_iscalling(-1);
- for (i=0 ; i < 8 ; i++) {
+ for (i=0 ; i < CARD_HAND ; i++) {
Drag.init($("card" + i), card_mouseup_cb);
for (e = 0 ; e < PLAYERS_N ; e++)
$("card"+sux[e]+i).style.visibility = "hidden";
$("takes"+sux[i]).style.visibility = "hidden";
}
- for (i = 0 ; i < 8 ; i++) {
+ for (i=0 ; i < CARD_HAND ; i++) {
cards_pos[i] = i;
cards_ea_pos[i] = i;
cards_ne_pos[i] = i;
* Suite 330, Boston, MA 02111-1307, USA.
*
*/
-
+/* number of players */
var PLAYERS_N = 3;
+/* initial number of cards in hand */
+var CARD_HAND = 3;
/* current manche */
var manche = 1;
/* cards on hands */
/* suffix to add to images name */
var sux = new Array( "", "_ea", "", "", "_we");
-var cards_pos = new Array (8);
-var cards_ea_pos = new Array (8);
-var cards_ne_pos = new Array (8);
-var cards_nw_pos = new Array (8);
-var cards_we_pos = new Array (8);
+var cards_pos = new Array (CARD_HAND);
+var cards_ea_pos = new Array (CARD_HAND);
+var cards_ne_pos = new Array (CARD_HAND);
+var cards_nw_pos = new Array (CARD_HAND);
+var cards_we_pos = new Array (CARD_HAND);
var take_x = new Array(562, 745, 452, 30, 52);
var take_y = new Array(545, 177, 70, 62,155);
-for (i = 0 ; i < 8 ; i++) {
+for (i = 0 ; i < CARD_HAND ; i++) {
cards_pos[i] = i;
cards_ea_pos[i] = i;
cards_ne_pos[i] = i;
for (i = 0 ; i < car_n ; i++) {
$("card" + cards_pos[i]).style.left = start + (i * inter);
$("card" + cards_pos[i]).style.top = 475 + (125 - cards_height)/2;
- $("card" + cards_pos[i]).style.zIndex = 8 - i;
+ $("card" + cards_pos[i]).style.zIndex = CARD_HAND - i;
$("card" + cards_pos[i]).style.visibility = "visible";
}
for (i = 0 ; i < car_n ; i++) {
$("card_ea" + cards_ea_pos[i]).style.left = 675 + (125 - cards_height)/2;
$("card_ea" + cards_ea_pos[i]).style.top = start + (i * inter);
- $("card_ea" + cards_ea_pos[i]).style.zIndex = 8 - i;
+ $("card_ea" + cards_ea_pos[i]).style.zIndex = CARD_HAND - i;
$("card_ea" + cards_ea_pos[i]).style.visibility = "visible";
// alert("xx "+ (675 + (125 - cards_height)/2) +" yy " + start + (i * inter));
}
for (i = 0 ; i < car_n ; i++) {
$("card_we" + cards_we_pos[i]).style.left = (125 - cards_height)/2;
$("card_we" + cards_we_pos[i]).style.top = start - (i * inter);
- $("card_we" + cards_we_pos[i]).style.zIndex = 8 - i;
+ $("card_we" + cards_we_pos[i]).style.zIndex = CARD_HAND - i;
$("card_we" + cards_we_pos[i]).style.visibility = "visible";
}
var i;
var arg = new Array(zer,uno,due,tre,qua,cin,sei,set);
- for (i = 0 ; i < 8 ; i++) {
+ for (i = 0 ; i < CARD_HAND ; i++) {
$("card"+i).src = getcard(arg[i], 0);
$("card"+i).briskid = arg[i];
}
log_wr("CIC".$loggo);
/* se era il suo turno e la carta era sua ed era in mano */
- if ($a_play >=0 && $a_play < (BIN5_PLAYERS_N == 5 ? 40 : 24) &&
+ if ($a_play >=0 && $a_play < (BIN5_CARD_HAND * BIN5_PLAYERS_N) &&
($user->table_pos == (($table->gstart + $table->turn) % BIN5_PLAYERS_N)) &&
$table->card[$a_play]->stat == 'hand' &&
$table->card[$a_play]->owner == $user->table_pos) {
$player_nex = $card_play . "is_my_time = true; remark_on();";
$player_oth = $card_play;
}
- else if ($table->turn <= (BIN5_PLAYERS_N * 8)) { /* manche finished */
+ else if ($table->turn <= (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* manche finished */
$winner = calculate_winner($table);
log_wr("GSTART 3");
$table->gstart = $winner;
$player_nex = $card_play . $card_take;
else
$player_nex = "";
- if ($table->turn < (BIN5_PLAYERS_N * 8)) /* game NOT finished */
+ if ($table->turn < (BIN5_PLAYERS_N * BIN5_CARD_HAND)) /* game NOT finished */
$player_nex .= "is_my_time = true; remark_on();";
$player_oth = $card_play . $card_take;
}
$retar[$i] = $ret;
}
- if ($table->turn == (BIN5_PLAYERS_N * 8)) { /* game finished */
+ if ($table->turn == (BIN5_PLAYERS_N * BIN5_CARD_HAND)) { /* game finished */
log_wr(sprintf("GIOCO FINITO !!!"));