diff options
author | Arun Persaud <arun@nubati.net> | 2010-09-21 20:27:12 -0700 |
---|---|---|
committer | Arun Persaud <arun@nubati.net> | 2010-09-21 20:32:39 -0700 |
commit | f94dd2d6d58f37306d1da0f6bb12f5276883cd6b (patch) | |
tree | 434c01c1050581a3241690e5d72197009363cef0 | |
parent | 615fb7c0fec9ec6f187a3c568cf1e2e6c1572b1e (diff) | |
download | e-DoKo-f94dd2d6d58f37306d1da0f6bb12f5276883cd6b.tar.gz e-DoKo-f94dd2d6d58f37306d1da0f6bb12f5276883cd6b.tar.bz2 e-DoKo-f94dd2d6d58f37306d1da0f6bb12f5276883cd6b.zip |
NEW FEATURE: pre select card to play if there is only one option
-rw-r--r-- | include/game.php | 34 | ||||
-rw-r--r-- | include/output.php | 9 |
2 files changed, 39 insertions, 4 deletions
diff --git a/include/game.php b/include/game.php index eb66a98..04df162 100644 --- a/include/game.php +++ b/include/game.php @@ -1990,6 +1990,38 @@ switch($mystatus) if(have_suit($mycards,$firstcard)) $followsuit = 1; + /* count how many cards we can play, so that we can pre-select it if there is only one */ + $howmanycards = 0; + foreach($mycards as $card) + { + if($howmanycard>1) + break; + + /* display only cards that the player is allowed to play as links, the rest just display normal + * also check if we have both schweinchen, in that case only display on of them as playable + */ + if( ($followsuit && !same_type($card,$firstcard)) || + ( (int)($card)==19 && + !$GAME['schweinchen-first'] && + ( $RULES['schweinchen']=='second' || + ( $RULES['schweinchen']=='secondaftercall' && + (DB_get_call_by_hash($GAME['schweinchen-who']) || + DB_get_partner_call_by_hash($GAME['schweinchen-who']) ) + ) + ) && + $GAME['schweinchen-who']==$me && + in_array($gametype,array('normal','wedding','trump','silent')) + ) + ) + continue ; + else + $howmanycards++; + } + if($howmanycards==1) + $howmanycards=1; + else + $howmanycards=0; + foreach($mycards as $card) { /* display only cards that the player is allowed to play as links, the rest just display normal @@ -2010,7 +2042,7 @@ switch($mystatus) ) display_card($card,$PREF['cardset']); else - display_link_card($card,$PREF['cardset']); + display_link_card($card,$PREF['cardset'],$selected=$howmanycards); } } else if($mystatus=='play' ) diff --git a/include/output.php b/include/output.php index 3ad0552..0c2ff96 100644 --- a/include/output.php +++ b/include/output.php @@ -202,12 +202,15 @@ function display_card($card,$dir="english") return; } -function display_link_card($card,$dir="english",$type="card") +function display_link_card($card,$dir="english",$type="card", $selected=0) { + if($selected) + $selected = 'selected="selected"'; + if( $card/2 - (int)($card/2) == 0.5) - echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n"; + echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" $selected /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n"; else - echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n"; + echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" $selected /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n"; return; } |