From: Arun Persaud Date: Sun, 14 Mar 2010 18:11:38 +0000 (-0700) Subject: CLEANUP: cleaned up code for Karlchen X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=c05246b378470eab9c172d8d96328a821302a273;ds=sidebyside CLEANUP: cleaned up code for Karlchen --- diff --git a/include/game.php b/include/game.php index b94ee90..db27bde 100644 --- a/include/game.php +++ b/include/game.php @@ -1524,28 +1524,31 @@ switch($mystatus) /* same as for foxes, karlchen doesn't always make sense * check what kind of game it is and set karlchen accordingly */ - $ok = 1; /* default: karlchen should be accounted for */ - if($tricknr != 12 ) - $ok = 0; /* Karlchen works only in the last trick */ - if($ok && DB_get_gametype_by_gameid($gameid)=='solo' ) + + if($tricknr == 12 ) /* Karlchen works only in the last trick */ { - $solo = DB_get_solo_by_gameid($gameid); - if($solo == 'trumpless' || $solo == 'jack' || $solo == 'queen' ) - $ok = 0; /* no Karlchen in these solos */ - } + /* check for solo */ + $solo = 'none'; + if(DB_get_gametype_by_gameid($gameid)=='solo' ) + $solo = DB_get_solo_by_gameid($gameid); - if($ok) - foreach($play as $played) - if ( $played['card']==11 || $played['card']==12 ) - if ($played['pos'] == $winner ) - { - /* possible caught a fox, check party */ - $uid1 = DB_get_userid('gameid-position',$gameid,$winner); - $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1); + /* no Karlchen in these solos */ + if($solo != 'trumpless' && $solo != 'jack' && $solo != 'queen' ) + { + foreach($play as $played) + if ( $played['card']==11 || $played['card']==12 ) + if ($played['pos'] == $winner ) + { + /* save Karlchen */ + $uid1 = DB_get_userid('gameid-position',$gameid,$winner); + $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1); + + DB_query("INSERT INTO Score". + " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')"); + }; + }; + }; /* end scoring Karlchen */ - DB_query("INSERT INTO Score". - " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')"); - } /* * check for doppelopf (>40 points) ***********************************/