</head>
<body>
<h1> Welcome to E-Doko </h1>
-<p>
<?php
/*
* config
*/
$host = "http://doko.nubati.net/index.php";
+$wiki = "http://wiki.nubati.net/index.php?title=EmailDoko";
$debug = 0;
/*
function display_card($card)
{
if( $card/2 - (int)($card/2) == 0.5)
- echo "<img src=\"cards/".$card.".png\" height=\"100\" alt=\"".card_to_name($card)."\" />";
+ echo "<img src=\"cards/".$card.".png\" height=\"100\" alt=\"".card_to_name($card)."\" />\n";
else
- echo "<img src=\"cards/".($card-1).".png\" height=\"100\" alt=\"".card_to_name($card-1)."\" />";
+ echo "<img src=\"cards/".($card-1).".png\" height=\"100\" alt=\"".card_to_name($card-1)."\" />\n";
return;
}
function display_link_card($card,$me)
{
if( $card/2 - (int)($card/2) == 0.5)
- echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".$card.".png\" height=\"100\" alt=\"".card_to_name($card)."\" /></a>";
+ echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".$card.".png\" height=\"100\" alt=\"".card_to_name($card)."\" /></a>\n";
else
- echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".($card-1).".png\" height=\"100\" alt=\"".card_to_name($card-1)."\" /></a>";
+ echo "<a href=\"index.php?me=$me&card=$card\"><img src=\"cards/".($card-1).".png\" height=\"100\" alt=\"".card_to_name($card-1)."\" /></a>\n";
return;
}
return;
}
+echo "<p>If you find bugs, please list them in the <a href=\"".$wiki."\">wiki</a></p>\n";
+
$history=array();
/* check for status file and read it, if possible */
else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
{
echo "go back to ";
- echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />";
+ echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
}
else
{ /* show the hand */
$mycards = explode(";",$allcards);
sort($mycards);
- echo "your cards are <br>";
+ echo "your cards are <br>\n";
foreach($mycards as $card)
{
display_card($card);
if(check_wedding($player[$b]["cards"]))
{
echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />";
+ echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
}
else
{
- echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />";
+ echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
};
echo "do you have poverty?";
if(count_trump($player[$b]["cards"])<4)
{
echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />";
+ echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
}
else
{
- echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />";
+ echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
};
echo "do you have too many nines?";
if(count_nines($player[$b]["cards"])>4)
{
echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />";
+ echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
}
else
{
- echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />";
+ echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
};
echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
if(!isset($_REQUEST["solo"])|| !isset($_REQUEST["wedding"])|| !isset($_REQUEST["poverty"]) || !isset($_REQUEST["nines"]) )
{
echo "go back to ";
- echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />";
+ echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
}
else if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
{
}
else if($_REQUEST["wedding"] == "yes")
{
- echo "wedding was chosen<br>";
+ echo "wedding was chosen<br />\n";
$player[$c]["option"].="W";
}
else if($_REQUEST["poverty"] == "yes")
{
- echo "poverty was chosen<br>";
+ echo "poverty was chosen<br />\n";
$player[$c]["option"].="P";
}
else if($_REQUEST["nines"] == "yes")
{
- echo "nines was chosen<br>";
+ echo "nines was chosen<br />\n";
$player[$c]["option"].="N";
}
/* who is requesting this*/
if(!isset($_REQUEST["me"]))
- {
- if(!isset($_REQUEST["recovery"]))
- {
- echo "a game is in progress, but you are not playing.<br />";
- echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />";
-?>
+ {
+ if(!isset($_REQUEST["recovery"]))
+ {
+ echo "a game is in progress, but you are not playing.<br />\n";
+ echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
+ ?>
<form action="index.php" method="post">
recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
<input type="submit" value="get me back into the game" />
</form>
<?php
- }
- else
- {
- $recovery=$_REQUEST["recovery"];
- $ok=-1;
- for($i=0;$i<4;$i++)
- if(trim($recovery)==trim($player[$hash[$i]]["email"]))
- $ok=$i;
- if($ok>=0)
- {
- $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
- "\n if this doesn't work, contact the admin.\n";
- mymail($recovery,"[DoKo-Debug] recovery ",$message);
- echo "email has been sent.";
- }
- else
- {
- echo "can't find this email address, sorry.";
- };
- }
- }
+ }
+ else
+ {
+ $recovery=$_REQUEST["recovery"];
+ $ok=-1;
+ for($i=0;$i<4;$i++)
+ if(trim($recovery)==trim($player[$hash[$i]]["email"]))
+ $ok=$i;
+ if($ok>=0)
+ {
+ $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
+ "\n if this doesn't work, contact the admin.\n";
+ mymail($recovery,"[DoKo-Debug] recovery ",$message);
+ echo "email has been sent.";
+ }
+ else
+ {
+ echo "can't find this email address, sorry.";
+ };
+ } /* end recovery */
+ }
else
- {
+ { /* $me is set */
$me = $_REQUEST["me"];
-
- echo "game in progress and you are in it<br />";
+
+ echo "game in progress and you are in it<br />\n";
if($game["solo-who"]>=0)
- echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />";
+ echo $player[$hash[$game["solo-who"]]]["name"]." is playing a ".$game["solo-what"]." solo!<br />\n";
else if($game["wedding"]>=0)
- echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />";
+ echo $player[$hash[$game["wedding"]]]["name"]." is playing a wedding!<br />\n";
+ /* show history */
foreach($history as $play)
{
- echo "<br />";
-
+ echo "<br />\n";
+
$trick = explode(":",$play);
$last=-2;
}
}
+ /* figure out who needs to play next */
$next = $last + 1;
if ($next>=4)
$next -= 4 ;
{
$next=$history[sizeof($history)-1][0];
}
-
-
+
+ /* are we trying to play a card? */
if(isset($_REQUEST["card"]))
{
if($hash[$next]==$me)
{
- $card=$_REQUEST["card"];
+ $card = $_REQUEST["card"];
$mycards = explode(";",$player[$me]["cards"]);
+
+ /* do we have that card */
if(in_array($card,$mycards))
{
- $tmp=array();
+ /* delete card from array */
+ $tmp = array();
foreach($mycards as $m)
- if($m!=$card)
+ if($m != $card)
$tmp[]=$m;
+
$tmp2="";
for($i=0;$i<sizeof($tmp)-1;$i++)
{
$tmp2.=$tmp[$i];
$player[$me]["cards"]=$tmp2;
+ /* add card to history, special case if this is the first card */
if($last<0)
{
$history[sizeof($history)-1]="".$player[$me]["number"]."->".$card.":\n";
$history[sizeof($history)-1]=join(":",$tmp);
}
save_status();
-
+
echo " you played ";
display_card($card);
+
/* send out email to players who want/need to get informed */
for($i=0;$i<4;$i++)
{
if((ereg("c",$player[$hash[$i]]["option"]) || $i==$mynext) && $hash[$i]!=$me)
{
$message = " Hello ".$player[$hash[$i]]["name"].",\n\n";
-
+
if($i==$mynext)
- {
- $message .= "it's your turn now.\n".
- "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
- }
- $message .= $player[$me]["name"]. "has played the following card ".card_to_name($card)."\n";
+ {
+ $message .= "it's your turn now.\n".
+ "Use this link to play a card: ".$host."?me=".$hash[$i]."\n\n" ;
+ }
+ $message .= $player[$me]["name"]." has played the following card ".card_to_name($card)."\n";
if($game["solo-who"]>=0)
$message.= $player[$hash[$game["solo-who"]]]." is playing a ".$game["solo-what"]." solo!\n";
-
+
mymail($player[$hash[$i]]["email"],"[DoKo-debug] a card has been played",$message);
-
+
if($debug)
- echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />";
+ echo "<a href=\"index.php?me=".$hash[$mynext]."\"> next player </a> <br />\n";
}
}
}
else
- echo "seems like you don't have that card<br>";
-
+ echo "seems like you don't have that card<br />\n";
+
}
- }
+ } /* end if card is set */
else if(isset($_REQUEST["win"]) && strlen($history[sizeof($history)-1])>3)
{
$win=$_REQUEST["win"];
$points += card_value($c);
}
$player[$hash[$win]]["points"]+=$points;
- echo "<br> ".$player[$hash[$win]]["name"]." won: $points Points <br>";
-
+ echo "<br />\n ".$player[$hash[$win]]["name"]." won: $points Points <br />\n";
+
save_status();
- }
- echo "<br />";
+ }; /* end if win is set */
+ echo "<br />\n";
$tmp = explode(":",$history[sizeof($history)-1]);
+ /* check last history entry: end of a trick? ask who won it */
if(sizeof($tmp)==5)
{
?>
</form>
<?php
- }
+ }
else if(sizeof($tmp)<5 && 1<sizeof($tmp) && !isset($_REQUEST["card"]))
- {
+ {
if(sizeof($tmp)==2 && strlen($tmp[0])==1)
{
$next=$tmp[0];
-
+
if($debug)
- echo "DEBUG: the next move is for <a href=\"index.php?me=".$hash[$next]."\">the next player</a><br>";
-
+ echo "DEBUG: the next move is for <a href=\"index.php?me=".$hash[$next]."\">the next player</a><br />\n";
+
if(strlen(trim($player[$me]["cards"]))==0)
{
- echo "<br> game over, count points <br>";
+ echo "<br /> game over, count points <br />\n";
for($i=0;$i<4;$i++)
{
- echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br>";
+ echo $player[$hash[$i]]["name"]." got ".$player[$hash[$i]]["points"]."<br />\n";
}
}
}
- if($hash[$next]==$me && strlen(trim($player[$me]["cards"]))>0 )
+ echo "<br />\n";
+ } /* end check for winner */
+
+ /* do we still have cards? display them */
+ if(strlen(trim($player[$me]["cards"]))>0 )
+ {
+ $allcards = trim($player[$me]["cards"]);
+ $mycards = explode(";",$allcards);
+
+ sort($mycards);
+
+ echo "<p class=\"mycards\">\n";
+ /* is it our turn? */
+ if($hash[$next]==$me)
{
-
- echo "ITS YOUR TURN<br>";
- $allcards = trim($player[$me]["cards"]);
- $mycards = explode(";",$allcards);
-
- sort($mycards);
- echo "your cards are <br>";
+ echo "ITS YOUR TURN <br />\n";
+ echo "your cards are: <br />\n";
foreach($mycards as $card)
{
display_link_card($card,$me);
}
- echo "<br />\n";
}
- echo "<br />";
-
+ else
+ { /* not our turn, just show the hand */
+ echo "your cards are: <br />\n";
+ foreach($mycards as $card)
+ {
+ display_card($card);
+ }
+ }
+ echo "</p>\n";
}
}
}
}
?>
-</p>
</body>
</html>