summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarun <arun@nubati.net>2006-11-14 20:00:18 +0000
committerarun <arun>2006-11-14 20:00:18 +0000
commit75ad669f06207b8e2813c7ae4f238d46dab25160 (patch)
tree05e127c9ee18655d5b2014b8265589e732bed63f
downloade-DoKo-75ad669f06207b8e2813c7ae4f238d46dab25160.tar.gz
e-DoKo-75ad669f06207b8e2813c7ae4f238d46dab25160.tar.bz2
e-DoKo-75ad669f06207b8e2813c7ae4f238d46dab25160.zip
Initial import
-rw-r--r--index.php210
-rw-r--r--random.txt4
-rw-r--r--status.txt5
3 files changed, 219 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..90b91ce
--- /dev/null
+++ b/index.php
@@ -0,0 +1,210 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
+ "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+ <head>
+ <title>Doko via email</title>
+ <link rel="stylesheet" type="text/css" href="standard.css"/>
+ </head>
+<body>
+<h1> Welcome to E-Doko </h1>
+
+<?php
+/* check for status file and read it, if possible */
+
+if(file_exists("status.txt"))
+ $lines = file("status.txt");
+else
+ die("no file");
+
+/* check if we want to start a new game */
+if( isset($_REQUEST["PlayerA"]) &&
+ isset($_REQUEST["PlayerB"]) &&
+ isset($_REQUEST["PlayerC"]) &&
+ isset($_REQUEST["PlayerD"]) &&
+ isset($_REQUEST["EmailA"]) &&
+ isset($_REQUEST["EmailB"]) &&
+ isset($_REQUEST["EmailC"]) &&
+ isset($_REQUEST["EmailD"]) )
+{
+ $PlayerA = $_REQUEST["PlayerA"];
+ $PlayerB = $_REQUEST["PlayerB"];
+ $PlayerC = $_REQUEST["PlayerC"];
+ $PlayerD = $_REQUEST["PlayerD"];
+ $EmailA = $_REQUEST["EmailA"] ;
+ $EmailB = $_REQUEST["EmailB"] ;
+ $EmailC = $_REQUEST["EmailC"] ;
+ $EmailD = $_REQUEST["EmailD"] ;
+
+ /* send out email, check for error with email */
+ echo "send out emails to everyone, asking if they want to join";
+ echo "use link <br>";
+ echo "<a href=\"index.php?a=hash1\"> player 1</a> <br />";
+ echo "<a href=\"index.php?a=hash2\"> player 2</a> <br />";
+ echo "<a href=\"index.php?a=hash3\"> player 3</a> <br />";
+ echo "<a href=\"index.php?a=hash4\"> player 4</a> <br />";
+ /* read in random.txt */
+ if(file_exists("random.txt"))
+ $random = file("random.txt");
+ else
+ die("no random file");
+
+ $randomNR = explode( ":", $random[1] );
+
+ /* write status into file */
+ $output = fopen("status.txt","w");
+ if ($output)
+ {
+ fwrite($output, "0\n");
+
+ fwrite($output, "hash1:".$PlayerA.":".$EmailA."::" );
+ for($i=0;$i<12;$i++)
+ fwrite($output,";$randomNR[$i]" );
+ fwrite($output,"\n");
+
+ fwrite($output, "hash2:$PlayerB:$EmailB::" );
+ for(;$i<24;$i++)
+ fwrite($output,";$randomNR[$i]" );
+ fwrite($output,"\n");
+
+ fwrite($output, "hash3:$PlayerC:$EmailC::" );
+ for(;$i<36;$i++)
+ fwrite($output,";$randomNR[$i]" );
+ fwrite($output,"\n");
+
+ fwrite($output, "hash4:$PlayerD:$EmailD::");
+ for(;$i<48;$i++)
+ fwrite($output,";$randomNR[$i]" );
+ fwrite($output,"\n");
+
+ fclose($output);
+ }
+ else
+ echo "can't open file for writing";
+};
+
+/* test if a game is running, else output everything for a new game */
+if(sizeof($lines)<2)
+{
+?>
+ <p> no game in progress, please input 4 names and email addresses </p>
+ <form action="index.php" method="post">
+ Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
+ Email: <input name="EmailA" type="text" size="10" maxlength="20" /> <br />
+
+ Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
+ Email: <input name="EmailB" type="text" size="10" maxlength="20" /> <br />
+
+ Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
+ Email: <input name="EmailC" type="text" size="10" maxlength="20" /> <br />
+
+ Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
+ Email: <input name="EmailD" type="text" size="10" maxlength="20" /> <br />
+
+ <input type="submit" value="start game" />
+ </form>
+<?php
+}
+else
+{ /* load game status */
+ $tmp = explode( ":",$lines[1]);
+ $player[$tmp[0]]["name"] = $tmp[1];
+ $player[$tmp[0]]["email"] = $tmp[2];
+ $player[$tmp[0]]["option"] = $tmp[3];
+ $player[$tmp[0]]["cards"] = $tmp[4];
+
+ $tmp = explode( ":",$lines[2]);
+ $player[$tmp[0]]["name"] = $tmp[1];
+ $player[$tmp[0]]["email"] = $tmp[2];
+ $player[$tmp[0]]["option"] = $tmp[3];
+ $player[$tmp[0]]["cards"] = $tmp[4];
+
+ $tmp = explode( ":",$lines[3]);
+ $player[$tmp[0]]["name"] = $tmp[1];
+ $player[$tmp[0]]["email"] = $tmp[2];
+ $player[$tmp[0]]["option"] = $tmp[3];
+ $player[$tmp[0]]["cards"] = $tmp[4];
+
+ $tmp = explode( ":",$lines[4]);
+ $player[$tmp[0]]["name"] = $tmp[1];
+ $player[$tmp[0]]["email"] = $tmp[2];
+ $player[$tmp[0]]["option"] = $tmp[3];
+ $player[$tmp[0]]["cards"] = $tmp[4];
+}
+
+/* check if a player wants to accept a game */
+if(isset($_REQUEST["a"]))
+{
+ $a=$_REQUEST["a"];
+?>
+ <form action="index.php" method="post">
+ Do you want to play a game of DoKo?
+ yes<input type="radio" name="in" value="yes" />
+ no<input type="radio" name="in" value="no" /> <br />
+
+ Do you want to get an email for every card played or only if it your move?
+ every card<input type="radio" name="update" value="card" />
+ only on my turn<input type="radio" name="update" value="turn" /> <br />
+<?php
+ echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
+ echo "\n";
+ echo "<input type=\"submit\" value=\"count me in\" />\n";
+ echo " </form>\n";
+}
+ /* yes? email him his hand, ask for solo, poverty, email every move or every card? */
+if(isset($_REQUEST["b"]))
+{
+ $b=$_REQUEST["b"];
+ echo "hash is $b <br>";
+ if(!isset($_REQUEST["in"])|| !isset($_REQUEST["update"]) )
+ {
+ echo "go back to ";
+ echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />";
+ }
+ else
+ { /* show the hand */
+ echo $player[$b]["cards"];
+ $tmp = $player[$b]["cards"];
+ $cards = explode( ":",$tmp);
+ echo "your cards are";
+ foreach($cards as $card) echo " $card ";
+ echo "<br />\n";
+ ?>
+ <form action="index.php" method="post">
+
+ do you want to play solo?
+ yes<input type="radio" name="solo" value="yes" />
+ no<input type="radio" name="solo" value="no" /> <br />
+
+ do you have a wedding?
+ yes<input type="radio" name="wedding" value="yes" />
+ no<input type="radio" name="wedding" value="no" /> <br />
+
+ do you have poverty?
+ yes<input type="radio" name="poverty" value="yes" />
+ no<input type="radio" name="poverty" value="no" /> <br />
+
+
+ <input type="hidden" name="c" value="$b" />
+
+ <input type="submit" value="count me in" />
+
+ </form>
+
+<?php
+ }
+} /* is this the last player that needs to accept? */
+ /* yes, figure out who starts, send out email to first player */
+ /* no, email the rest to cancel game */
+
+/* player wants to make a move? */
+ /* check if it is this players turn it is (if it's the players turn, convert cards into links) */
+ /* if it is the last card played*/
+ /* add checkbox for who one the trick */
+ /* email next player */
+ /* last card played? */
+ /* count score for each player */
+?>
+
+</body>
+</html>
diff --git a/random.txt b/random.txt
new file mode 100644
index 0000000..4c57a78
--- /dev/null
+++ b/random.txt
@@ -0,0 +1,4 @@
+16:28:37:44:7:39:9:2:21:41:27:42:43:46:8:17:4:25:31:45:23:35:30:18:24:6:29:34:26:48:14:32:19:3:1:47:40:33:5:22:20:38:13:15:12:36:10:11:
+30:15:45:41:32:5:9:14:42:20:27:40:1:19:21:18:26:6:43:29:31:33:37:13:4:46:24:22:35:7:16:38:2:28:23:48:47:10:3:8:39:11:36:44:17:12:34:25:
+22:8:16:36:21:24:41:27:12:14:25:2:26:48:10:47:18:35:33:3:39:4:9:15:30:13:31:38:19:45:6:29:42:23:37:5:1:32:46:40:28:44:7:43:17:34:20:11:
+19:14:48:15:6:7:25:43:18:17:24:9:44:45:2:27:8:31:30:1:16:41:20:37:29:32:40:11:47:46:13:42:4:33:3:23:10:39:21:28:36:38:5:35:22:12:34:26:
diff --git a/status.txt b/status.txt
new file mode 100644
index 0000000..20f66ab
--- /dev/null
+++ b/status.txt
@@ -0,0 +1,5 @@
+0
+hash1:a:bbv::;30;15;45;41;32;5;9;14;42;20;27;40
+hash2:b:asdf::;1;19;21;18;26;6;43;29;31;33;37;13
+hash3:da:sd::;4;46;24;22;35;7;16;38;2;28;23;48
+hash4:kljdkljs:asdf@sdf::;47;10;3;8;39;11;36;44;17;12;34;25