Created
March 31, 2020 14:56
-
-
Save pierrealexaline/8f2f6c5eb286cf0975ecdf1f0d8aff07 to your computer and use it in GitHub Desktop.
WCS - Les conditions en PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Afin de choisir la meilleure défense pour Indiana Jones, tu dois écrire un petit | |
| script PHP qui va se baser sur celui-ci : | |
| $weapons = ['fists', 'whip', 'gun']; | |
| $opponentWeapon = $weapons[rand(0,2)]; // Cela permet de choisir une arme de manière aléatoire. | |
| Todo : | |
| $indyWeapon = '???'; | |
| le pistolet bat le poing mais perd contre le fouet | |
| le poing bat le fouet mais perd contre le pistolet | |
| le fouet bat le pistolet mais perd contre le poing | |
| */ | |
| $weapons = ['fists', 'whip', 'gun']; | |
| $opponentWeapon = $weapons[rand(0,2)]; | |
| switch ($opponentWeapon) { | |
| case 'fists': | |
| $indyWeapon = $weapons[2]; // 2 => gun | |
| break; | |
| case 'whip': | |
| $indyWeapon = $weapons[0]; // 0 => fists | |
| break; | |
| case 'gun': | |
| $indyWeapon = $weapons[1]; // 1 => whip | |
| break; | |
| } | |
| // Response | |
| echo 'Opponent : ' . $opponentWeapon . ' - Indiana Jones ' . $indyWeapon; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment