NEW FEATURE: in poverty you can now see what cards have been handed over
authorArun Persaud <arun@nubati.net>
Sun, 13 Jul 2008 21:40:59 +0000 (14:40 -0700)
committerArun Persaud <arun@nubati.net>
Mon, 14 Jul 2008 03:35:17 +0000 (20:35 -0700)
cards exchanged during poverty show now up in the pre-game trick.

Signed-off-by: Arun Persaud <arun@nubati.net>
cards/altenburg/0.png [new file with mode: 0644]
cards/english/0.png [new file with mode: 0644]
create_database.sql
css/standard010.css [moved from css/standard009.css with 96% similarity]
include/db.php
include/game.php
include/output.php

diff --git a/cards/altenburg/0.png b/cards/altenburg/0.png
new file mode 100644 (file)
index 0000000..1ece76f
Binary files /dev/null and b/cards/altenburg/0.png differ
diff --git a/cards/english/0.png b/cards/english/0.png
new file mode 100644 (file)
index 0000000..1ece76f
Binary files /dev/null and b/cards/english/0.png differ
index 0ac02f0275f8ec101cc455e590f7f6496bfac2e3..5ec47ebd992308ba83940f0596801a665fa123fc 100644 (file)
@@ -200,6 +200,32 @@ LOCK TABLES `Hand_Card` WRITE;
 UNLOCK TABLES;
 /*!40000 ALTER TABLE `Hand_Card` ENABLE KEYS */;
 
+--
+-- Table structure for table `Card_Exchange`
+--
+
+DROP TABLE IF EXISTS `Card_Exchange`;
+CREATE TABLE `Card_Exchange` (
+  `id` int(11) NOT NULL auto_increment,
+  `orig_hand_id` int(11) NOT NULL default '0',
+  `new_hand_id` int(11) NOT NULL default '0',
+  `card_id` int(11) NOT NULL default '0',
+  UNIQUE KEY `id` (`id`),
+  KEY `orig_hand_id` (`orig_hand_id`),
+  KEY `new_hand_id` (`new_hand_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `Hand_Card`
+--
+
+
+/*!40000 ALTER TABLE `Hand_Card` DISABLE KEYS */;
+LOCK TABLES `Hand_Card` WRITE;
+UNLOCK TABLES;
+/*!40000 ALTER TABLE `Hand_Card` ENABLE KEYS */;
+
+
 --
 -- Table structure for table `Play`
 --
similarity index 96%
rename from css/standard009.css
rename to css/standard010.css
index 6d13028d61499a75805145bf7d714ea029b90f8e..41b331944934706fc405a91bb7011a4cec57d592 100644 (file)
@@ -214,6 +214,8 @@ ul.tricks li div.trick img.arrow {
   z-index:8;
 }
 
+#trick0 img { float:left; width: 3em; }
+
 hr {clear:both;}
 
 /*ul.tricks li:hover div.table{ display:block; }*/
@@ -229,6 +231,12 @@ ul.tricks li div div.card0 img,ul.tricks li div div.card0 .score, .vorbehalt0 {
   width:6%;
   z-index:30;
 }
+.vorbehalt0 {
+  left:37.5%;
+  right:57.5%;
+  width:10%;
+  text-align:left;
+}
 ul.tricks li div div.card0 span.comment{
   position:absolute;
   margin:0;
@@ -251,6 +259,12 @@ ul.tricks li div div.card1 img,ul.tricks li div div.card1 .score, .vorbehalt1 {
   text-align:center;
   z-index:30;
 }
+.vorbehalt1{
+  left:45%;
+  right:45%;
+  width:10%;
+  z-index:30;
+}
 ul.tricks li div div.card1 span.comment{
   position:absolute;
   margin:0;
@@ -269,10 +283,16 @@ ul.tricks li div div.card2 img,ul.tricks li div div.card2 .score, .vorbehalt2{
   /*border: 1px solid red;*/
   top: 40%;
   right:37.5%;
-  left:56x.5%;
+  left:56.5%;
   width:6%;
   z-index:30;
 }
+.vorbehalt2{
+  left:auto;
+  right:38%;
+  width:10%;
+  text-align:right;
+}
 ul.tricks li div div.card2 span.comment{
   position:absolute;
   margin:0;
@@ -296,6 +316,12 @@ ul.tricks li div div.card3 img,ul.tricks li div div.card3 .score, .vorbehalt3{
   text-align:center;
   z-index:30;
 }
+.vorbehalt3{
+  left:45%;
+  right:45%;
+  width:10%;
+  text-align:center;
+}
 ul.tricks li div div.card3 span.comment{
   position:absolute;
   margin:0;
index 9b691ecb3f8e7c953348f2e2f63e63b55b3513ef..b7c6f707fd2c8abf786589def567346bc3bc6a01 100644 (file)
@@ -1084,4 +1084,24 @@ function DB_get_name($type,$var1='')
     return "";
 }
 
+function DB_add_exchanged_card($card,$old_hand_id,$new_hand_id)
+{
+  DB_query("INSERT INTO Card_Exchange VALUES (NULL,$new_hand_id,$old_hand_id,$card)");
+  return;
+}
+
+function DB_get_exchanged_cards($hash)
+{
+  $cards = array();
+
+  $handid = DB_get_handid('hash',$hash);
+
+  $result = DB_query("SELECT card_id FROM Card_Exchange WHERE orig_hand_id=".DB_quote_smart($handid));
+  while($r = DB_fetch_array($result))
+    $cards[]=$r[0];
+
+  return $cards;
+}
+
+
 ?>
\ No newline at end of file
index 3ed94973ab4ede24e6e4a8437cf1ae84e5a026d7..e471d5d47fef8eb5339ccaad02102f0cbd9ce73f 100644 (file)
@@ -693,6 +693,7 @@ switch($mystatus)
          {
            $result = DB_query("UPDATE Hand_Card SET hand_id='$partnerhand'".
                               " WHERE hand_id='$myhand' AND card_id=".DB_quote_smart($exchange));
+           DB_add_exchanged_card(DB_quote_smart($exchange),$myhand,$partnerhand);
          };
       }
 
@@ -844,6 +845,12 @@ switch($mystatus)
            $userhand = DB_get_handid('gameid-userid',$gameid,$trump);
            $userhash = DB_get_hash_from_gameid_and_userid($gameid,$trump);
 
+           /* remember which cards were handed over*/
+           $partnerhand = DB_get_all_hand($userhash);
+           foreach ($partnerhand as $card)
+             if($card<27)
+               DB_add_exchanged_card($card,$userhand,$myhand);
+
            /* copy trump from player A to B */
            $result = DB_query("UPDATE Hand_Card SET hand_id='$myhand' WHERE hand_id='$userhand' AND card_id<'27'" );
 
@@ -1067,15 +1074,87 @@ 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)
+           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";
 
                if($mygametype == $usersick)
index 21f7e8eb5a78be972f0893cdf5bacb83e01ddabd..827273954d6247fc6f75d463a6e710fc5a4a85da 100644 (file)
@@ -143,7 +143,7 @@ function display_card($card,$dir="english")
   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
    * convert even cards to the matching odd value */
 
-  if( $card/2 - (int)($card/2) == 0.5)
+  if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
   else
     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
@@ -270,7 +270,7 @@ function output_header()
      <title>e-Doko</title>
      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
-     <link rel="stylesheet" type="text/css" href="css/standard009.css" />
+     <link rel="stylesheet" type="text/css" href="css/standard010.css" />
      <script type="text/javascript">
        var current=0;
        function hl(num) {