J'avais créé, il y a de sa, deux ou trois bonne années, un jeux en PHP. Rien d'autre que : Pierre Papier Ciseau ET PUIT.
<?php
try
{
$connexion = new PDO('mysql:host='.$dbhost.';dbname='.$dbname, $dbuser, $dbpasswd);
}
catch(Exception $e)
{
echo 'Une erreur est survenue !';
die();
}
mt_srand((float) microtime()*1000000);
$chance = mt_rand(1, 4);
$chance2 = mt_rand(1, 2);
//
$resultats = $connexion->query("SELECT * FROM phpbb_users WHERE username='".$userdata['username']."'");
$resultats->setFetchMode(PDO::FETCH_OBJ);
$ligne = $resultats->fetch();
//
//Mode Victoire puit
if($jank == 'puit' AND $chance == '1' OR $chance == '2')
{
if($chance2 == "1")
{
echo"<img src='images/ciseau2.png'/>";
}
else
{
echo"<img src='images/roche2.png'/>";
}
}
//Mode Victoire roche
elseif($jank == 'roche' AND $chance == '1' OR $chance == '2')
{
echo"<img src='images/ciseau2.png'/>";
}
//Mode Victoire papier
elseif($jank == 'papier' AND $chance == '1' OR $chance == '2')
{
if($chance2 == "1")
{
echo"<img src='images/puit2.png'/>";
}
else
{
echo"<img src='images/roche2.png'/>";
}
}
//Mode Victoire ciseau
elseif($jank == 'ciseau' AND $chance == '1' OR $chance == '2')
{
echo"<img src='images/papier2.png'/>";
}
//Mode Match Nul pour tout
elseif($chance == '3')
{
echo'<img src="images/' . $jank . '2.png"/>';
}
//Mode Defaite puit
elseif($jank == 'puit' AND $chance == '4')
{
echo"<img src='images/papier2.png'/>";
}
//Mode Defaite roche
elseif($jank == 'roche' AND $chance == '4')
{
if($chance2 == "1")
{
echo"<img src='images/papier2.png'/>";
}
else
{
echo"<img src='images/puit2.png'/>";
}
}
//Mode Defaite papier
elseif($jank == 'papier' AND $chance == '4')
{
echo"<img src='images/ciseau2.png'/>";
}
//Mode Defaite ciseau
elseif($jank == 'ciseau' AND $chance == '4')
{
if($chance2 == "1")
{
echo"<img src='images/puit2.png'/>";
}
else
{
echo"<img src='images/roche2.png'/>";
}
}
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td colspan='3' align='center'>";
if($chance == '1' OR $chance == '2')
{
echo"<em class='bleu'>Arf t'a gagné...Continue Stp --</em><b class='bleu'>(+3)</b>";
$Pts = $Nb_pt + 3;
}
elseif($chance == '3')
{
echo"<em class='orange'>Match nul *flag*</em><b class='orange'>(+0)</b>";
$Pts = $Nb_pt;
}
else
{
echo"<em class='rouge'>Bon bah t'a perdu, serais-je trop fort pour toi?</em><b class='rouge'>(-5)</b>";
$Pts = $Nb_pt - 5;
if($Pts < 0)
{
$Pts = 0;
}
}
$points= $connexion->query("UPDATE phpbb_users SET xp_jaken=".$Pts." WHERE user_id= ".$ligne->user_id."");
?>
Voilà, j'ai amélioré les requêtes, mais après, pour réduire le code (c'est à dire, le coder en plus "poussé"), et avoir le même résultat, je bloque.. Une piste?merci d'avance,
Anthony