diff options
author | arun <arun@nubati.net> | 2007-06-02 15:40:16 +0000 |
---|---|---|
committer | arun <arun> | 2007-06-02 15:40:16 +0000 |
commit | d638a4e1d0c15ce749430e546d695827c04979f1 (patch) | |
tree | 318947d1b68ce13b9f96ff1c9a73fddecba5eab7 /functions.php | |
parent | 05c0e5ebd24477c861b06884e60db11672127569 (diff) | |
download | e-DoKo-d638a4e1d0c15ce749430e546d695827c04979f1.tar.gz e-DoKo-d638a4e1d0c15ce749430e546d695827c04979f1.tar.bz2 e-DoKo-d638a4e1d0c15ce749430e546d695827c04979f1.zip |
new feature: added checks for re/contra/90 etc. ; fixed: some measages were outdated
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 45 |
1 files changed, 43 insertions, 2 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 +?> |