Skip to content
Permalink
d0bd7166b2
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
37 lines (30 sloc) 716 Bytes
#include "Character.h"
void Character::attack(Monster& target)
{
target.health -= damage;
cout << " You attack the " << target.name << " doing " << damage << " damage!" << endl;
cout << " health: " << health << endl;
}
void Character::rangedAttack(Monster& target)
{
if (arrows == 0)
cout << " You're out of arrows!" << endl;
else
{
short rangedDamage = 3;
target.health -= rangedDamage;
arrows--;
cout << "You shoot " << target.name << " doing " << rangedDamage << " damage!" << endl;
}
}
Character::Character(string newname)
{
name = newname;
health = 100;
damage = 3;
arrows = 5;
}
void Character::display()
{
cout << name << " health: " << health << " arrows: " << arrows << endl;
}