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