cz.cvut.agents.rph.reversi.main
Class ReversiCreator

java.lang.Object
  extended by cz.cvut.agents.rph.reversi.main.HeadlessReversiCreator
      extended by cz.cvut.agents.rph.reversi.main.ReversiCreator
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class ReversiCreator
extends HeadlessReversiCreator
implements java.awt.event.ActionListener

Creator of the Reversi game. Main entry point of the game. Author: Ondrej Vanek Date: 10/3/12 Time: 10:09 AM


Field Summary
protected static int FRAME_HEIGHT
          Height of the JFrame holding the ReversiView.
protected static int FRAME_WIDTH
          Width of the JFrame holding the ReversiView.
protected  ReversiView view
          View of the game
 
Fields inherited from class cz.cvut.agents.rph.reversi.main.HeadlessReversiCreator
controller, model, PLAYGROUND_HEIGHT, PLAYGROUND_WIDTH, timeoutInMilis
 
Constructor Summary
ReversiCreator()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          For restarting purposes.
protected  ReversiController createGame(int width, int height, ReversiPlayer player1, ReversiPlayer player2)
          Creates the whole game.
static void main(java.lang.String[] args)
          Creates a Reversi game.
private  ReversiGameResult playGame()
          Calls the controller with to execute the game.
private  void setLookAndFeel()
          Sets nicer look&feel (Nimbus - works from Java 6.10 further).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAME_WIDTH

protected static final int FRAME_WIDTH
Width of the JFrame holding the ReversiView.

See Also:
Constant Field Values

FRAME_HEIGHT

protected static final int FRAME_HEIGHT
Height of the JFrame holding the ReversiView.

See Also:
Constant Field Values

view

protected ReversiView view
View of the game

Constructor Detail

ReversiCreator

public ReversiCreator()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Creates a Reversi game. Players can be specified in the arguments

Parameters:
args - full names of the player classes (e.g. cz.cvut.agents.rph.reversi.players.WrongMovePlayer) and size of the board (all optional).
Throws:
java.lang.Exception

createGame

protected ReversiController createGame(int width,
                                       int height,
                                       ReversiPlayer player1,
                                       ReversiPlayer player2)
                                throws java.lang.Exception
Creates the whole game.

Overrides:
createGame in class HeadlessReversiCreator
Parameters:
width - width of the playground.
height - height of the playground.
player1 - first player.
player2 - second player.
Returns:
controller responsible for the game execution - for restarting purposes, accessible as field as well.
Throws:
java.lang.Exception - if something goes wrong, inspect this guy.

playGame

private ReversiGameResult playGame()
                            throws java.lang.Exception
Calls the controller with to execute the game.

Returns:
result of the game.
Throws:
java.lang.Exception

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
For restarting purposes.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - event (from the ReversiView.

setLookAndFeel

private void setLookAndFeel()
Sets nicer look&feel (Nimbus - works from Java 6.10 further).