-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.cpp
56 lines (52 loc) · 1.08 KB
/
common.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
#include "common.h"
GameMode stringToGameMode(const string& mode) {
GameMode toSet;
if (mode=="timed") {
toSet=timed;
} else if (mode=="four"){
toSet=four;
} else if (mode=="standard"){
toSet=standard;
} else if (mode=="attack"){
toSet=attack;
} else {
cout << "Gamemode " << mode << " n'existe pas." << endl;
cout << "Gamemode par défaut appliqué : standard" << endl;
toSet = standard;
}
return toSet;
}
string gameModeToString(const GameMode& mode) {
string strMode="";
switch (mode) {
case(timed):
strMode="timed";
break;
case(four):
strMode=four;
break;
case(standard):
strMode="standard";
break;
case(attack):
strMode="attack";
break;
default:
cout<<"Wrong mode"<<mode<<endl;
}
return strMode;
}
bool isPointNeighbor(Point pt_1, Point pt_2){
bool res = false;
if (pt_1.x == pt_2.x){
if (pt_1.y - pt_2.y == 1 || pt_1.y - pt_2.y == -1){
res = true;
}
}
if (pt_1.y == pt_2.y){
if (pt_1.x - pt_2.x == 1 || pt_1.x - pt_2.x == -1){
res = true;
}
}
return res;
}