-
Notifications
You must be signed in to change notification settings - Fork 2
/
Chronos.java
executable file
·130 lines (106 loc) · 3.41 KB
/
Chronos.java
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
*
*
* Chronos.java
*
* Created on 26. September 2004, 19:07
*/
/** chronical order to identify wether a card is popped, placed, moved
* and wether the turn is finished or the complete game
*
* @author peter karich
*/
public class Chronos
{
int moveNo=0;
boolean finishedGame, finishedTurn, retFromBeginning, lastMoves;
/** a whole turn is splitted into several steps
*/
static int FRESH=0, SHOWED=1, STARTCARD_PLACED=2, status;
private boolean sthWasClicked;
public Chronos()
{ status=FRESH;
finishedGame=false;
finishedTurn=false;
retFromBeginning=true;
lastMoves=false;
}
public void newTurn(boolean fromBeg)
{ finishedTurn=false;
retFromBeginning=true;//!!important -> this var is false if this player will see forgotten moves of the other one. But if he had forgotten moves than he shouldn't able to see forgotten moves of the other player
sthWasClicked=false;
if(fromBeg) status=FRESH;
else status=STARTCARD_PLACED;
}
public void setStatus(int s)
{ status=s;
if(getStatus().equals("undefined"))
{ throw new Error("sth gowes wrong in class chronos");
}
}
public String getStatus()
{ String tmp="undefined";
switch(status)
{ case 0: tmp="none"; break;
case 1: tmp="showed"; break;
case 2: tmp="placed"; break;
}
return tmp;
}
public void setGameIsFinished()
{ finishedGame=true;
}
public void setTurnIsFinished()
{ finishedTurn=true;
}
public boolean isGameFinished()
{ return finishedGame;
}
public void setSthWasClicked()
{ sthWasClicked=false;
}
public boolean sthWasClicked()
{ return sthWasClicked;
}
public boolean fresh()
{ return status==FRESH;
}
public boolean showed()
{ return status==SHOWED;
}
public boolean placedStartCard()
{ return status==STARTCARD_PLACED;
}
public boolean isTurnFinished()
{ return finishedTurn;
}
public void setLastMoves(boolean b)
{ lastMoves=b;
}
public boolean lastMoves()
{ return lastMoves;
}
public void setTheOtherPlayerIsNotReady()
{ retFromBeginning=false;
finishedTurn=true;
}
public boolean fromBeginning()
{ return retFromBeginning;
}
public void nextMove()
{ moveNo++;
}
public void prevMove()
{ moveNo--;
}
public int getMoveNo()
{ return moveNo/2+1;
}
}