ProjectTextRPG/TextRPG/Source/Game/Characters/Player/Player.h

128 lines
2.6 KiB
C++

#pragma once
#include "Core/Interface/Damageable.h"
#include "Core/Object/GameObject.h"
template <typename T>
class InventorySystem;
class Item;
class Player;
struct PlayerStatData
{
PlayerStatData() :
Level(0),
HP(0),
MP(0),
Attack(0),
Defence(0)
{
}
PlayerStatData(const std::string& InName, const std::string& InJob, const int InLevel, const int InHP, const int InMP, const int InAttack, const int InDefence) :
Name(InName),
Job(InJob),
Level(InLevel),
HP(InHP),
MP(InMP),
Attack(InAttack),
Defence(InDefence)
{
}
PlayerStatData(const PlayerStatData& Other) :
Level(0),
HP(0),
MP(0),
Attack(0),
Defence(0)
{
}
PlayerStatData(PlayerStatData&& other) noexcept :
Name(std::move(other.Name)),
Job(std::move(other.Job)),
Level(other.Level),
HP(other.HP),
MP(other.MP),
Attack(other.Attack),
Defence(other.Defence)
{
}
PlayerStatData& operator=(const PlayerStatData& Other) = default;
friend std::ostream& operator<<(std::ostream& OS, const PlayerStatData& RHS);
std::string Name;
std::string Job;
int Level;
int HP;
int MP;
int Attack;
int Defence;
};
inline std::ostream& operator<<(std::ostream& OS, const PlayerStatData& RHS)
{
OS << "====================================" << "\n";
OS << RHS.Name << "" << "현재 능력치" << "\n";
OS << "====================================" << "\n";
OS << "HP: " << RHS.HP << "\t" << "MP: " << RHS.MP << "\n";
OS << "공격력: " << RHS.Attack << "\t" << "방어력: " << RHS.Defence << "\n";
OS << "====================================" << "\n";
return OS;
}
class PlayerFactory
{
public:
template <typename T>
static Player* CreatePlayer(PlayerStatData&& Rvalue);
};
class Player : public GameObject, public IDamageable
{
public:
Player() = default;
Player(PlayerStatData&& Rvalue);
~Player() override;
virtual void Attack(class Monster* Target) = 0;
void Initalize() override;
void Release() override;
void TakeDamage(int Amount) override;
bool IsDead() override;
void Reset() override;
void PrepareInitInventory();
void PrintPlayerStatus() const;
InventorySystem<Item>* GetInventory() const;
std::string GetName() const;
std::string GetJob() const;
int GetLevel() const;
int GetHP() const;
int GetMP() const;
int GetAttack() const;
int GetDefence() const;
protected:
InventorySystem<Item>* Inventory;
PlayerStatData PlayerData;
PlayerStatData OriginalData;
int HitCount;
};
template <typename T>
Player* PlayerFactory::CreatePlayer(PlayerStatData&& Rvalue)
{
Player* NewPlayer = new T(std::move(Rvalue));
NewPlayer->Initalize();
return NewPlayer;
}