-
Notifications
You must be signed in to change notification settings - Fork 1
/
match.pde
46 lines (42 loc) · 842 Bytes
/
match.pde
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
boolean readyForStart() {
if(gameStarted()) {
return false;
}
return true;
}
boolean matchFinish() {
int totalGames = (gameType * 2) + 3;
int gamesToWin = (totalGames/2)+1;
if(gameStarted()) {
if(gamesWin[1] == gamesToWin || gamesWin[2] == gamesToWin) {
return true;
}
}
return false;
}
int getWinner() {
if(gamesWin[1] > gamesWin[2]) {
return 1;
}
else if(gamesWin[2] > gamesWin[1]) {
return 2;
}
return 0;
}
void closeMatch() {
if(confirm(lang.getString("confirm-stop-title"), lang.getString("confirm-stop-text"))) {
if(!matchFinish()) {
if(totalPoints > 0 || currentGame > 1) {
saveMatch();
}
}
endMatch();
}
}
void endMatch() {
gameStart = false;
sides = 12;
changedInLastGame = false;
setDefaults();
loop();
}