- $hash = DB_get_hash_from_game_and_pos($gameid,$i);
- $cards = DB_get_all_hand($hash);
- if( in_array("19",$cards) && in_array("20",$cards) )
- {
- $GAME["schweinchen"]=1;
- $GAME["schweinchen-who"]=$hash;
- }
- };
+ /* always need to use Schweinchen to figure out for example who has poverty */
+ $ok=1;
+ }
+else
+ {
+ /* in a game Schweinchen is not valid in all types of games */
+ if( $gametype == 'normal' || $gametype == 'silent' || $gametype=='trump' )
+ if( in_array($RULES['schweinchen'],array('both','second','secondaftercall')) )
+ $ok=1;
+ }
+
+/* these are the defaults */
+$GAME['schweinchen-who'] = NULL;
+$GAME['schweinchen-first'] = NULL;
+$GAME['schweinchen-second'] = NULL;
+
+if($ok)
+{
+ /* need to check for Schweinchen */
+ for($i=1;$i<5;$i++)
+ {
+ $hash = DB_get_hash_from_game_and_pos($gameid,$i);
+ $cards = DB_get_all_hand($hash);
+ if( in_array("19",$cards) && in_array("20",$cards) )
+ $GAME['schweinchen-who']=$hash;
+ };
+ $GAME['schweinchen-first'] = 0; /* to keep track if they have been played already */
+ $GAME['schweinchen-second'] = 0;
+}
+/* end check for Schweinchen */
+
+/* set the $CARDS variable, needed for sorting the cards
+ * we set it to normal so that the pre-game phase is handled ok
+ * and later set it to the correct game type that is played
+ */
+set_gametype('normal');