org.moyoman.client.reference
Class MousePlayer

java.lang.Object
  |
  +--org.moyoman.comm.client.Player
        |
        +--org.moyoman.comm.client.NonvalidatedPlayer
              |
              +--org.moyoman.client.reference.MousePlayer
All Implemented Interfaces:
EventListener, MouseListener

public class MousePlayer
extends NonvalidatedPlayer
implements MouseListener

Provides an implementation of NonvalidatedPlayer to allow mouse input.

Since:
v0.02
Version:
v0.03
Author:
Jeffrey M. Thompson

Field Summary
private  Move _move
          Current move.
private  short _moveNumber
          Current move number.
private  IMoyoman _owner
          Owner.
private static boolean DEBUG
           
 
Fields inherited from class org.moyoman.comm.client.NonvalidatedPlayer
 
Fields inherited from class org.moyoman.comm.client.Player
color, handicap
 
Constructor Summary
MousePlayer(IMoyoman owner, Color c, Handicap h)
          Construct this object with the given parameters.
MousePlayer(IMoyoman owner, Color c, Handicap h, String id)
           
 
Method Summary
protected  String getHomeDirectory()
          Return the home directory.
 String getIdentifyingInfo()
          Return identifying information about this player.
protected  Move getRequestedMove()
          The derived class must override this method to get a move from the player.
protected  void makeValidatedMove(MoveDescriptor md)
          The derived class must override this method to make a move.
 void mouseClicked(MouseEvent event)
          Respond to a mouse click.
 void mouseEntered(MouseEvent event)
          Implement the mouse listener inteface.
 void mouseExited(MouseEvent event)
          Implement the mouse listener inteface.
 void mousePressed(MouseEvent event)
          Implement the mouse listener inteface.
 void mouseReleased(MouseEvent event)
          Implement the mouse listener inteface.
protected  void setIllegalMoves(Stone[] moves)
          This method sets the moves that are illegal, excluding the ko.
protected  void setKo(Stone ko)
          This method sets the move that is illegal because it immediately retakes the ko.
 
Methods inherited from class org.moyoman.comm.client.NonvalidatedPlayer
derivedMakeMove, derivedRequestMove, getGameRecord, getId, getKo, getMoveNumber, isSelfInitializingUser, isValidatedUser, validateMove
 
Methods inherited from class org.moyoman.comm.client.Player
getColor, getHandicap, makeMove, makeMoveNoEvents, registerEndOfGameMoveListener, registerMakeMoveListener, registerRequestMoveListener, requestMove, unregisterEndOfGameListeners, unregisterMakeMoveListeners, unregisterRequestMoveListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

_owner

private IMoyoman _owner
Owner.


_move

private Move _move
Current move.


_moveNumber

private short _moveNumber
Current move number.

Constructor Detail

MousePlayer

public MousePlayer(IMoyoman owner,
                   Color c,
                   Handicap h)
            throws InternalErrorException
Construct this object with the given parameters.

Parameters:
owner - The owner.
c - The color of the player.
h - The handicap of the game.
Throws:
InternalErrorException - Thrown if the operation fails for any reason.

MousePlayer

public MousePlayer(IMoyoman owner,
                   Color c,
                   Handicap h,
                   String id)
            throws InternalErrorException
Method Detail

getIdentifyingInfo

public String getIdentifyingInfo()
Return identifying information about this player.

Specified by:
getIdentifyingInfo in class Player
Returns:
A String object such as "MoyomanPlayer".
Since:
v0.02

mouseClicked

public void mouseClicked(MouseEvent event)
Respond to a mouse click.

Specified by:
mouseClicked in interface MouseListener
Since:
v0.02

mouseEntered

public void mouseEntered(MouseEvent event)
Implement the mouse listener inteface.

Specified by:
mouseEntered in interface MouseListener
Parameters:
event - A mouse event.
Since:
v1.0

mouseExited

public void mouseExited(MouseEvent event)
Implement the mouse listener inteface.

Specified by:
mouseExited in interface MouseListener
Parameters:
event - A mouse event.
Since:
v1.0

mousePressed

public void mousePressed(MouseEvent event)
Implement the mouse listener inteface.

Specified by:
mousePressed in interface MouseListener
Parameters:
event - A mouse event.
Since:
v1.0

mouseReleased

public void mouseReleased(MouseEvent event)
Implement the mouse listener inteface.

Specified by:
mouseReleased in interface MouseListener
Parameters:
event - A mouse event.
Since:
v1.0

getHomeDirectory

protected String getHomeDirectory()
Return the home directory.

Since:
v0.02

setIllegalMoves

protected void setIllegalMoves(Stone[] moves)
This method sets the moves that are illegal, excluding the ko.

Parameters:
moves - An array of Stone objects which are illegal moves.

setKo

protected void setKo(Stone ko)
This method sets the move that is illegal because it immediately retakes the ko.

Parameters:
ko - The stone which is an illegal move without making a ko threat. This parameter may be null if there is no ko.

getRequestedMove

protected Move getRequestedMove()
The derived class must override this method to get a move from the player. The move returned by this method will be validated.

Specified by:
getRequestedMove in class NonvalidatedPlayer
Returns:
The move to be made.

makeValidatedMove

protected void makeValidatedMove(MoveDescriptor md)
                          throws IllegalMoveException,
                                 InternalErrorException
The derived class must override this method to make a move. The move has already been validated before this method is called.

Specified by:
makeValidatedMove in class NonvalidatedPlayer
Parameters:
md - The move to be made.
Throws:
Exception - Thrown if the operation fails for any reason.
InternalErrorException - Thrown if the operation fails for any reason.
IllegalMoveException - - Thrown if the move to be made is illegal.