-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatus.cpp
99 lines (76 loc) · 2.41 KB
/
status.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "Status.h"
#include <algorithm>
using std::find_if;
using std::exception;
Status::Status(vector<Player*> playerList) {
this->playerList = vector<Player*>(playerList.begin(), playerList.end());
this->currentTurnCount = 0;
this->winnerPlayer = -1;
this->foulStatus = false;
this->turnProgressStatus = false;
this->turnChangeStatus = false;
this->pNowPlayer = playerList.at(0);
}
Player* Status::getTurnPlayer() noexcept {
return this->pNowPlayer;
}
Player* Status::getNotTurnPlayer() noexcept {
Player* nowPlayer = this->pNowPlayer;
vector<Player*>::iterator foundIndex = find_if(this->playerList.begin(), this->playerList.end(), [nowPlayer](Player* pPlayer) {
return (pPlayer->getPlayerId() != nowPlayer->getPlayerId());
});
return *foundIndex;
}
vector<int> Status::getPlayerIdList() const noexcept {
vector<int> idList;
for (Player* player : this->playerList) {
idList.push_back(player->getPlayerId());
}
return idList;
}
void Status::setTurnPlayer(int playerID)
{
vector<Player*>::iterator foundIndex = find_if(this->playerList.begin(), this->playerList.end(), [playerID](Player* pPlayer){
return (pPlayer->getPlayerId() == playerID);
});
if (foundIndex == this->playerList.end()) {
throw PlayerNotFoundException("플레이어 ID에 맞는 플레이어를 찾을 수 없습니다.");
}
this->pNowPlayer = *foundIndex;
}
bool Status::getFoulStatus() const noexcept {
return this->foulStatus;
}
bool Status::getTurnProgressStatus() const noexcept {
return this->turnProgressStatus;
}
bool Status::getTurnChangeStatus() const noexcept {
return this->turnChangeStatus;
}
bool Status::getGameEndStatus() const noexcept {
return (this->winnerPlayer >= 0);
}
int Status::getCurrentTurnCount() const noexcept {
return this->currentTurnCount;
}
int Status::getWinnerPlayer() const {
if (winnerPlayer < 0) {
throw PlayerNotFoundException("아직 게임이 끝나지 않았습니다.");
}
return this->winnerPlayer;
}
void Status::setWinnerPlayer(int winner) noexcept {
this->winnerPlayer = winner;
}
void Status::setFoulStatus(bool toSet) noexcept {
this->foulStatus = toSet;
}
void Status::setTurnProgressStatus(bool toSet) noexcept {
this->turnProgressStatus = toSet;
}
void Status::setTurnChangeStatus(bool toSet) noexcept {
this->turnChangeStatus = toSet;
}
void Status::nextTurnCount() noexcept {
this->currentTurnCount++;
}