forked from matkatmusic/PFMCPP_Project7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.h
More file actions
70 lines (53 loc) · 1.92 KB
/
Copy pathCharacter.h
File metadata and controls
70 lines (53 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <string>
#include <vector>
#include <memory>
#include <iostream>
#include "Item.h"
struct Character
{
Character(int hp, int armor_, int attackDamage_ );
virtual ~Character() { }
/*
a pure virtual getName function.
derived class stores the name, not the base class.
*/
virtual const std::string& getName() = 0;
virtual std::string getStats() = 0;
virtual void attack( Character& other );
void defend();
void help( Character& other );
int takeDamage(int damage);
int getHP() const { return hitPoints; }
int getArmorLevel() const { return armor; }
int getAttackDamage() const { return attackDamage; }
bool getIsDefending() const { return isDefending; }
const std::vector<std::unique_ptr<Item>>& getHelpfulItems() const { return helpfulItems; }
const std::vector<std::unique_ptr<Item>>& getDefensiveItems() const { return defensiveItems; }
void boostArmor( int amount )
{
armor += amount;
std::cout << getName() << "'s armor level has been boosted to " << armor << std::endl;
}
void boostHitPoints( int amount )
{
hitPoints += amount;
std::cout << getName() << "'s hit point level has been boosted to " << hitPoints << std::endl;
}
void boostAttackDamage( int amount )
{
attackDamage += amount;
std::cout << getName() << "'s attack damage level has been boosted to " << attackDamage << std::endl;
}
void printStats();
protected:
std::vector<std::unique_ptr<Item>> defensiveItems;
std::vector<std::unique_ptr<Item>> helpfulItems;
int hitPoints, armor;
int attackDamage;
bool isDefending = false;
private:
std::unique_ptr<int> initialHitPoints, initialArmorLevel, initialAttackDamage;
void attackInternal(Character& other);
void victorRewardStats(int& initialValue, int& currentValue);
};