C++ Text Rpg 프로젝트 | Laboratory


13조 Role & Responsibilities

  • 권민성 : 아키텍쳐
  • 김남태 : Git 마스터
  • 황병권 : PM
  • 박하민 : 서기
  • 이준로 : 발표자료 준비

계 획

오전

  • 09:00 ~ 10:00 : 알고리즘 문제풀기
  • 10:45 ~ 13:00 : 작업
    • 김남태 : Inventory, Item 클래스 구현
    • 황병권 : Monster 클래스 완료 후 Merge전 몬스터 아스키 아트로 구현
    • 박하민 : Action 제외한 필수 기능 구현
    • 권민성 : 게임에 출력될 화면 대부분의 UI 뼈대 제작 밑 엔터로 선택 구현
    • 이준로 : Action Context 생성 작업 및 기존 Class 적용

오후: 집중 코딩

  • 14:30 ~ 15:00 : 13조 회의
  • 15:00 ~ 18:00
    • 김남태 : Inventory, Item 클래스 저장타입 변경
    • 황병권 :몬스터 클래스 수정 및 아스키 아트
    • 박하민 : Player 클래스 내부 Action 구현 및 ItemUse 협업
    • 권민성 : 게임에 출력될 화면 대부분의 UI 뼈대 제작 밑 엔터로 선택 구현
    • 이준로 : Action Context 기반 ItemUse 작성

저녁: 스크럼 및 TIL

  • 20:00 ~ 20:30 : 저녁 스크럼 - 회고, 작업물 공유 및 설명
  • 20:30 ~ 21:00 : TIL

진행상황

필수 기능 구현

플레이어 캐릭터 - 박하민

  • Player 클래스 담당 | 플레이어 Status 관리, 아이템 사용 (완료)

몬스터 - 황병권

  • Monster 클래스 담당 | 전투에 나올 몬스터 Status 관리 (완료) UI에 넣을 아스키 아트(진행중)

전투 시스템 - 이준로

  • 몬스터와 플레이어가 턴제로 전투 (완료)

아이템 - 김남태

  • 아이템 추가, 제거 및 인벤토리에 저장 (완료)

 

추가 기능 구현

UI / 게임 매니저 - 권민성

  • 게임에 출력될 화면 대부분의 UI 뼈대 제작 밑 엔터로 선택 구현 (완료)

Inventory.cpp / .h

#include "pch.h"
#include "Inventory.h"
// cpp
Inventory::Inventory() : capacity(10)
{
	vInventory.reserve(capacity);	// 인벤토리 최대용량 초기화
}

Inventory::~Inventory()
{
}

vector<shared_ptr<Item>> Inventory::GetInventory() const
{
	return vInventory;
}

void Inventory::AddItem(Item* Item_)
{
	string itemName_ = Item_->GetsItemName();

	// 인벤토리 남은 자리 확인
	if (vInventory.size() >= capacity)
	{
		return;
	}
	
	// 동일 아이템 확인
	for (const auto& item_ : vInventory)
	{
		if (item_->GetsItemName() == itemName_)
		{
			// 개수 만큼 추가
			item_->AddItemCount(Item_->GetiItemCount());
			break;
		}
	}
	
	// 아이템 추가
	vInventory.push_back(shared_ptr<Item>(Item_));
}

void Inventory::RemoveItem(const string& itemName_, const int& itemCount_)
{
	for (auto inventorySlot = vInventory.begin(); inventorySlot != vInventory.end(); )
	{
		auto& item_ = *inventorySlot; // item_ 타입 : shared_ptr<Item>&

		if (item_->GetsItemName() == itemName_)
		{
			// 개수 만큼 감소
			item_->ReduceItemCount(itemCount_);
			if (item_->GetiItemCount() <= 0)
			{
				inventorySlot = vInventory.erase(inventorySlot);
			}
		}
	}
}

#pragma once
#include <map>
#include "Item.h"
using namespace std;
// header
class Item;

class Inventory
{
private:
	vector<shared_ptr<Item>> vInventory;		// 인벤토리 저장소
	int capacity; // 인벤토리 용량

public:
	Inventory();	// 생성자
	~Inventory();	// 소멸자

	vector<shared_ptr<Item>> GetInventory() const;	// Getter

	void AddItem(Item* Item_);	// 인벤토리에 아이템 추가
	void RemoveItem(const string& itemName_, const int& itemCount_);	// 인벤토리에 있는 아이템 삭제
};

 

Item.cpp / .h

#include "pch.h"
#include "Item.h"
// cpp
Item::Item(string itemName_, int price_, int itemCount_, ItemEffectType type_, int value_) :
	sItemName(itemName_),
	price(price_),
	itemCount(itemCount_),
	effectType(type_),
	effectValue(value_)
{
}

const string& Item::GetsItemName() const
{
	return sItemName;
}

int Item::GetiPrice() const
{
	return price;
}

int Item::GetiItemCount() const
{
	return itemCount;
}

ItemEffectType Item::GetEffectType() const
{
	return effectType;
}

int Item::GetEffectValue() const
{
	return effectValue;
}

void Item::SetsItemName(const string& sItemName_)
{
	sItemName = sItemName_;
}

void Item::SetiPrice(const int& price_)
{
	price = price_;
}

void Item::SetsItemCount(const int& iItemCount_)
{
	itemCount = iItemCount_;
}

void Item::AddItemCount(int amount)
{
	itemCount += amount;
}

void Item::ReduceItemCount(int amount)
{
	itemCount -= amount;
}

#pragma once
// header
using namespace std;

// 아이템 효과 타입
enum class ItemEffectType
{
	None,
	Heal,		// 체력회복
	AttackUp	// 공격력 증가
};

class Item
{
private:
	string sItemName;	// 아이템 이름
	int price;			// 아이템 가격
	int itemCount;		// 수량
	ItemEffectType effectType;	// 아이템 효과 타입
	int effectValue;	// 효과 수치		

public:
	Item(string itemName_, int price_, int itemCount_, ItemEffectType type_, int value_);	// 생성자

	// Getter
	const string& GetsItemName() const;
	int GetiPrice() const;
	int GetiItemCount() const;
	ItemEffectType GetEffectType() const;
	int GetEffectValue() const;

	// Setter
	void SetsItemName(const string& sItemName_); 
	void SetiPrice(const int& price_);
	void SetsItemCount(const int& ItemCount_);

	void AddItemCount(int amount);	// 아이템 수량 증가
	void ReduceItemCount(int amount);	// 아이템 수량 증가
};

 

+ Recent posts