Class TRules
java.lang.Object
|
+----Rules
|
+----TRules
- public class TRules
- extends Rules
TRules
TicTacToe Rules
this file is designed to be an example for creating games for jGames
-the comment "DNR" (do not remove) means that this method or variable
musn't be removed but should be changed to fit the game you are coding
-the comment "DNC" (do not change) means that this method or variable
must be there and left as it's.
Each of the folowing methods works for one player only, that's why you need
to write a rtab() method that reverse the table if the player who is playing
isn't player1.
all the calls to thoses methods are done from Rules.java
- Version:
- 1.0b1 25/04/98
-
tab
- tab is where the game is saved, this array represent player1's board
where 0 values are unchecked squares , 1 player1's crosses and 2 for player 2.
-
TRules()
- constructor
-
m(int, int[])
- move, this method is called by move() it returns a new array
for this move at this position on this board as if the paler was player 1
-
msg(int, boolean)
- message to send a player when he plays something
if p = true that does mean it's for the player and false for the oponnent
-
newGame()
- init the board
-
r(int, int[])
-
return true if the player can replay
-
rtab(int[])
- reverse the array, this is used as m(),v(),r() works only for 1 player
so we reverse the array each time player2 plays
-
v(int, int[])
-
return true if this move is valid
-
w(int[])
- win, loose , tie
return 0 if not finished
1 if this player win
2 if the opponent win
-1 if it's a tie
tab
public int tab[]
- tab is where the game is saved, this array represent player1's board
where 0 values are unchecked squares , 1 player1's crosses and 2 for player 2.
TRules
public TRules()
- constructor
newGame
public void newGame()
- init the board
- Overrides:
- newGame in class Rules
rtab
public int[] rtab(int stab[])
- reverse the array, this is used as m(),v(),r() works only for 1 player
so we reverse the array each time player2 plays
- Overrides:
- rtab in class Rules
v
public boolean v(int i,
int ttab[])
- return true if this move is valid
- Overrides:
- v in class Rules
r
public boolean r(int bol,
int ttab[])
- return true if the player can replay
- Overrides:
- r in class Rules
m
public int[] m(int i,
int ttab[])
- move, this method is called by move() it returns a new array
for this move at this position on this board as if the paler was player 1
- Overrides:
- m in class Rules
w
public int w(int ttab[])
- win, loose , tie
return 0 if not finished
1 if this player win
2 if the opponent win
-1 if it's a tie
- Overrides:
- w in class Rules
msg
public String msg(int bol,
boolean p)
- message to send a player when he plays something
if p = true that does mean it's for the player and false for the oponnent
- Overrides:
- msg in class Rules