Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. var health = 16;
  2. var potion = 5;
  3.  
  4. health = Math.min(20, health + potion)
  5.  
  6. var itemSelection = prompt("HP: " + playerHp + "nItems:n1.Potion - INFO: Restores 5 HP. Can attack after use" + "nQTY: " + potions + "n2.Exit");
  7.  
  8. switch (itemSelection) {
  9. case '1':
  10. if(playerHp === 20){
  11. alert("You are already at full health.");
  12. }else{
  13. playerHp += 5;
  14. potions -= 1;
  15. if (playerHp > 20) {
  16. playerHp = 20;
  17. }
  18. }
  19. playerTurn();
  20. break;
  21. case '2':
  22. playerTurn();
  23. break;
  24. default:
  25. alert("Invalid choice.");
  26. itemMenu();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement