Added copy operators for game's static instance
Player CommandParser can be swapped but not copied.
This commit is contained in:
+22
-4
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "creature.h"
|
||||
|
||||
|
||||
class Player : Creature {
|
||||
private:
|
||||
|
||||
private:
|
||||
// Inventory inventory;
|
||||
|
||||
// Lets keep the room a loose reference to avoid to many hardcoded details and other info
|
||||
@@ -15,11 +15,29 @@ private:
|
||||
int prevRoomID = -1;
|
||||
|
||||
public:
|
||||
|
||||
Player();
|
||||
Player(Player &rhs);
|
||||
Player& operator=(Player& rhs);
|
||||
|
||||
void Init() override;
|
||||
void LevelUp() override;
|
||||
void Die() override;
|
||||
void TakeDamage(int damageType, float damage) override;
|
||||
float GetHealth() override;
|
||||
|
||||
void ChangeRoom(int roomID);
|
||||
|
||||
inline friend void swap(Player& lhs, Player &rhs) noexcept
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs.id, rhs.id);
|
||||
swap(lhs.name, rhs.name);
|
||||
swap(lhs.description, rhs.description);
|
||||
swap(lhs.stats, rhs.stats);
|
||||
swap(lhs.level, rhs.level);
|
||||
swap(lhs.prevRoomID, rhs.prevRoomID);
|
||||
swap(lhs.curRoomID, rhs.curRoomID);
|
||||
}
|
||||
|
||||
~Player();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user