summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/game.php34
-rw-r--r--include/output.php9
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;
}