+<?php
+/*
+ * brisk - rules_together17.phh
+ *
+ * Copyright (C) 2017 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+require_once("briskin5.phh");
+require_once("rules_base.phh");
+
+class Rules_together17 extends Rules_no_draw {
+ function __construct($table)
+ {
+ parent::__construct($table);
+ $this->id = 4;
+ }
+
+ function tourn_points(&$user, $user_pos)
+ {
+ $card = $this->table->card;
+ unset($user->asta_tourn_pts);
+ $user->asta_tourn_pts = array(0, 0, 0, 0);
+ $tourn_values = array(11, 10, 4,3,2, 1,1,1,1,1);
+
+ error_log("QUI CI SIAMO: PRE");
+ for ($i = 0 ; $i < BIN5_PLAYERS_N * BIN5_CARD_HAND ; $i++) {
+ error_log("QUI CI SIAMO: LOOP");
+
+ if ($card[$i]->owner == $user_pos) {
+ error_log("QUI CI SIAMO: ASSIGN");
+ $user->asta_tourn_pts[(int)($i / 10)] += $tourn_values[$i % 10];
+ }
+ }
+ }
+
+ function tourn_points_max($user)
+ {
+
+ $mx = 0;
+ for ($i = 0 ; $i < 4 ; $i++) {
+ error_log("tourn_pts_max ");
+ error_log(print_r($user->asta_tourn_pts, TRUE));
+ if ($user->asta_tourn_pts[$i] > $mx) {
+ $mx = $user->asta_tourn_pts[$i];
+ }
+ }
+
+ return $mx;
+ }
+
+ function rules_asta(&$bri, $curtime, $action, $user, &$ret_s, $a_card, $a_pnt) {
+ /*
+Per le chiamate da 62 a 70 bisognerà avere 13 punti ( esempi.: asso e fante oppure tre
+e cavallo oppure re, cavallo, fante, sette, sei, cinque, quattro) ;
+Per chiamate da 71 ad 80 bisognerà avere 19 punti ( esempi.: asso, re, cavallo e 6
+oppure tre, re, fante, 7, 6 e 5 );
+Per chiamate da 81 a 90 bisognerà avere 23 punti ( esempi.: asso, tre e fante oppure
+asso, re, cavallo, fante, 6, 5 e 4);
+Per chiamate da 91 a 100 bisognerà avere 25 punti ( esempi.: asso, tre, re e 7 oppure
+asso, tre, cavallo e fante );
+Per chiamate da 101 a 120 bisognerà avere 28 punti ( esempi.:asso, tre, re e cavallo
+oppure asso, tre, cavallo, 7, 6, 5 e 4 ).
+ */
+
+ if ($a_card >= 0 && $a_card < 9 && $a_card > $this->table->asta_card)
+ return TRUE;
+ else if ($a_card == 9 &&
+ $a_pnt > ($this->table->asta_pnt >= 61 ? $this->table->asta_pnt : 60) && $a_pnt <= 120) {
+ if ($a_pnt < 71)
+ $min_pts = 13;
+ else if ($a_pnt < 80)
+ $min_pts = 19;
+ else if ($a_pnt < 90)
+ $min_pts = 23;
+ else if ($a_pnt < 100)
+ $min_pts = 25;
+ else
+ $min_pts = 28;
+
+ $max_hand_pts = $this->tourn_points_max($user);
+ if ($max_hand_pts < $min_pts) {
+ $ret_s = sprintf("Hai chiamato un due a %d ma in mano hai al massimo %d punti-torneo, non puoi.",
+ $a_pnt, $max_hand_pts);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+} // class Rules_no_draw
+
+?>
\ No newline at end of file