saving php5 version
This commit is contained in:
commit
c2c1ee7b9b
46 changed files with 817 additions and 0 deletions
88
poker_pott.php
Executable file
88
poker_pott.php
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
$FirstMoreThanSecond = (isset($_POST['FMTS']) && $_POST['FMTS']) ? $_POST['FMTS']:3;
|
||||
$SecondMoreThanThird = (isset($_POST['FMTT']) && $_POST['FMTT']) ? $_POST['FMTT']:2;
|
||||
$Stake = (isset($_POST['Stake']) && $_POST['Stake']) ? $_POST['Stake']:2;
|
||||
|
||||
function GetDotByPott ($Pott)
|
||||
{
|
||||
global $FirstMoreThanSecond;
|
||||
global $SecondMoreThanThird;
|
||||
|
||||
$FMTS = $FirstMoreThanSecond;
|
||||
$SMTT = $SecondMoreThanThird;
|
||||
|
||||
$a=$b=0; //1st and 2nd place
|
||||
$c=$Pott; //3th starts with all the money
|
||||
while (!( ($a>=($FMTS*$b)) && ($b>=$SMTT*$c) ))
|
||||
{
|
||||
//transport from c to b
|
||||
if ($b<($SMTT*$c) && $c>0)
|
||||
{
|
||||
$b++;
|
||||
$c--;
|
||||
}
|
||||
//transport from b to a
|
||||
if ($a<($FMTS*$b) && $b>0)
|
||||
{
|
||||
$a++;
|
||||
$b--;
|
||||
}
|
||||
}
|
||||
$RetVal=array();
|
||||
$RetVal[0]=0; //empty
|
||||
$RetVal[1]=$a; //1st place
|
||||
$RetVal[2]=$b; //2nd place
|
||||
$RetVal[3]=$c; //3th place
|
||||
return $RetVal;
|
||||
}
|
||||
$BODY.='<form action="index.php?page=poker_pott" method="post">';
|
||||
$BODY.='<input type="hidden" name="page" value="poker_pott">';
|
||||
$BODY.='Einsatz: ';
|
||||
$BODY.='<select name="Stake">';
|
||||
for ($i=1;$i<=10;$i++)
|
||||
{
|
||||
$BODY.='<option value="'.$i.'"'.(($Stake==$i)? "selected":"").'>'.$i.'€</option>';
|
||||
}
|
||||
$BODY.="</select><br>";
|
||||
|
||||
$BODY.='Erster bekommt mindestens ';
|
||||
$BODY.='<select name="FMTS">';
|
||||
for ($i=1;$i<=10;$i++)
|
||||
{
|
||||
$BODY.='<option value="'.$i.'"'.(($FirstMoreThanSecond==$i)? "selected":"").'>'.$i.' mal</option>';
|
||||
}
|
||||
$BODY.="</select>mehr als der Zweite<br>";
|
||||
|
||||
$BODY.='Zweiter bekommt mindestens ';
|
||||
$BODY.='<select name="FMTT">';
|
||||
for ($i=1;$i<=10;$i++)
|
||||
{
|
||||
$BODY.='<option value="'.$i.'"'.(($SecondMoreThanThird==$i)? "selected":"").'>'.$i.' mal</option>';
|
||||
}
|
||||
$BODY.="</select>mehr als der Dritte<br>";
|
||||
|
||||
$BODY.='<input type="submit" value="Neu Berechnen">';
|
||||
|
||||
$BODY.='</form>';
|
||||
|
||||
$BODY.= "<table class=\"list\">";
|
||||
$BODY.= "<tr>";
|
||||
$BODY.= "<th>Spieler</th>";
|
||||
$BODY.= "<th>Pott</th>";
|
||||
$BODY.= "<th>1.Platz</th>";
|
||||
$BODY.= "<th>2.Platz</th>";
|
||||
$BODY.= "<th>3.Platz</th>";
|
||||
$BODY.= "</tr>";
|
||||
for ($i=4; $i<=20; $i++)
|
||||
{
|
||||
$Ret = GetDotByPott($Stake*$i);
|
||||
$BODY.= "<tr>";
|
||||
$BODY.= "<td>".$i."</td>";
|
||||
$BODY.= "<td>".($i*$Stake)."€</td>";
|
||||
$BODY.= "<td><strong>".$Ret[1]."€</strong></td>";
|
||||
$BODY.= "<td><strong>".$Ret[2]."€</strong></td>";
|
||||
$BODY.= "<td><strong>".$Ret[3]."€</strong></td>";
|
||||
$BODY.= "</tr>";
|
||||
}
|
||||
$BODY.= "</table>";
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue