-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cpp
44 lines (40 loc) · 1.05 KB
/
Game.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
#include "Game.h"
const int Game::passing_directions[PLAYER_COUNT] = {1, 3, 2, 0}; // left, right, across, keep
void Game::game_reset()
{
for (int i = 0; i < PLAYER_COUNT; ++i)
{
total_scores[i] = 0;
}
winners.clear();
passing_index = 0;
}
void Game::end_hand()
{
bool game_over = false;
// shoot the moon already handled in Game_Hand::end_hand
for (int player = 0; player < PLAYER_COUNT; ++player)
{
total_scores[player] += hand.get_score(player);
if (total_scores[player] > 99)
{
game_over = true;
}
}
if (game_over)
{
winners.push_back(0);
for (int player = 1; player < PLAYER_COUNT; ++player)
{
if (total_scores[player] < total_scores[winners[0]]) // better
{
winners.clear();
winners.push_back(player);
}
else if (total_scores[player] == total_scores[winners[0]]) // tie
{
winners.push_back(player);
}
}
}
}