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

Variable Index

 o 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.

Constructor Index

 o TRules()
constructor

Method Index

 o 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
 o 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
 o newGame()
init the board
 o r(int, int[])
return true if the player can replay
 o 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
 o v(int, int[])
return true if this move is valid
 o 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

Variables

 o 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.

Constructors

 o TRules
 public TRules()
constructor

Methods

 o newGame
 public void newGame()
init the board

Overrides:
newGame in class Rules
 o 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
 o v
 public boolean v(int i,
                  int ttab[])
return true if this move is valid

Overrides:
v in class Rules
 o r
 public boolean r(int bol,
                  int ttab[])
return true if the player can replay

Overrides:
r in class Rules
 o 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
 o 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
 o 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