- 리그게임 만든거에서 한 플레이어를 골라서 직접 컨트롤.
- (fstream of fscanf) 세이브 로드 구현하기, 플레이어 수, 모든 플레이어들 정보 다 저장해서 리그게임 그대로 이어서 하기
- 일정 게임 플레이 하면 승자 토너먼트 구현하기
구현 :
플레이어로 참여하여 한 클래스로 골라서 리그에 참여
레벨시스템을 도입하여, 레벨업할때마다, 스킬포인트, 공격력, 체력이 레벨비례로 상승됨
각 플레이어끼리 한경기씩 마치면 종료되면서 자동으로 SAVE되어 플레이어의 이름에 맞춰서 레벨, 경험치가 저장되고,
다시 플레이하면 해당 레벨 경험치가 로드할수있고, 플레이했던 데이터 그대로 플레이가능
Load는 txt에 저장된 파일에 한줄을 먼저 getline으로 string을 따와서 substr함수로 " "을 기준으로 문자열을 잘라 각각 동적할당된 player의 이름, lv, exp에 새로 할당
↓ Load 테스트
↓ Save 테스트
↓ 새로 추가한 Save, Load와 Load할때 불러온 레벨과 경험치에 따라서 능력치 설정 함수
void GameManager::Save()
{
ofstream fout(FILE_NAME);
for (int i = 0; i < playersize; i++)
{
fout << players[i]->GetStatus().playername << " " << players[i]->GetLevel() <<
" " << players[i]->GetExp() << endl;
}
fout.close();
}
void GameManager::Load()
{
ifstream fin(FILE_NAME);
string temp;
string separator = " ";
int position;
uint templv;
uint tempexp;
if (fin.is_open())
{
for (int i = 0; i < playersize; i++)
{
int cur_position = 0;
getline(fin, temp);
if ((position = temp.find(separator, cur_position)) != string::npos)
{
int len = position - cur_position;
players[i]->SetPlayerName(temp.substr(cur_position, len));
cur_position = position + 1;
templv = stoi((temp.substr(cur_position, len)));
cur_position = position + 2;
tempexp = stoi((temp.substr(cur_position, len)));
cur_position = position + 1;
players[i]->LoadSetting(templv, tempexp);
}
}
fin.close();
}
}
void Player::LoadSetting(uint level, uint exp)
{
this->level = level;
this->exp = exp;
maxSp += level - 1;
curSp = maxSp;
for (int i = 0; i < level - 1; i++)
{
SetAttack();
SetMaxHp();
}
}