1. Day26
- 알고리즘 코드카타
- 과제 6: [CH2: 팀 프로젝트] 텍스트 콘솔 RPG
2. C++ 문법 학습(Day26)
- 알고리즘 코드카타
- 자리수 더하기, 약수의 합, 나머지가 1이 되는 수 찾기
- 과제 6 : [CH2: 팀 프로젝트] 텍스트 콘솔 RPG(Item 관련 클래스)
3. 과제 6 : [CH2: 팀 프로젝트] 텍스트 콘솔 RPG
- 코드리뷰(튜터님 & 클로드)
- 첫 턴에서 회복 물약이 항상 획득되는 상황 트러블 슈팅
- rand()함수의 시드가 고정이라 매번 컴파일마다 같은 상황이 반복 → main() 함수 안의 rand() 함수 사용하기 전 시점에 srand(time(nullptr)) 를 사용해 랜덤 시드를 매번 다르게 구현
- 상점진입 → 1또는 2로 아이템 구매,판매 상태로 진입 → 아무 구매와 판매 없이 돌아가기로 메인 상점밖으로 나오는 과정에서 같은 페이지가 두번 반복되는 경우가 발생함
- shopPrint() 함수 내에서 switch문이 함수의 재귀적 사용으로 ShopPrint()가 두번 사용돼 나가려면 스택식으로 쌓인 함수를 두번 나가야해서 생기는 문제
void ShopPrint() {
bool isEscapeShop = false;
while (!isEscapeShop) {
cout << StreamManager::PrintText_ViewShopSelection();
cout << StreamManager::PrintText_InputSelection();
int choiceCheck;
cin >> choiceCheck;
switch (choiceCheck) {
default:
break;
case 0:
isEscapeShop = true;
break;
case 1: {
int shopInnerGet;
cout << endl;
cout << StreamManager::PrintText_ViewShopBuy() << endl;
cout << StreamManager::PrintText_InputSelection();
cin >> shopInnerGet;
switch (shopInnerGet)
{
default:
break;
case 0:
StreamManager::ClearScreen();
// 여기서 shopPrint() 부분이 재귀적으로 사용되면서 스택으로 쌓이기 때문에 0번을 두번입력해야 shop에서 완전 나올 수 있음
//ShopPrint(); 주석처리로 지우기만 해도 어차피 스위치문 나가서 while문이 돌아가기 때문에 해결
break;
case 1:
case 2:
int realIndex = shopInnerGet - 1;
cout << endl;
cout << StreamManager::PrintText_ViewShopCount(true) << endl;
cout << StreamManager::PrintText_InputSelection(true);
int shopBuyCount;
cin >> shopInnerGet;
bool isSuccess = GameManager::Get().TryBuyItem(realIndex, shopInnerGet);
cout << StreamManager::PrintText_ViewShopIsSuccess(true, isSuccess) << endl;
isEscapeShop = isSuccess;
StreamManager::WaitForEnter();
break;
}
}
break;
case 2: {
int shopInnerGet;
vector<Item*> plItemGet = GameManager::Get().GetPlayerItems();
cout << endl;
cout << StreamManager::PrintText_ViewShopSell(plItemGet) << endl;
cout << StreamManager::PrintText_InputSelection();
cin >> shopInnerGet;
switch (shopInnerGet)
{
default:
break;
case 0:
StreamManager::ClearScreen();
// ShopPrint(); 여기도 위와 같은 이유
break;
case 1:
case 2:
int realIndex = shopInnerGet - 1;
if (plItemGet[realIndex] == nullptr) {
StreamManager::PrintText_WrongSelection();
break;
}
cout << endl;
cout << StreamManager::PrintText_ViewShopCount(false) << endl;
cout << StreamManager::PrintText_InputSelection(true);
int shopBuyCount;
cin >> shopInnerGet;
bool isSuccess = GameManager::Get().TrySellItem(realIndex, shopInnerGet);
cout << StreamManager::PrintText_ViewShopIsSuccess(false, isSuccess) << endl;
isEscapeShop = isSuccess;
StreamManager::WaitForEnter();
break;
}
}
break;
}
StreamManager::ClearScreen();
}
}
4. 내일 계획 : 트러블 슈팅 정리 및 마무리, 발표 준비