From: arun Date: Thu, 7 Dec 2006 10:47:11 +0000 (+0000) Subject: new database backend... kind of working X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=c997188d74716ef29f82da903435b95eec736d79 new database backend... kind of working --- diff --git a/create_database.sql b/create_database.sql new file mode 100644 index 0000000..9156bae --- /dev/null +++ b/create_database.sql @@ -0,0 +1,292 @@ +-- MySQL dump 10.9 +-- +-- Host: localhost Database: doko +-- ------------------------------------------------------ +-- Server version 4.1.10 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + +-- +-- Table structure for table `Card` +-- + +DROP TABLE IF EXISTS `Card`; +CREATE TABLE `Card` ( + `id` int(11) NOT NULL auto_increment, + `suite` enum('diamonds','hearts','spades','clubs') NOT NULL default 'diamonds', + `strength` enum('nine','ten','jack','queen','king','ace') NOT NULL default 'nine', + `points` tinyint(4) NOT NULL default '0', + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Card` +-- + + +/*!40000 ALTER TABLE `Card` DISABLE KEYS */; +LOCK TABLES `Card` WRITE; +INSERT INTO `Card` VALUES (1,'hearts','ten',10),(2,'hearts','ten',10),(3,'clubs','queen',3),(4,'clubs','queen',3),(5,'spades','queen',3),(6,'spades','queen',3),(7,'hearts','queen',3),(8,'hearts','queen',3),(9,'diamonds','queen',3),(10,'diamonds','queen',3),(11,'clubs','jack',2),(12,'clubs','jack',2),(13,'spades','jack',2),(14,'spades','jack',2),(15,'hearts','jack',2),(16,'hearts','jack',2),(17,'diamonds','jack',2),(18,'diamonds','jack',2),(19,'diamonds','ace',11),(20,'diamonds','ace',11),(21,'diamonds','ten',10),(22,'diamonds','ten',10),(23,'diamonds','king',4),(24,'diamonds','king',4),(25,'diamonds','nine',0),(26,'diamonds','nine',0),(27,'clubs','ace',11),(28,'clubs','ace',11),(29,'clubs','ten',10),(30,'clubs','ten',10),(31,'clubs','king',4),(32,'clubs','king',4),(33,'clubs','nine',0),(34,'clubs','nine',0),(35,'spades','ace',11),(36,'spades','ace',11),(37,'spades','ten',10),(38,'spades','ten',10),(39,'spades','king',4),(40,'spades','king',4),(41,'spades','nine',0),(42,'spades','nine',0),(43,'hearts','ace',11),(44,'hearts','ace',11),(45,'hearts','king',4),(46,'hearts','king',4),(47,'hearts','nine',0),(48,'hearts','nine',0); +UNLOCK TABLES; +/*!40000 ALTER TABLE `Card` ENABLE KEYS */; + +-- +-- Table structure for table `Comment` +-- + +DROP TABLE IF EXISTS `Comment`; +CREATE TABLE `Comment` ( + `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `create_date` timestamp NOT NULL default '0000-00-00 00:00:00', + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) default NULL, + `play_id` int(11) default NULL, + `comment` text, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Comment` +-- + + +/*!40000 ALTER TABLE `Comment` DISABLE KEYS */; +LOCK TABLES `Comment` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Comment` ENABLE KEYS */; + +-- +-- Table structure for table `Game` +-- + +DROP TABLE IF EXISTS `Game`; +CREATE TABLE `Game` ( + `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `create_date` timestamp NOT NULL default '0000-00-00 00:00:00', + `randomnumbers` varchar(136) default NULL, + `type` enum('solo','wedding','poverty','dpoverty') default NULL, + `solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL, + `id` int(11) NOT NULL auto_increment, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Game` +-- + + +/*!40000 ALTER TABLE `Game` DISABLE KEYS */; +LOCK TABLES `Game` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Game` ENABLE KEYS */; + +-- +-- Table structure for table `Hand` +-- + +DROP TABLE IF EXISTS `Hand`; +CREATE TABLE `Hand` ( + `id` int(11) NOT NULL auto_increment, + `game_id` int(11) NOT NULL default '0', + `user_id` int(11) NOT NULL default '0', + `hash` varchar(33) default NULL, + `status` enum('start','init','check','poverty','play','gameover') default 'start', + `position` tinyint(4) NOT NULL default '0', + `party` enum('re','contra') default NULL, + `sickness` enum('wedding','nines','poverty','solo') default NULL, + `solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL, + `sick_call` enum('true','false') default 'false', + `win_call` enum('true','false') default 'false', + `point_call` enum('90','60','30','0') default NULL, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Hand` +-- + + +/*!40000 ALTER TABLE `Hand` DISABLE KEYS */; +LOCK TABLES `Hand` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Hand` ENABLE KEYS */; + +-- +-- Table structure for table `Hand_Card` +-- + +DROP TABLE IF EXISTS `Hand_Card`; +CREATE TABLE `Hand_Card` ( + `id` int(11) NOT NULL auto_increment, + `hand_id` int(11) NOT NULL default '0', + `card_id` int(11) NOT NULL default '0', + `played` enum('true','false') default 'false', + UNIQUE KEY `id` (`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` +-- + +DROP TABLE IF EXISTS `Play`; +CREATE TABLE `Play` ( + `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `create_date` timestamp NOT NULL default '0000-00-00 00:00:00', + `id` int(11) NOT NULL auto_increment, + `trick_id` int(11) NOT NULL default '0', + `hand_card_id` int(11) NOT NULL default '0', + `sequence` tinyint(4) NOT NULL default '0', + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Play` +-- + + +/*!40000 ALTER TABLE `Play` DISABLE KEYS */; +LOCK TABLES `Play` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Play` ENABLE KEYS */; + +-- +-- Table structure for table `Score` +-- + +DROP TABLE IF EXISTS `Score`; +CREATE TABLE `Score` ( + `id` int(11) NOT NULL auto_increment, + `game_id` int(11) NOT NULL default '0', + `hand_id` int(11) NOT NULL default '0', + `score` tinyint(4) default NULL, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Score` +-- + + +/*!40000 ALTER TABLE `Score` DISABLE KEYS */; +LOCK TABLES `Score` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Score` ENABLE KEYS */; + +-- +-- Table structure for table `Trick` +-- + +DROP TABLE IF EXISTS `Trick`; +CREATE TABLE `Trick` ( + `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `create_date` timestamp NOT NULL default '0000-00-00 00:00:00', + `id` int(11) NOT NULL auto_increment, + `game_id` int(11) NOT NULL default '0', + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `Trick` +-- + + +/*!40000 ALTER TABLE `Trick` DISABLE KEYS */; +LOCK TABLES `Trick` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `Trick` ENABLE KEYS */; + +-- +-- Table structure for table `User` +-- + +DROP TABLE IF EXISTS `User`; +CREATE TABLE `User` ( + `id` int(11) NOT NULL auto_increment, + `fullname` varchar(64) default NULL, + `email` varchar(64) default NULL, + `password` varchar(32) default NULL, + `timezone` tinyint(2) default NULL, + `last_login` timestamp NOT NULL default '0000-00-00 00:00:00', + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `User` +-- + + +/*!40000 ALTER TABLE `User` DISABLE KEYS */; +LOCK TABLES `User` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `User` ENABLE KEYS */; + +-- +-- Table structure for table `User_Game_Prefs` +-- + +DROP TABLE IF EXISTS `User_Game_Prefs`; +CREATE TABLE `User_Game_Prefs` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL default '0', + `game_id` int(11) NOT NULL default '0', + `pref_key` varchar(64) default NULL, + `value` varchar(64) default NULL, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `User_Game_Prefs` +-- + + +/*!40000 ALTER TABLE `User_Game_Prefs` DISABLE KEYS */; +LOCK TABLES `User_Game_Prefs` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `User_Game_Prefs` ENABLE KEYS */; + +-- +-- Table structure for table `User_Prefs` +-- + +DROP TABLE IF EXISTS `User_Prefs`; +CREATE TABLE `User_Prefs` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL default '0', + `pref_key` varchar(64) default NULL, + `value` varchar(64) default NULL, + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `User_Prefs` +-- + + +/*!40000 ALTER TABLE `User_Prefs` DISABLE KEYS */; +LOCK TABLES `User_Prefs` WRITE; +UNLOCK TABLES; +/*!40000 ALTER TABLE `User_Prefs` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + diff --git a/db.php b/db.php new file mode 100644 index 0000000..bd37532 --- /dev/null +++ b/db.php @@ -0,0 +1,264 @@ +\n"; + } + return; +} + +function DB_get_email_by_name($name) +{ + echo "*looking for $name*"; + $result = mysql_query("SELECT email FROM user WHERE fullname=".DB_quote_smart($name).""); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return ""; +} + +function DB_get_userid_by_name($name) +{ + $result = mysql_query("SELECT id FROM user WHERE fullname=".DB_quote_smart($name)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} +function DB_get_userid_by_passwd($passwd) +{ + $result = mysql_query("SELECT id FROM user WHERE password=".DB_quote_smart($passwd)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} +function DB_get_userid_by_email($email) +{ + $result = mysql_query("SELECT id FROM user WHERE email=".DB_quote_smart($email)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_get_handid_by_hash($hash) +{ + $result = mysql_query("SELECT id FROM hand WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_get_userid_by_hash($hash) +{ + $result = mysql_query("SELECT user_id FROM hand WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_get_pos_by_hash($hash) +{ + $result = mysql_query("SELECT position FROM hand WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_get_name_by_hash($hash) +{ + $result = mysql_query("SELECT fullname FROM hand LEFT JOIN user ON hand.user_id=user.id WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return ""; +} + +function DB_get_status_by_hash($hash) +{ + $result = mysql_query("SELECT status FROM hand WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_set_hand_status_by_hash($hash,$status) +{ + mysql_query("UPDATE hand SET status='".$status."' WHERE hash=".DB_quote_smart($hash)); + return; +} + +function DB_get_gameid_by_hash($hash) +{ + $result = mysql_query("SELECT game_id FROM hand WHERE hash=".DB_quote_smart($hash)); + $r = mysql_fetch_array($result,MYSQL_NUM); + + if($r) + return $r[0]; + else + return 0; +} + +function DB_cancel_game($hash) +{ + $gameid = DB_get_gameid_by_hash($me); + + if(!$gameid) + return; + + /* get the IDs of all players */ + $result = mysql_query("SELECT id FROM hand WHERE game_id=".DB_quote_smart($gameid)); + while($r = mysql_fetch_array($result,MYSQL_NUM)) + { + $id = $r[0]; + + $tmp = mysql_query("SELECT id FROM hand_card WHERE hand_id=".DB_quote_smart($id)); + $tmp = mysql_fetch_array($tmp,MYSQL_NUM); + mysql_query("DELETE FROM play WHERE hand_card_id=".DB_quote_smart($tmp[0])); + + + mysql_query("DELETE FROM hand_card WHERE hand_id=".DB_quote_smart($id)); + mysql_query("DELETE FROM score WHERE hand_id=".DB_quote_smart($id)); + mysql_query("DELETE FROM hand WHERE id=".DB_quote_smart($id)); + } + + /* delete game */ + mysql_query("DELETE FROM user_game_prefs WHERE game_id=".DB_quote_smart($gameid)); + mysql_query("DELETE FROM trick WHERE game_id=".DB_quote_smart($gameid)); + mysql_query("DELETE FROM game WHERE id=".DB_quote_smart($gameid)); + + return; +} + +function DB_get_hand($me) +{ + $cards = array(); + + $handid = DB_get_handid_by_hash($me); + + $result = mysql_query("SELECT card_id FROM hand_card WHERE hand_id=".DB_quote_smart($handid)." and played='false' "); + while($r = mysql_fetch_array($result,MYSQL_NUM)) + $cards[]=$r[0]; + + return $cards; +} + +function DB_set_solo_by_hash($me,$solo) +{ + mysql_query("UPDATE hand SET solo=".DB_quote_smart($solo)." WHERE hash=".DB_quote_smart($hash)); + return; +} + +function DB_set_sickness_by_hash($me,$sickness) +{ + mysql_query("UPDATE hand SET sickness=".DB_quote_smart($sickness)." WHERE hash=".DB_quote_smart($hash)); + return; +} + +function DB_get_current_trickid($gameid) +{ + $result = mysql_query("SELECT trick.id,MAX(play.sequence) FROM play ". + "LEFT JOIN trick ON play.trick_id=trick.id ". + "WHERE trick.game_id=".DB_quote_smart($gameid)." ". + "GROUP BY trick.id"); + while( $r = mysql_fetch_array($result,MYSQL_NUM) ) + { + $trickid = $r[0]; + $sequence = $r[1]; + }; + + if(!$sequence || $sequence==4) + { + mysql_query("INSERT INTO trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).")"); + $trickid = mysql_insert_id(); + $sequence = 1; + } + else + { + $sequence++; + } + + return array($trickid,$sequence); +} + +function DB_get_max_trickid($gameid) +{ + $result = mysql_query("SELECT MAX(id) FROM trick WHERE game_id=".DB_quote_smart($gameid)); + $r = mysql_fetch_array($result,MYSQL_NUM) ; + + + return ($r?$r[0]:NULL); +} + +function DB_play_card($trickid,$handcardid,$sequence) +{ + mysql_query("INSERT into play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid). + ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")"); + return; +} + +?> \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..0ce10e2 --- /dev/null +++ b/functions.php @@ -0,0 +1,434 @@ +",$message); + echo "
To: $To
Subject: $Subject
$message
\n"; + } + else + mail($To,$Subject,$message); + return; +} + +function is_trump($c) { return (($c<27) ? 1:0);} +function is_club($c) { return (in_array($c,array('27','28','29','30','31','32','33','34')));} +function is_spade($c) { return (in_array($c,array('35','36','37','38','39','40','41','42')));} +function is_heart($c) { return (in_array($c,array('43','44','45','46','47','48')));} + +function compare_cards($a,$b) +{ + /* if a is higher than b return 1, else 0, a being the card first played */ + + /* first map all cards to the odd number */ + if( $a/2 - (int)($a/2) != 0.5) + $a--; + if( $b/2 - (int)($b/2) != 0.5) + $b--; + + if(is_trump($a) && $a<=$b) + return 1; + else if(is_trump($a) && $a>$b) + return 0; + else + { /*$a is not a trump */ + if(is_trump($b)) + return 0; + else + { + /* both clubs? */ + if( is_club($a) && is_club($b)) + if($a<=$b) + return 1; + else + return 0; + /* both spade? */ + if( is_spade($a) && is_spade($b)) + if($a<=$b) + return 1; + else + return 0; + /* both heart? */ + if( is_heart($a) && is_heart($b)) + if($a<=$b) + return 1; + else + return 0; + return 1; + } + } + +} + +function get_winner($p) +{ + /* get all 4 cards played in a trick */ + $c1 = $p[1]; + $c2 = $p[2]; + $c3 = $p[3]; + $c4 = $p[4]; + + /* find out who won */ + if( compare_cards($c1,$c2) && compare_cards($c1,$c3) && compare_cards($c1,$c4) ) + return 1; + if( compare_cards($c2,$c3) && compare_cards($c2,$c4) ) + return 2; + if( compare_cards($c3,$c4) ) + return 3; + return 4; +} + +function count_nines($cards) +{ + $nines = 0; + + foreach($cards as $c) + { + if($c == "25" || $c == "26") $nines++; + else if($c == "33" || $c == "34") $nines++; + else if($c == "41" || $c == "42") $nines++; + else if($c == "47" || $c == "48") $nines++; + } + + return $nines; +} + +function check_wedding($cards) +{ + + if( in_array("3",$cards) && in_array("2",$cards) ) + return 1; + + return 0; +} + +function count_trump($cards) +{ + $trump = 0; + + /* count each trump */ + foreach($cards as $c) + if( (int)($c) <27) + $trump++; + + /* subtract foxes */ + if( in_array("19",$cards)) + $trump--; + if( in_array("20",$cards) ) + $trump--; + /* add one, in case the player has both foxes (schweinchen) */ + if( in_array("19",$cards) && in_array("20",$cards) ) + $trump++; + + 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."; + } +} + +function card_value($card) +{ + switch($card) + { + case 1: /* heart */ + case 2: + return 10; + case 3: /* clubes */ + case 4: + case 5: /* spades */ + case 6: + case 7: /* hearts */ + case 8: + case 9: /* diamonds */ + case 10: + return 3; + case 11: /* clubes */ + case 12: + case 13: /* spades */ + case 14: + case 15: /* hearts */ + case 16: + case 17: /* diamonds */ + case 18: + return 2; + case 19: /* diamonds */ + case 20: + case 27: /* clubs */ + case 28: + case 35: /* spades */ + case 36: + case 43: /* hearts */ + case 44: + return 11; + case 21: /* diamonds */ + case 22: + case 29: /* clubs */ + case 30: + case 37: /* spades */ + case 38: + return 10; + case 23: /* diamonds */ + case 24: + case 31: /* clubs */ + case 32: + case 39: /* spades */ + case 40: + case 45: /* hearts */ + case 46: + return 4; + case 25: /* diamonds */ + case 26: + case 33: /* clubs */ + case 34: + case 41: /* spades */ + case 42: + case 47: /* hearts */ + case 48: + return 0; + default: + echo "something went wrong, please contact the admin. ErrorCode: 2
"; + return 0; + } +} + +function display_card($card) +{ + /* 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) + echo "\"".card_to_name($card)."\"\n"; + else + echo "\"".card_to_name($card-1)."\"\n"; + + return; +} + +function display_link_card($card) +{ + if( $card/2 - (int)($card/2) == 0.5) + echo "\"\"\n"; + else + echo "\"\"\n"; + return; +} + +function create_array_of_random_numbers() +{ + $r = array(); + $a = array(); + + for($i=1;$i<49;$i++) + $a[$i]=$i; + + $r = array_rand($a,48); + + return $r; +} + +function check_want_to_play($me) +{ + ?> +
+ Do you want to play a game of DoKo? + yes + no
+ + Do you want to get an email for every card played or only if it your move? + every card + only on my turn
+\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + return; +} + +function check_for_sickness($me,$mycards) +{ + ?> +

nothing implemented so far, but give it a try anyway ;)

+ +
+ + do you want to play solo? + +
+ + "; + echo " no
\n"; + } + else + { + echo " no
\n"; + }; + + echo "do you have poverty?"; + if(count_trump($mycards)<4) + { + echo " yes"; + echo " no
\n"; + } + else + { + echo " no
\n"; + }; + + echo "do you have too many nines?"; + if(count_nines($mycards)>4) + { + echo " yes"; + echo " no
\n"; + } + else + { + echo " no
\n"; + }; + + echo "\n"; + echo "\n"; + + echo "
\n"; + + return; +} + +function display_status() +{ + echo "
"; + echo " is someone playing solo, etc?"; + echo "
"; + + return; +} + +function display_news() +{ + global $wiki; + echo "
". + "Please hit shift+reload.

". + "New Database backend, lost a few features on the way.

". + "If you find more bugs, please list them in the wiki.
\n"; + return; +} + +function display_cards($me,$myturn) +{ + return; +} + +?> \ No newline at end of file diff --git a/index.php b/index.php index e86854c..d13e3bb 100644 --- a/index.php +++ b/index.php @@ -3,9 +3,9 @@ "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"> - e-DoKo + e-Doko - +