Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tableau = ["pierre", "feuille", "ciseaux"];
- $choixIA = $tableau[rand(0,2)];
- $choixUser = (string)readline("Choisissez pierre/feuille/ciseaux : ");
- $result;
- echo shifumi($choixUser, $choixIA);
- function shifumi($choixUser, $choixIA)
- {
- if(($choixUser === "feuille")||($choixUser === "pierre")||($choixUser === "ciseaux")){
- if($choixUser === $choixIA){
- description("Egalité", $choixIA);
- }elseif(($choixUser === "pierre")&&($choixIA === "feuille")){
- description("Perdu", $choixIA);
- if($choixIA === "ciseaux"){
- description("Gagné", $choixIA);
- }
- }elseif(($choixUser === "feuille")&&($choixIA === "ciseaux")){
- description("Perdu", $choixIA);
- if($choixIA === "pierre"){
- description("Gagné", $choixIA);
- }
- }elseif(($choixUser === "ciseaux")&&($choixIA === "pierre")){
- description("Perdu", $choixIA);
- if($choixIA === "feuille"){
- description("Gagné", $choixIA);
- }
- }
- }else{
- echo "Tu n'écris pas une bonne valeur, choisis entre pierre, feuille ou ciseaux ! \n";
- }
- }
- function description($result, $choixIA)
- {
- echo "Ton adversaire a choisi : ";
- sleep(1);
- echo "$choixIA \n";
- sleep(1);
- echo "==> $result ! \n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement