cz.cvut.agents.rph.reversi
Class ReversiModel

java.lang.Object
  extended by cz.cvut.agents.rph.core.GameModel
      extended by cz.cvut.agents.rph.reversi.ReversiModel

public class ReversiModel
extends GameModel

Concrete instance of the Reversi game model. Author: Ondrej Vanek Date: 10/3/12 Time: 10:05 AM


Nested Class Summary
 
Nested classes/interfaces inherited from class cz.cvut.agents.rph.core.GameModel
GameModel.GameStatus
 
Field Summary
protected  int[][] board
           
static int EMPTY_SQUARE
           
private  java.lang.String errorPlayerName
           
(package private)  ReversiGameResult gameResult
           
protected  int height
           
static int PLAYER1_COLOR
           
protected  long player1MaxTime
           
private  java.lang.String player1Name
           
static int PLAYER2_COLOR
           
protected  long player2MaxTime
           
private  java.lang.String player2Name
           
private  java.lang.String timeoutPlayerName
           
protected  int width
           
 
Fields inherited from class cz.cvut.agents.rph.core.GameModel
gameStatus
 
Constructor Summary
ReversiModel(int width, int height)
           
 
Method Summary
 boolean canPlay(int player)
           
 void changePlayPauseGameStatus()
           
private  void changeStonesInDirection(int player, int dirX, int dirY, int x, int y)
           
 void confirmMoves()
          Puts -1,0,1 to the board, instead of 2,3,4,5 (temporary colors).
protected  int[][] copyBoard(int[][] board)
           
(package private)  int[][] getBoard()
           
 int[][] getBoardCopy()
           
 java.lang.String getErrorPlayerName()
           
 ReversiGameResult getGameResult()
           
 int getHeight()
           
 long getPlayer1MaxTime()
           
 java.lang.String getPlayer1Name()
           
(package private)  int getPlayer1Stones()
           
 long getPlayer2MaxTime()
           
 java.lang.String getPlayer2Name()
           
(package private)  int getPlayer2Stones()
           
private  int getStonesWithColor(int color)
           
 java.lang.String getTimeoutPlayerName()
           
 int getValue(int x, int y)
           
 int getWidth()
           
private  void initPlayground()
           
 boolean isCorrectMove(int player, ReversiMove move)
           
private  boolean isCorrectMoveInDirection(int player, int dirX, int dirY, int x, int y)
           
 boolean isEndOfGame()
           
 void putMove(int player, ReversiMove move)
          Puts the move of a player to the board.
 void restart()
           
 void setGameResult(ReversiGameResult gameResult, java.lang.String errorPlayerName, java.lang.String timeoutPlayerName)
          Sets the game result AND notify the views to react.
 void setPlayerNames(java.lang.String player1Name, java.lang.String player2Name)
           
private  void updateMaxTimes(int player, ReversiMove move)
           
 
Methods inherited from class cz.cvut.agents.rph.core.GameModel
addView, getGameStatus, notifyViews, removeView, setGameStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

protected int[][] board

width

protected int width

height

protected int height

player1MaxTime

protected long player1MaxTime

player2MaxTime

protected long player2MaxTime

player1Name

private java.lang.String player1Name

player2Name

private java.lang.String player2Name

gameResult

ReversiGameResult gameResult

errorPlayerName

private java.lang.String errorPlayerName

timeoutPlayerName

private java.lang.String timeoutPlayerName

EMPTY_SQUARE

public static final int EMPTY_SQUARE
See Also:
Constant Field Values

PLAYER1_COLOR

public static final int PLAYER1_COLOR
See Also:
Constant Field Values

PLAYER2_COLOR

public static final int PLAYER2_COLOR
See Also:
Constant Field Values
Constructor Detail

ReversiModel

public ReversiModel(int width,
                    int height)
Method Detail

isEndOfGame

public boolean isEndOfGame()
Specified by:
isEndOfGame in class GameModel

setPlayerNames

public void setPlayerNames(java.lang.String player1Name,
                           java.lang.String player2Name)

getPlayer1Name

public java.lang.String getPlayer1Name()

getPlayer2Name

public java.lang.String getPlayer2Name()

canPlay

public boolean canPlay(int player)

changePlayPauseGameStatus

public void changePlayPauseGameStatus()

setGameResult

public void setGameResult(ReversiGameResult gameResult,
                          java.lang.String errorPlayerName,
                          java.lang.String timeoutPlayerName)
Sets the game result AND notify the views to react.

Parameters:
gameResult -
errorPlayerName -
timeoutPlayerName -

restart

public void restart()
Specified by:
restart in class GameModel

getBoardCopy

public int[][] getBoardCopy()

copyBoard

protected int[][] copyBoard(int[][] board)

getBoard

int[][] getBoard()

getPlayer1Stones

int getPlayer1Stones()

getPlayer2Stones

int getPlayer2Stones()

getStonesWithColor

private int getStonesWithColor(int color)

getWidth

public int getWidth()

getHeight

public int getHeight()

initPlayground

private void initPlayground()

getValue

public int getValue(int x,
                    int y)

getGameResult

public ReversiGameResult getGameResult()
Specified by:
getGameResult in class GameModel

putMove

public void putMove(int player,
                    ReversiMove move)
Puts the move of a player to the board. Places temporary color onto the board. Call confirmMoves to set the board values to the normal 0,1 values.

Parameters:
player -
move -

updateMaxTimes

private void updateMaxTimes(int player,
                            ReversiMove move)

getPlayer1MaxTime

public long getPlayer1MaxTime()

getPlayer2MaxTime

public long getPlayer2MaxTime()

changeStonesInDirection

private void changeStonesInDirection(int player,
                                     int dirX,
                                     int dirY,
                                     int x,
                                     int y)

confirmMoves

public void confirmMoves()
Puts -1,0,1 to the board, instead of 2,3,4,5 (temporary colors).


isCorrectMove

public boolean isCorrectMove(int player,
                             ReversiMove move)

isCorrectMoveInDirection

private boolean isCorrectMoveInDirection(int player,
                                         int dirX,
                                         int dirY,
                                         int x,
                                         int y)

getTimeoutPlayerName

public java.lang.String getTimeoutPlayerName()

getErrorPlayerName

public java.lang.String getErrorPlayerName()