Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $weapons = ['fists', 'whip', 'gun', 'nuclear']; // don't change the order of weapon élément in the array
- $opponentWeapon = rand(0,count($weapons)-1);
- echo 'The weapon of the opponent is <b>' . $weapons[$opponentWeapon] . '</b><br/><br/>';
- switch ($opponentWeapon) {
- case 0:
- // The gun beats the fists
- $indyWeapon = 2;
- break;
- case 1:
- // The fists beat the whip
- $indyWeapon = 0;
- break;
- case 2:
- // The whip beats the gun
- $indyWeapon = 1;
- break;
- default:
- $indyWeapon = -1;
- break;
- }
- if (-1 == $indyWeapon) // Yoga test -;)
- echo 'This case isn\'t considered';
- else
- echo 'Indy choose <b>' . $weapons[$indyWeapon] . '</b> to fight with the opponent';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement