-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImmunityCompetition.cpp
44 lines (34 loc) · 1.32 KB
/
ImmunityCompetition.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 "ImmunityCompetition.h"
using namespace std;
void ImmunityCompetition::compete(Team &team)
{
int maxIndex = -1;
float maxValue = -1;
for(int i = 0; i < 11; i++)
{
Player player = team.getPlayers()[i];
if (player.getAge() != 0)
{
team.getPlayers()[i].setVotes(1);
team.getPlayers()[i].setImmunity(false);
team.getPlayers()[i].setCandidate(false);
float value = 0.75 * player.getTechnique() + 0.25 * (100-player.getFatigue());
cout << "Player: " + player.getName();
cout << " Technique: " << player.getTechnique();
cout << " Fatigue: " << player.getFatigue();
cout << " Value: " << value << endl;
if (maxValue < value)
{
maxValue = value;
maxIndex = i;
}
}
}
winner = team.getPlayers()[maxIndex].getName();
team.getPlayers()[maxIndex].setWins(team.getPlayers()[maxIndex].getWins() + 1);
team.getPlayers()[maxIndex].setImmunity(true);
team.getPlayers()[maxIndex].setVotes(team.getPlayers()[maxIndex].getVotes() + immunityAward.getVotes());
team.getPlayers()[maxIndex].status();
cout << "Immunity Competition Finished." << endl;
status();
}