<?php
+/* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Arun Persaud <arun@nubati.net>
+ *
+ * This file is part of e-DoKo.
+ *
+ * e-DoKo is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * e-DoKo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with e-DoKo. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
/* make sure that we are not called from outside the scripts,
* use a variable defined in config.php to check this
*/
/* functions which only ouput html */
+function autoversion($file)
+{
+ /* changes the file name of e.g. css/style.css to css/style.<md5>.css/js
+ * this way the browser can cache the file and will reload it if the file changed
+ * needs to have .htaccess set up correctly to link back to css/style.css */
+
+ /* only use it for file that have an absolut path */
+ if(!file_exists(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file))
+ return $file;
+
+ $md5 = md5_file(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file);
+ return preg_replace('{\\.([^./]+)$}', ".$md5.\$1", $file);
+}
+
+
function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
{
global $RULES;
echo "<div class=\"message\">\n<form action=\"index.php?action=new\" method=\"post\">\n";
- echo "Do you want to continue playing?(This will start a new game, with the next person as dealer.)\n";
+ $output = sprintf(_('Do you want to continue playing? (This will start a new game, with %s starting the game.)'),$playerA);
+ echo $output."\n";
echo " <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
echo " <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
echo " <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
echo " <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
- echo " <input type=\"hidden\" name=\"dullen\" value=\"".$RULES["dullen"]."\" />\n";
- echo " <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES["schweinchen"]."\" />\n";
- echo " <input type=\"hidden\" name=\"callrule\" value=\"".$RULES["call"]."\" />\n";
+ echo " <input type=\"hidden\" name=\"dullen\" value=\"".$RULES['dullen']."\" />\n";
+ echo " <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES['schweinchen']."\" />\n";
+ echo " <input type=\"hidden\" name=\"callrule\" value=\"".$RULES['call']."\" />\n";
+ echo " <input type=\"hidden\" name=\"lowtrump\" value=\"".$RULES['lowtrump']."\" />\n";
echo " <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
- echo " <input type=\"submit\" value=\"keep playing\" />\n";
+ echo " <input type=\"submit\" value=\""._('keep playing')."\" />\n";
echo "</form>\n</div>";
return;
}
function output_form_for_new_game($names)
{
-?>
- <form action="index.php?action=new" method="post">
- <h2> Select players (Remember: you need to be one of the players) </h2>
+ $copy_names = $names; /* local copy, so that we can delete names from it
+ * after we selected them to make sure that each name
+ * only shows up once
+ */
- <div class="table">
- <img class="table" src="pics/table.png" alt="table" />
-<?php
- /* ask for player names */
- $i=0;
- foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
+ /* delete players name, since he will be on position D anyway */
+ unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
+ srand((float) microtime() * 10000000);
+
+
+ echo ' <form action="index.php?action=new" method="post">';
+ echo ' <h2> '._('Select players (Remember: you need to be one of the players)').' </h2>';
+
+ echo ' <div class="table">';
+
+ echo " <div class=\"table1\">\n";
+ $randkey = array_rand($copy_names);
+ $rand = $copy_names[$randkey];
+ /* delete this name from the list of possible names */
+ unset($copy_names[$randkey]);
+ echo " <select name=\"PlayerB\" size=\"1\"> \n";
+ foreach($names as $name)
{
- srand((float) microtime() * 10000000);
- $randkey = array_rand($names);
- $rand = $names[$randkey];
- echo " <div class=\"table".$i."\">\n";
- $i++;
- echo " <select name=\"$player\" size=\"1\"> \n";
- foreach($names as $name)
- {
- if($name==$rand)
- {
- echo " <option selected=\"selected\">$name</option>\n";
- }
- else
- echo " <option>$name</option>\n";
- }
- echo " </select>\n </div>\n";
+ if($name==$rand)
+ echo " <option selected=\"selected\">$name</option>\n";
+ else
+ echo " <option>$name</option>\n";
}
-?>
- </div>
-
- <h2 class="rules"> Rules </h2>
- <p> Some areas are grayed out which means that the rule is not implemented yet and therefore cannot be selected </p>
- <p> Ten of hearts: </p>
- <ul>
- <li> <input type="radio" name="dullen" value="none" /> just normal non-trump </li>
- <li> <input type="radio" name="dullen" value="firstwins" /> first ten of hearts wins the trick </li>
- <li> <input type="radio" name="dullen" value="secondwins" checked="checked" /> second ten of hearts wins the trick </li>
- </ul>
- <p> Schweinchen (both foxes), only in normal games or silent solos: </p>
- <ul>
- <li> <input type="radio" name="schweinchen" value="none" checked="checked" /> none </li>
- <li> <input type="radio" name="schweinchen" value="both" />
- both become highest trump (automatic call at beginning of the game)
- </li>
- <li> <input type="radio" name="schweinchen" value="second" />
- first one normal, second one becomes highest (call during the game) </li>
- <li> <input type="radio" name="schweinchen" value="secondaftercall" disabled="disabled" />
- second one become highest only in case re/contra was announced (not working yet)
- </li>
- </ul>
- <p> Call Re/Contra, etc.: </p>
- <ul>
- <li><input type="radio" name="callrule" value="1st-own-card" checked="checked" />
- Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.</li>
- <li><input type="radio" name="callrule" value="5th-card" />
- Can call re/contra until 5th card is played, 90 until 9th card is played, etc.</li>
- <li><input type="radio" name="callrule" value="9-cards" />
- Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.</li>
- </ul>
- <input type="submit" value="start game" />
- </form>
-<?php
+ echo " </select>\n </div>\n";
+
+ echo ' <div class="middle">';
+
+ $randkey = array_rand($copy_names);
+ $rand = $copy_names[$randkey];
+ /* delete this name from the list of possible names */
+ unset($copy_names[$randkey]);
+ echo " <div class=\"table0\">\n";
+ echo " <select name=\"PlayerA\" size=\"1\"> \n";
+ foreach($names as $name)
+ {
+ if($name==$rand)
+ echo " <option selected=\"selected\">$name</option>\n";
+ else
+ echo " <option>$name</option>\n";
+ }
+ echo " </select>\n </div>\n";
+
+ echo ' <img class="table" src="pics/table.png" alt="table" />';
+ $randkey = array_rand($copy_names);
+ $rand = $copy_names[$randkey];
+ /* delete this name from the list of possible names */
+ unset($copy_names[$randkey]);
+ echo " <div class=\"table2\">\n";
+ echo " <select name=\"PlayerC\" size=\"1\"> \n";
+ foreach($names as $name)
+ {
+ if($name==$rand)
+ echo " <option selected=\"selected\">$name</option>\n";
+ else
+ echo " <option>$name</option>\n";
+ }
+ echo " </select>\n </div>\n";
+
+ echo ' </div>';
+ $rand = $_SESSION["name"];
+ echo " <div class=\"table3\">\n";
+ echo " <select name=\"PlayerD\" size=\"1\"> \n";
+ foreach($names as $name)
+ {
+ if($name==$rand)
+ echo " <option selected=\"selected\">$name</option>\n";
+ else
+ echo " <option>$name</option>\n";
+ }
+ echo " </select>\n </div>\n";
+
+ /* ask player for names */
+
+ echo ' </div>';
+ echo '';
+ echo ' <h2 class="rules">'._('Rules').'</h2>';
+ echo ' <h3>'._('Gameplay-related').'</h3>';
+ echo ' <h4>'._('Ten of hearts').':</h4>';
+ echo ' <p>';
+ echo ' <select name="dullen">';
+ echo ' <option value="none"> '._('just normal non-trump').' </option>';
+ echo ' <option value="firstwins"> '._('first ten of hearts wins the trick').' </option>';
+ echo ' <option value="secondwins" selected="selected"> '.('second ten of hearts wins the trick').' </option>';
+ echo ' </select>';
+ echo ' </p>';
+ echo ' <h4>'._('Schweinchen (both foxes), only in normal games or silent solos').':</h4>';
+ echo ' <p>';
+ echo ' <select name="schweinchen">';
+ echo ' <option value="none" selected="selected"> '._('none').' </option>';
+ echo ' <option value="both"> '._('both become highest trump (automatic call at beginning of the game)').' </option>';
+ echo ' <option value="second"> '._('first one normal, second one becomes highest (call during the game)').' </option>';
+ echo ' <option value="secondaftercall"> ',_('second one become highest only in case re/contra was announced');
+ echo ' </option>';
+ echo ' </select>';
+ echo ' </p>';
+ echo ' <h4>'._('Call Re/Contra, etc.').':</h4>';
+ echo ' <p>';
+ echo ' <select name="callrule">';
+ echo ' <option value="1st-own-card" selected="selected"> '._('Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.').'</option>';
+ echo ' <option value="5th-card"> '._('Can call re/contra until 5th card is played, 90 until 9th card is played, etc.').'</option>';
+ echo ' <option value="9-cards" > '._('Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.').'</option>';
+ echo ' </select>';
+ echo ' </p>';
+ echo ' <h4>'._('Low trump').'</h4>';
+ echo ' <p>';
+ echo ' '._('Player can\'t trump a fox, that is none of his trump is higher than a fox.');
+ echo ' <select name="lowtrump">';
+ echo ' <option value="poverty">'._('The trump will be treated as poverty and offered to another player.').'</option>';
+ echo ' <option value="cancel"> '._('The game will be canceled unless there is a solo.').'</option>';
+ echo ' <option value="none"> '._('Bad luck, the player needs to play a normal game.').'</option>';
+ echo ' </select>';
+ echo ' </p>';
+ echo ' <h3>'._('Scoring-related').'</h3>';
+ echo ' <h4>'._('(not yet implemented)').'</h4>';
+ echo ' <p><input type="submit" value="'._('start game').'"></p>';
+ echo ' </form>';
+
}
-function output_table($data,$caption="",$class="")
+function output_table($data,$caption="",$class="",$id="")
{
+
+ $HTML = "\n<table";
+
if($class!="")
- $HTML = "\n<table class=\"$class\">\n";
- else
- $HTML = "\n<table>\n";
+ $HTML.= " class=\"$class\"";
+ if($id!="")
+ $HTML.= " id=\"$id\"";
+
+ $HTML.=">\n";
$i=0;