Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. $tableau = ["pierre", "feuille", "ciseaux"];
  4. $choixIA = $tableau[rand(0,2)];
  5. $choixUser = (string)readline("Choisissez pierre/feuille/ciseaux : ");
  6. $result;
  7.  
  8. echo shifumi($choixUser, $choixIA);
  9.  
  10. function shifumi($choixUser, $choixIA)
  11. {
  12. if(($choixUser === "feuille")||($choixUser === "pierre")||($choixUser === "ciseaux")){
  13. if($choixUser === $choixIA){
  14. description("Egalité", $choixIA);
  15. }elseif(($choixUser === "pierre")&&($choixIA === "feuille")){
  16. description("Perdu", $choixIA);
  17. if($choixIA === "ciseaux"){
  18. description("Gagné", $choixIA);
  19. }
  20. }elseif(($choixUser === "feuille")&&($choixIA === "ciseaux")){
  21. description("Perdu", $choixIA);
  22. if($choixIA === "pierre"){
  23. description("Gagné", $choixIA);
  24. }
  25. }elseif(($choixUser === "ciseaux")&&($choixIA === "pierre")){
  26. description("Perdu", $choixIA);
  27. if($choixIA === "feuille"){
  28. description("Gagné", $choixIA);
  29. }
  30. }
  31. }else{
  32. echo "Tu n'écris pas une bonne valeur, choisis entre pierre, feuille ou ciseaux ! \n";
  33. }
  34. }
  35.  
  36. function description($result, $choixIA)
  37. {
  38. echo "Ton adversaire a choisi : ";
  39. sleep(1);
  40. echo "$choixIA \n";
  41. sleep(1);
  42. echo "==> $result ! \n";
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement