This repository was archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharacter.h
executable file
·66 lines (56 loc) · 2.17 KB
/
character.h
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
#ifndef __CHARACTER_H__
#define __CHARACTER_H__
#include "treasure.h"
class Character{
int maxhp, hp, atk, def;
int gvalue; // = 2 By default, 1 for orc and 4 for dwarf
int potionABS; //1 by default, -1 for elves
int r,c; // row, column
char type; //human,elf,orc OR wolf,vampire,merchant,etc.
int halfgold; // amount of half gold the player/enemy holds
public:
Character(char type, int r, int c);
virtual ~Character();
virtual int getAtk();
virtual int getDef();
virtual void setCoordinates(int r, int c);
virtual int getRow();
virtual int getColumn();
virtual bool attack(Character &c) = 0;
virtual void increaseGold(int n);
virtual void increaseHP(int n); //if HP is less than 0, set to 0, if more than max, set to max
virtual int getHP();
virtual int getPotABS();
virtual int getGold();
virtual void action(Character* &c) = 0;
void setType(char type);
char getType();
};
//Singleton Player
class Player: public Character{
static Player* instance;
Player(int r, int c, char type); // constructs the player according to each type’s specification
public:
virtual void action(Character* &c);
static Player* getInstance(int r = -1, int c = -1, char type = 'h');
virtual bool attack(Character &c);
static void cleanup();
void setType(char type, int r, int c);
};
class Enemy: public Character{
int hostile; //all hostile = 1 except merchents
public:
Enemy(char type, int r, int c); //construct enemy
virtual void action(Character* &c);
virtual bool attack(Character &c); //check player's coordinates is nearby (remember 50% chance miss), will also check if hostile
virtual void changeHostility(); //always set hostility to 1
};
class Dragon: public Enemy{
Dhorde * myhorde;
public:
Dragon(int r, int c, Dhorde* myhorde);
~Dragon();
virtual bool attack(Character &c); //player's coordinates, checks if near dragon hoard
void notifyHorde();
};
#endif