|
@@ -20,21 +20,26 @@ bool Game::addPlayer(std::string name){
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
|
-void Game::score(){
|
|
|
+void Game::score()
|
|
|
+{
|
|
|
|
|
|
std::vector<int> pointsGuide = {0,1,3,6,10,15,21,28,36,45,55,66,78};
|
|
|
|
|
|
- for(int i = 0;i <players.size();i++){
|
|
|
+ for(int i = 0;i <players.size();i++)
|
|
|
+ {
|
|
|
|
|
|
players[i].score = 0;
|
|
|
|
|
|
players[i].score -= players[i].penaltyCount*PENALTY_VALUE;
|
|
|
|
|
|
- for(int j = 0;j <white1;j++){
|
|
|
+ for(int j = 0;j <white1;j++)
|
|
|
+ {
|
|
|
int count = 0;
|
|
|
|
|
|
- for(int k =0;k <CHECKBOXES;k++){
|
|
|
- if(true == players[i].rowColors[j][k]){
|
|
|
+ for(int k =0;k <CHECKBOXES;k++)
|
|
|
+ {
|
|
|
+ if(true == players[i].rowColors[j][k])
|
|
|
+ {
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
@@ -43,42 +48,80 @@ void Game::score(){
|
|
|
}
|
|
|
|
|
|
|
|
|
- for(int i = 0;i<players.size();i++){
|
|
|
+ for(int i = 0;i<players.size();i++)
|
|
|
+ {
|
|
|
|
|
|
if(players[i].penaltyCount == MAX_PENALTY){state = FINISHED;}
|
|
|
}
|
|
|
|
|
|
int lockCount = 0;
|
|
|
- for(int i = 0;i<lockOut.size();i++){
|
|
|
+ for(int i = 0;i<lockOut.size();i++)
|
|
|
+ {
|
|
|
if(true == lockOut[i]){lockCount++;}
|
|
|
}
|
|
|
- if(MAX_LOCKOUT <= lockCount){
|
|
|
+ if(MAX_LOCKOUT <= lockCount)
|
|
|
+ {
|
|
|
state = FINISHED;
|
|
|
}
|
|
|
}
|
|
|
-void Game::turn(PlayerCard activePlayer) {
|
|
|
+void Game::turn(PlayerCard activePlayer)
|
|
|
+{
|
|
|
|
|
|
- for(int i = 0; i <players.size();i++){
|
|
|
+ for(int i = 0; i <players.size();i++)
|
|
|
+ {
|
|
|
players[i].isTurnDone = false;
|
|
|
}
|
|
|
|
|
|
dice.roll();
|
|
|
|
|
|
- while(true){
|
|
|
+ while(true)
|
|
|
+ {
|
|
|
bool temp = true;
|
|
|
- for(int i = 0; i <players.size();i++){
|
|
|
+ for(int i = 0; i <players.size();i++)
|
|
|
+ {
|
|
|
temp = temp && players[i].isTurnDone;
|
|
|
}
|
|
|
if(temp){break;}
|
|
|
Sleep(1);
|
|
|
}
|
|
|
+
|
|
|
+ for(int i = 0; i <players.size();i++)
|
|
|
+ {
|
|
|
+ int t;
|
|
|
+
|
|
|
+ if(-1<(t = players[i].selection[everyone][row]))
|
|
|
+ {
|
|
|
+ int color = players[i].selection[everyone][row];
|
|
|
+ int checkbox = players[i].selection[everyone][column];
|
|
|
+ players[i].rowColors[color][checkbox] = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(-1<(t = players[i].selection[active][row]))
|
|
|
+ {
|
|
|
+ int color = players[i].selection[active][row];
|
|
|
+ int checkbox = players[i].selection[active][column];
|
|
|
+ players[i].rowColors[color][checkbox] = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(0<(t = players[i].selection[penalty][0]))
|
|
|
+ {
|
|
|
+ players[i].penaltyCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
score();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
std::string Game::send()
|
|
|
{
|
|
|
std::string output;
|
|
|
-
|
|
|
+ if(dice.dice.size()==0){fprintf(stdout, "kyle is cool\n");}
|
|
|
+
|
|
|
+ for(int i = 0; i < dice.dice.size(); i++)
|
|
|
+ {
|
|
|
+ output.push_back(dice.dice[i] + '0');
|
|
|
+ }
|
|
|
|
|
|
for(int i = 0; i < players.size(); i++)
|
|
|
{
|
|
@@ -92,11 +135,38 @@ std::string Game::send()
|
|
|
output.push_back(players[i].rowColors[j][k] ? 'T' : 'F');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ output.push_back(players[i].penaltyCount + '0');
|
|
|
}
|
|
|
+
|
|
|
+ for(int i = 0; i < lockOut.size();i++)
|
|
|
+ {
|
|
|
+ output.push_back(lockOut[i] ? 'T' : 'F');
|
|
|
+ }
|
|
|
+
|
|
|
+ output.push_back(state == FINISHED ? 'T' : 'F');
|
|
|
+
|
|
|
fprintf(stdout, "the output is: %s\n", output.c_str());
|
|
|
return output;
|
|
|
}
|
|
|
-void Game::receive(std::string userInput){
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void Game::receive(std::string userInput)
|
|
|
+{
|
|
|
+ players[0].newSelection();
|
|
|
+
|
|
|
+ players[0].selection[penalty][0] = 1;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ players[0].selection[everyone][row] = green;
|
|
|
+ players[0].selection[everyone][column] = 5;
|
|
|
+ players[0].selection[active][row] = yellow;
|
|
|
+ players[0].selection[active][column] = 11;
|
|
|
+
|
|
|
+
|
|
|
}
|