From d638a4e1d0c15ce749430e546d695827c04979f1 Mon Sep 17 00:00:00 2001 From: arun Date: Sat, 2 Jun 2007 15:40:16 +0000 Subject: [PATCH 1/1] new feature: added checks for re/contra/90 etc. ; fixed: some measages were outdated --- functions.php | 45 +++++++++++++++++++++++++++++++++++++++++++-- index.php | 10 +++++++--- output.php | 22 +++++++++++++++------- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/functions.php b/functions.php index f33dd1c..418591d 100644 --- a/functions.php +++ b/functions.php @@ -649,7 +649,48 @@ function sort_comp($a,$b) function can_call($what,$hash) { - return 1; + global $RULES; + + /*TODO: check if this already has been call by teammate */ + + $gameid = DB_get_gameid_by_hash($hash); + $gametype = DB_get_gametype_by_gameid($gameid); + + $NRcards = count(DB_get_hand($me)); + + $NRallcards = 0; + for ($i=1;$i<5;$i++) + { + $user = DB_get_hash_from_game_and_pos($gameid,$i); + $NRallcards += count(DB_get_hand($user)); + }; + + /* in case of a wedding, everything will be delayed by an offset */ + $offset = 0; + if($gametype=="wedding") + { + $offset = DB_get_sickness_by_gameid($gameid); + if ($offset <0) /* not resolved */ + return 0; + }; + + switch ($RULES["call"]) + { + case "1st-own-card": + if( 4-($what/30) >= 12 - $NRcards + $offset) + return 1; + break; + case "5th-card": + if( 27+4*($what/30)) <= $NRallcards + $offset*4) + return 1; + break; + case "9-cards": + if( ($what/10) <= $NRcards + $offset) + return 1; + break; + } + + return 0; } -?> \ No newline at end of file +?> diff --git a/index.php b/index.php index 8e21ae6..10416f1 100644 --- a/index.php +++ b/index.php @@ -243,7 +243,9 @@ else if(myisset("me")) $RULES["dullen"] = $r[2]; $RULES["schweinchen"] = $r[3]; - + $RULES["call"] = "1st-own-card"; + + /* get some infos about the game */ $gametype = DB_get_gametype_by_gameid($gameid); $gamestatus = DB_get_game_status_by_gameid($gameid); @@ -333,7 +335,7 @@ else if(myisset("me")) display_card($card,$PREF["cardset"]); echo "

\n"; - check_for_sickness($me,$mycards); + output_check_for_sickness($me,$mycards); /* move on to the next stage*/ DB_set_hand_status_by_hash($me,'check'); @@ -1461,7 +1463,9 @@ else if(myisset("me")) " "; if( can_call(0,$me) ) echo " 0:". - " "; + " ". + " no call:". + " "; echo "
\nA short comments:\n"; echo "\n"; diff --git a/output.php b/output.php index 8288ee2..75d0135 100644 --- a/output.php +++ b/output.php @@ -106,6 +106,7 @@ function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid) echo " \n"; echo " \n"; echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "\n"; @@ -161,7 +162,16 @@ function output_form_for_new_game($names)

- +

Call Re/Contra, etc.: +

+

-

Solo will work, but the first player will not change. Nothing else implemented.

-
do you want to play solo? @@ -211,7 +219,7 @@ function check_for_sickness($me,$mycards) "; @@ -222,7 +230,7 @@ function check_for_sickness($me,$mycards) echo " no
\n"; }; - echo "do you have poverty?"; + echo "Do you have poverty?"; if(count_trump($mycards)<4) { echo " yes"; @@ -233,7 +241,7 @@ function check_for_sickness($me,$mycards) echo " no
\n"; }; - echo "do you have too many nines?"; + echo "Do you have too many nines?"; if(count_nines($mycards)>4) { echo " yes"; -- 2.25.1