public void PlayerUsePotion(HealingPotion potion) { if(_player.currentHitPoints < _player.maximumHitPoints) { // Add healing amount to the player's current hit points _player.currentHitPoints = (_player.currentHitPoints + potion.amountToHeal); // CurrentHitPoints cannot exceed player's MaximumHitPoints if (_player.currentHitPoints > _player.maximumHitPoints) { _player.currentHitPoints = _player.maximumHitPoints; } // Remove the potion from the player's inventory _player.RemoveItemFromInventory(potion, 1); // Display message RaiseMessage("You drink a " + potion.name); } else { RaiseMessage("You don't need to drink one of those right now!"); } }
public void UsePotion(HealingPotion potion) { // Add healing amount to the player's current hit points currentHitPoints = (currentHitPoints + potion.amountToHeal); // CurrentHitPoints cannot exceed player's MaximumHitPoints if (currentHitPoints > maximumHitPoints) { currentHitPoints = maximumHitPoints; } // Remove the potion from the player's inventory RemoveItemFromInventory(potion, 1); // Display message RaiseMessage("You drink a " + potion.name); // Monster gets their turn to attack int attackRoll = RandomNumberGenerator.NumberBetween(1, 20) + _currentMonster.attackMod; if (attackRoll >= AC) { // Determine the amount of damage the monster does to the player int damageToPlayer = RandomNumberGenerator.NumberBetween(_currentMonster.minimumDamage, _currentMonster.maximumDamage); // Display message RaiseMessage("The " + _currentMonster.name + " did " + damageToPlayer + " points of damage."); // Subtract damage from player currentHitPoints -= damageToPlayer; } if (currentHitPoints <= 0) { // Display message RaiseMessage("The " + _currentMonster.name + " killed you."); // Move player to "Home" MoveHome(); } }