diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/db.php | 3 | ||||
-rw-r--r-- | include/game.php | 109 | ||||
-rw-r--r-- | include/output.php | 126 |
3 files changed, 150 insertions, 88 deletions
diff --git a/include/db.php b/include/db.php index 6e1af93..27d639e 100644 --- a/include/db.php +++ b/include/db.php @@ -852,6 +852,9 @@ function DB_set_recovery_password($user,$newpw) function DB_get_card_name($card) { + if($card==0) + return 'backside'; + $r = DB_query_array("SELECT strength,suite FROM Card WHERE id='$card'"); if($r) diff --git a/include/game.php b/include/game.php index b08f36b..377d0aa 100644 --- a/include/game.php +++ b/include/game.php @@ -782,9 +782,6 @@ switch($mystatus) * it is easier to check B) first */ - /* output pre game in case user reloads */ - - set_gametype($gametype); /* this sets the $CARDS variable */ $myparty = DB_get_party_by_hash($me); @@ -810,6 +807,25 @@ switch($mystatus) $mycards = DB_get_hand($me); $mycards = mysort($mycards,$gametype); + /* output pre-game trick in case user reloads, + * only needs to be done when a team has been formed */ + if($myparty=='re' || $myparty=='contra') + { + echo "\n<ul class=\"tricks\">\n"; + echo " <li class=\"nohighlight\"> Game ".DB_format_gameid($gameid).": </li>\n"; + + $mygametype = DB_get_gametype_by_gameid($gameid); + + echo " <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n". + " <div class=\"trick\" id=\"trick0\">\n"; + + /* get information so show the cards that have been handed over in a poverty game */ + output_exchanged_cards(); + + echo " </div>\n </li>\n"; /* end div trick, end li trick */ + } + /* end output pre-game trick */ + /* check if user need to give more cards back */ if( ($myparty=='re' || $myparty=='contra') && count($mycards)>12) { @@ -1184,93 +1200,10 @@ switch($mystatus) { echo " <li onclick=\"hl('0');\" class=\"current\"><a href=\"#\">Pre</a>\n". " <div class=\"trick\" id=\"trick0\">\n"; - /* get information so show the cards that have been handed over in a poverty game */ - $partnerpos1 = 0; - $povertypos1 = 0; - $partnerpos2 = 0; - $povertypos2 = 0; - if($mygametype == 'poverty' || $mygametype=='dpoverty') - { - /* who has poverty */ - for($mypos=1;$mypos<5;$mypos++) - { - $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid); - if($usersick == 'poverty') - if($povertypos1) - $povertypos2 = $mypos; - else - $povertypos1 = $mypos; - } - /* get hash and cards for all */ - $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1); - $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1); - - $povertycards1 = DB_get_exchanged_cards($povertyhash1); - $partnercards1 = DB_get_exchanged_cards($partnerhash1); - - $partnerpos1 = DB_get_pos_by_hash($partnerhash1); - if($povertypos2) - { - $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2); - $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2); - $povertycards2 = DB_get_exchanged_cards($povertyhash2); - $partnercards2 = DB_get_exchanged_cards($partnerhash2); - - $partnerpos2 = DB_get_pos_by_hash($partnerhash2); - } - } - - $show = 1; - for($mypos=1;$mypos<5;$mypos++) - { - $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid); - if($usersick!=NULL || - $mypos==$povertypos1 || $mypos==$partnerpos1 || - $mypos==$povertypos2 || $mypos==$partnerpos2 ) - { - echo " <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />"; - if($show) - echo " $usersick <br />"; - if($mypos==$partnerpos1) - { - foreach($partnercards1 as $card) - if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover') - display_card($card,$PREF['cardset']); - else - display_card(0,$PREF['cardset']); - } - else if($mypos==$povertypos1) - { - foreach($povertycards1 as $card) - if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover') - display_card($card,$PREF['cardset']); - else - display_card(0,$PREF['cardset']); - } - else if($mypos==$povertypos2) - { - foreach($povertycards2 as $card) - if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover') - display_card($card,$PREF['cardset']); - else - display_card(0,$PREF['cardset']); - } - else if($mypos==$partnerpos2) - { - foreach($partnercards2 as $card) - if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover') - display_card($card,$PREF['cardset']); - else - display_card(0,$PREF['cardset']); - } - - echo " </div>\n"; + /* get information so show the cards that have been handed over in a poverty game */ + output_exchanged_cards(); - if($mygametype == $usersick) - $show = 0; - } - } echo " </div>\n </li>\n"; /* end div trick, end li trick */ } diff --git a/include/output.php b/include/output.php index 395e4ec..bdaa532 100644 --- a/include/output.php +++ b/include/output.php @@ -456,4 +456,130 @@ function output_robotproof($i) return "2*7="; } } + +function output_exchanged_cards() +{ + /* in a poverty game this function will output the exchanged cards + * players in the team will see the cards, the other team will see + * the backside of cards + */ + + /* need some information about the game */ + global $gameid,$mygametype, $PREF,$me; + + /* some variables to track where the people with poverty are sitting */ + $partnerpos1 = 0; + $povertypos1 = 0; + $partnerpos2 = 0; + $povertypos2 = 0; + + /* only need to do it in a poverty game, this might not be needed, but + * just to make sure everything is ok + */ + if($mygametype == 'poverty' || $mygametype=='dpoverty') + { + /* find out who has poverty */ + for($mypos=1;$mypos<5;$mypos++) + { + $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid); + if($usersick == 'poverty') + if($povertypos1) + $povertypos2 = $mypos; + else + $povertypos1 = $mypos; + } + /* get hash and exchanged cards for all involved */ + $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1); + $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1); + + $povertycards1 = DB_get_exchanged_cards($povertyhash1); + $partnercards1 = DB_get_exchanged_cards($partnerhash1); + + $partnerpos1 = DB_get_pos_by_hash($partnerhash1); + if($povertypos2) + { + $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2); + $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2); + + $povertycards2 = DB_get_exchanged_cards($povertyhash2); + $partnercards2 = DB_get_exchanged_cards($partnerhash2); + + $partnerpos2 = DB_get_pos_by_hash($partnerhash2); + } + } + + /* output the cards + * go through all positions, check that position has cards that need to be shown and + * show those cards + */ + $show = 1; + for($mypos=1;$mypos<5;$mypos++) + { + $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid); + if($usersick!=NULL || + $mypos==$povertypos1 || $mypos==$partnerpos1 || + $mypos==$povertypos2 || $mypos==$partnerpos2 ) + { + echo " <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />\n"; + if($show) + echo " $usersick <br />\n"; + if($mypos==$partnerpos1) + { + $trump_back=0; + foreach($partnercards1 as $card) + { + if(is_trump($card)) $trump_back=1; + echo ' '; + if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover') + display_card($card,$PREF['cardset']); + else + display_card(0,$PREF['cardset']); + } + if($trump_back) echo "Trump back"; + } + else if($mypos==$povertypos1) + { + foreach($povertycards1 as $card) + { + echo ' '; + if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover') + display_card($card,$PREF['cardset']); + else + display_card(0,$PREF['cardset']); + } + } + else if($mypos==$povertypos2) + { + foreach($povertycards2 as $card) + { + echo ' '; + if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover') + display_card($card,$PREF['cardset']); + else + display_card(0,$PREF['cardset']); + } + } + else if($mypos==$partnerpos2) + { + $trump_back=0; + foreach($partnercards2 as $card) + { + if(is_trump($card)) $trump_back=1; + echo ' '; + if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover') + display_card($card,$PREF['cardset']); + else + display_card(0,$PREF['cardset']); + } + if($trump_back) echo "Trump back"; + } + echo " </div>\n"; + + if($mygametype == $usersick) + $show = 0; + } + } +} + + ?>
\ No newline at end of file |