-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhass.c
63 lines (60 loc) · 1.58 KB
/
hass.c
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
#include "playerFunctionality.h"
/**
* @brief Returns the player who is occupying StLucia currently according to
* this player, if no player is occupying StLucia then it returns a player
* with label 1
*
* @param player
* This player
*
* @return The player in StLucia or a player with label '1' if that player
* does not exist
*/
Players get_st_lucia_occupant(Player* player) {
Players playerToReturn;
playerToReturn.label = '1';
for(int i = 0; i < player->remainingPlayers; i++) {
if(player->stLuciaOccupant == player->players[i].label) {
playerToReturn = player->players[i];
}
}
return playerToReturn;
}
/**
* @brief Always returns stay, since this player will always want to leave
* StLucia
*
* @param command
* The command to stay
*
* @param player
* This player
*/
void process_stay(char* command, Player* player) {
printf("stay\n");
fflush(stdout);
}
/**
* @brief Keeps all the point dice if this player is in StLucia, otherwise
* rerolls everything unless it has enough attack dice to kill the player in
* StLucia.
*
* @param dice
* The dice from this player's final roll
*
* @param player
* This player
*/
void keep_dice(DiceContent* dice, Player* player) {
if(player->stLuciaOccupant == player->label) {
dice->points = KEEP;
} else {
Players stLuciaOccupant = get_st_lucia_occupant(player);
if(stLuciaOccupant.label == '1') {
return;
}
if(stLuciaOccupant.health - dice->attack < 1) {
dice->attack = KEEP;
}
}
}