📄 players.h
字号:
#ifndef PLAYER_H#define PLAYER_H// The base class of every object in the arena is ArenaObject// everything, including players, in the arena is an ArenaObject.// Then in the 2nd level there is Player as a base class and// then HumanPlayer and CompPlayer.// ArenaObject// |// Player// / \// HumanPlayer CompPlayerclass Player : public ArenaObject{ protected: int level; int score; int current_exp; Weapon* melee_weapon; RangeWeapon* range_weapon; Armor* body_armor; int projectiles; public: Player(); ~Player(); virtual const string getName() const = 0; virtual const Weapon* getMelee() const = 0; virtual const RangeWeapon* getRange() const = 0; virtual const Armor* getArmor() const = 0; const int getExp() const; const int getProjectiles() const; const int getHealth() const; const int getMaxHealth() const; const int getLevel() const; const long getScore() const; //const int getAttacks() const; //const int getWins() const; //const int getLosses() const; // Not in use /* //Player-Hidden stat const int getSpeciesKills( *Species) const; //Player-Hidden, recaculated daily const int getIntoxication() const; const int getPlayerChallengesLeft() const; const int getRessurectionsLeft() const; const int getTodaysLuck() const; */ virtual void melee_attack(); virtual void take_turn(); void move_amount(Position); void move_to(Position); Position follow_direction(Position, int, int);};//class HumanPlayer : virtual public Playerclass HumanPlayer : public Player{ protected: int gold_in_hand; int gold_in_bank; public: HumanPlayer(); ~HumanPlayer(); // Getters const int getExp() const { return current_exp; } const string getName() const { return name; } const Weapon* getMelee() const { return melee_weapon; } const RangeWeapon* getRange() const { return range_weapon; } const Armor* getArmor() const { return body_armor; } const int getProjectiles() const { return projectiles; } const int getHealth() const { return current_health; } const int getMaxHealth() const { return max_health; } const int getLevel() const { return level; } const long getScore() const { return score; } //const int getAttacks() const { return attacks; } //const int getWins() const; //const int getLosses() const; const long getGoldInHand() const { return gold_in_hand; } const long getGoldInBank() const { return gold_in_bank; } // Setters Weapon* setMelee(Weapon* data) { melee_weapon = data; } RangeWeapon* setRange(RangeWeapon* data) { range_weapon = data; } Armor* setArmor(Armor* data) { body_armor = data; } int setExp(int data) { current_exp = data; } string setName(string data) { name = data; } int setProjectiles(int data) { projectiles = data; } int setHealth(int data) { current_health = data; } int setMaxHealth(int data) { max_health = data; } int setLevel(int data) { level = data; } long setScore(long data) { score = data; } long setGoldInHand(long data) { gold_in_hand = data; } long setGoldInBank(long data) { gold_in_bank = data; } // Methods int get_direction(int); void take_turn(); void melee_attack(Position); void range_attack(int, int); void plead_for_mercy();};class CompPlayer : public Player{ public: CompPlayer(); ~CompPlayer(); // Getters const int getExp() const { return current_exp; } const string getName() const { return name; } const int getProjectiles() const { return projectiles; } const int getHealth() const { return current_health; } const int getMaxHealth() const { return max_health; } const int getLevel() const { return level; } const long getScore() const { return score; } const Weapon* getMelee() const { return melee_weapon; } const RangeWeapon* getRange() const { return range_weapon; } const Armor* getArmor() const { return body_armor; } // Setters int setExp(int data) { current_exp = data; } char* setName(string data) { name = data; } int setProjectiles(int data) { projectiles = data; } int setHealth(int data) { current_health = data; } int setMaxHealth(int data) { max_health = data; } int setLevel(int data) { level = data; } long setScore(long data) { score = data; } // Methods void melee_attack(ArenaObject*); void take_turn();};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -