#pragma once #include "Core/Interface/Damageable.h" #include "Core/Object/GameObject.h" template 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 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* 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* Inventory; PlayerStatData PlayerData; PlayerStatData OriginalData; int HitCount; }; template Player* PlayerFactory::CreatePlayer(PlayerStatData&& Rvalue) { Player* NewPlayer = new T(std::move(Rvalue)); NewPlayer->Initalize(); return NewPlayer; }