Viewing file: index.phtml (4.6 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
$fighters = array( 1 => "Kucharszewski, Tomasz", "Roufus, Duke", "Leuyer, ?", "Lalonde, ?", "Fernandezi, ?", "McDonald, ?", "Smith, Maurice", "Singer" );
$endrounds = array( "1" => "1st Round", "2" => "2nd Round", "3" => "3rd Round", "OT" => "Overtime" );
$reasons = array( "ko" => "Knockout", "cut" => "Stop from cut", "dq" => "Disqualification", "dec" => "Decision", "towel" => "Towel thrown" );
$roundnames = array( 0 => "AX - K-1 USA Contest! - Welcome!", 1 => "AX - K-1 USA Contest! - eliminator matches", 2 => "AX - K-1 USA Contest! - semi-final matches", 3 => "AX - K-1 USA Contest! - final match" );
$fights = array( 0 => 8, 1 => 4, 2 => 2, 3 => 1 );
$rounds=3; // of the tournament, not of individual fights
function showrules() { echo "rules for the game here.</p>\n"; }
function arraylist($array) { reset($array); while (list($key,$val)=each($array)) { echo $key,"=>"; if (is_array($val)) {echo "<blockquote>"; arraylist($val); echo "</blockquote>";} else {echo $val;}; echo "<br>\n"; } }
// *** MAIN ***
//arraylist($HTTP_POST_VARS);
$round=$round+0;
// checking whether winners were chosen for all fights
if ($round>1) for($a=0;$a<$fights[$round-1];$a++) { if (empty($HTTP_POST_VARS[picks][$round-2][$a][winner])) { $round--; $err=1; break; } }
echo "<head><title>",$roundnames[$round],"</title></head><body>\n"; echo "<h1>",$roundnames[$round],"</h1>\n";
switch($round) { case "1": case "2": case "3": case "4": if ($err) { echo "<b>You can't leave a fight without a winner!</b>"; } else if ($round>$rounds) { echo "<b>Please review your choices before submitting:</b>"; } else { echo "<b>Please give the results of the following fights:</b>"; };
echo "<form method=post>\n"; echo "<table border>"; for ($a=0;$a<8;$a++) { echo "<tr><td>",$fighters[$a+1],"</td>\n"; $step=1; for ($b=1;$b<$round;$b++) { $step=$step*2; if (($a % $step) ==0) { echo "<td rowspan=$step>\n"; $choice=$HTTP_POST_VARS[picks][$b-1][$a/$step]; echo "<b>",$fighters[$choice[winner]],"</b><br>\n"; echo $endrounds[$choice[round]],"\n"; echo $reasons[$choice[reason]],"\n"; echo "<input type=hidden name=picks[",$b-1,"][",$a/$step,"][winner] value=",$choice[winner],">\n"; echo "<input type=hidden name=picks[",$b-1,"][",$a/$step,"][round] value=",$choice[round],">\n"; echo "<input type=hidden name=picks[",$b-1,"][",$a/$step,"][reason] value=",$choice[reason],">\n"; echo "</td>\n"; } } if (($round<=$rounds) && (($a % ($step*2)) == 0)) { echo "<td rowspan=",$step*2,">"; if ($round==1) { $fightera=$a+1; $fighterb=$a+2; } else { $fightera=$HTTP_POST_VARS[picks][$round-2][$a/$step][winner]; $fighterb=$HTTP_POST_VARS[picks][$round-2][$a/$step+1][winner]; };
echo "<select name=picks[",$round-1,"][",$a/(2*$step),"][winner]>\n"; echo "<option value=\"\">(Fighter)</option>\n"; echo "<option "; if ($HTTP_POST_VARS[picks][$round-1][$a/(2*$step)][winner]==$fightera) echo "selected "; echo "value=",$fightera,">",$fighters[$fightera],"</option>\n"; echo "<option "; if ($HTTP_POST_VARS[picks][$round-1][$a/(2*$step)][winner]==$fighterb) echo "selected "; echo "value=",$fighterb,">",$fighters[$fighterb],"</option>\n"; echo "</select>\n";
echo "<select name=picks[",$round-1,"][",$a/(2*$step),"][reason]>\n"; echo "<option value=\"\">(Result)</option>\n"; reset($reasons); reset($reasons); while (list($key,$val)=each($reasons)) { echo "<option "; if ($HTTP_POST_VARS[picks][$round-1][$a/(2*$step)][reason]==$key) echo "selected "; echo "value=$key>$val</option>\n"; } echo "</select>\n";
echo "<select name=picks[",$round-1,"][",$a/(2*$step),"][round]>\n"; echo "<option value=\"\">(Round)</option>\n"; reset($endrounds); while (list($key,$val)=each($endrounds)) { echo "<option "; if ($HTTP_POST_VARS[picks][$round-1][$a/(2*$step)][round]==$key) echo "selected "; echo "value=$key>$val</option>\n"; } echo "</select>\n";
echo "</td>\n"; } } echo "</table>"; echo "<input type=hidden name=round value=",$round+1,">"; if ($round>$rounds) { echo "<input type=submit name=send value=\"Submit guesses!\">"; } else { echo "<input type=submit name=send value=\"Next!\">"; } echo "</form>\n"; break; case "5": echo "Submitting guesses will come here."; break; default: showrules(); echo "<form method=post><input type=hidden name=round value=1><input type=submit name=send value=\"Play the game!\"></form>"; break; } ?> </body> </html>
|