-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathOption.cpp
112 lines (98 loc) · 1.86 KB
/
Option.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
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Game.hpp"
#include "Option.hpp"
#include <string>
#include <iostream>
Option::Option(const int & x, const int & y, const int & dens, const unsigned int & nb_player, const unsigned int & nb_ia)
{
this->setXMap(x);
this->setYMap(y);
this->setDensityBloc(dens);
this->setNbPlayer(nb_player);
this->setNbIa(nb_ia);
this->_bonus = 50;
}
Option::~Option()
{
}
void Option::setXMap(const int & x)
{
if (this->_xMap > x)
this->_xMap = x - 1;
else if (x % 2 == 0)
this->_xMap = x + 1;
else
this->_xMap = x;
if (this->_xMap < 9)
this->_xMap = 9;
if (this->_xMap > 19)
this->_xMap = 19;
}
int Option::getXMap() const
{
return this->_xMap;
}
void Option::setYMap(const int & y)
{
if (this->_yMap > y)
this->_yMap = y - 1;
else if (y % 2 == 0)
this->_yMap = y + 1;
else
this->_yMap = y;
if (this->_yMap < 9)
this->_yMap = 9;
if (this->_yMap > 19)
this->_yMap = 19;
}
int Option::getYMap() const
{
return this->_yMap;
}
void Option::setDensityBloc(const int & d)
{
this->_densityBloc = d;
if (d > 100)
this->_densityBloc = 0;
else if (d < 0)
this->_densityBloc = 100;
}
int Option::getDensityBloc() const
{
return this->_densityBloc;
}
void Option::setNbPlayer(const unsigned int & nb)
{
this->_nbPlayer = nb;
if (nb > 2)
this->_nbPlayer = 2;
else if (nb < 1)
this->_nbPlayer = 1;
}
unsigned int Option::getNbPlayer() const
{
return this->_nbPlayer;
}
void Option::setNbIa(const int & nb)
{
this->_nbIa = nb;
if (nb > 10)
this->_nbIa = 0;
else if (nb < 0)
this->_nbIa = 10;
}
unsigned int Option::getNbIa() const
{
return this->_nbIa;
}
void Option::setBonusDensity(int const & nb)
{
this->_bonus = nb;
if (nb > 100)
this->_bonus = 0;
else if (nb < 0)
this->_bonus = 100;
}
unsigned int Option::getBonusDensity() const
{
return this->_bonus;
}