summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2007-06-24 11:30:20 +0200
committerArun Persaud <arun@nubati.net>2007-06-24 11:30:20 +0200
commitb6d9a4aa79763981c524b3915ab11e449cad4c42 (patch)
tree5b713bca22f5889fbc859e84043e08565d20e13b
parent7405ce4fabf64e905e7b7371764d74dbc4b1b198 (diff)
downloade-DoKo-b6d9a4aa79763981c524b3915ab11e449cad4c42.tar.gz
e-DoKo-b6d9a4aa79763981c524b3915ab11e449cad4c42.tar.bz2
e-DoKo-b6d9a4aa79763981c524b3915ab11e449cad4c42.zip
CLEANUP: get card names from the database
-rw-r--r--db.php12
-rw-r--r--functions.php81
-rw-r--r--output.php8
3 files changed, 16 insertions, 85 deletions
diff --git a/db.php b/db.php
index 86f3d0e..75cd8a0 100644
--- a/db.php
+++ b/db.php
@@ -803,4 +803,16 @@ function DB_set_recovery_password($user,$newpw)
return;
}
+
+function DB_get_card_name($card)
+{
+ $queryresult = mysql_query("SELECT strength,suite FROM Card WHERE id='$card'");
+
+ $r = mysql_fetch_array($queryresult,MYSQL_NUM);
+ if($r)
+ return $r[0]." of ".$r[1];
+ else
+ return "Error during get_card_name ".$card;
+}
+
?> \ No newline at end of file
diff --git a/functions.php b/functions.php
index 3a650a2..be88974 100644
--- a/functions.php
+++ b/functions.php
@@ -276,87 +276,6 @@ function count_trump($cards)
return $trump;
}
-function card_to_name($card)
-{
- switch($card)
- {
- case 1:
- case 2:
- return "ten of hearts";
- case 3:
- case 4:
- return "queen of clubs";
- case 5:
- case 6:
- return "queen of spades";
- case 7:
- case 8:
- return "queen of hearts";
- case 9:
- case 10:
- return "queen of diamonds";
- case 11:
- case 12:
- return "jack of clubs";
- case 13:
- case 14:
- return "jack of spades";
- case 15:
- case 16:
- return "jack of hearts";
- case 17:
- case 18:
- return "jack of diamonds";
- case 19:
- case 20:
- return "ace of diamonds";
- case 21:
- case 22:
- return "ten of diamonds";
- case 23:
- case 24:
- return "king of diamonds";
- case 25:
- case 26:
- return "nine of diamonds";;
- case 27:
- case 28:
- return "ace of clubs";
- case 29:
- case 30:
- return "ten of clubs";
- case 31:
- case 32:
- return "king of clubs";
- case 33:
- case 34:
- return "nine of clubs";
- case 35:
- case 36:
- return "ace of spades";
- case 37:
- case 38:
- return "ten of spades";
- case 39:
- case 40:
- return "king of spades";
- case 41:
- case 42:
- return "nine of spades";
- case 43:
- case 44:
- return "ace of hearts";
- case 45:
- case 46:
- return "king of hearts";
- case 47:
- case 48:
- return "nine of hearts";
- default:
- return "something went wrong, please contact the admin. Error: code1. $card <br />";
- }
-}
-
function card_value($card)
{
switch($card)
diff --git a/output.php b/output.php
index fe4a971..f22c6df 100644
--- a/output.php
+++ b/output.php
@@ -179,9 +179,9 @@ function display_card($card,$dir="english")
* convert even cards to the matching odd value */
if( $card/2 - (int)($card/2) == 0.5)
- echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
+ echo "<img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" />\n";
else
- echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
+ echo "<img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" />\n";
return;
}
@@ -189,9 +189,9 @@ function display_card($card,$dir="english")
function display_link_card($card,$dir="english",$type="card")
{
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=\"\" /></div>\n";
+ 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";
else
- echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"\" /></div>\n";
+ 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";
return;
}