Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var health = 16;
- var potion = 5;
- health = Math.min(20, health + potion)
- var itemSelection = prompt("HP: " + playerHp + "nItems:n1.Potion - INFO: Restores 5 HP. Can attack after use" + "nQTY: " + potions + "n2.Exit");
- switch (itemSelection) {
- case '1':
- if(playerHp === 20){
- alert("You are already at full health.");
- }else{
- playerHp += 5;
- potions -= 1;
- if (playerHp > 20) {
- playerHp = 20;
- }
- }
- playerTurn();
- break;
- case '2':
- playerTurn();
- break;
- default:
- alert("Invalid choice.");
- itemMenu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement