de.tabacha.cgo.gui
Class HumanPlayer

java.lang.Object
  extended byde.tabacha.cgo.AbstractEngine
      extended byde.tabacha.cgo.gui.HumanPlayer
All Implemented Interfaces:
Constants, Engine, java.util.EventListener, javax.swing.event.MouseInputListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

final class HumanPlayer
extends AbstractEngine
implements javax.swing.event.MouseInputListener

The strategy is: The user makes the move. Design pattern: routine strategy, move builder
$Id: HumanPlayer.java,v 1.16 2004/07/30 21:06:35 mk Exp $

Version:
$Revision: 1.16 $
Threadsafe?
false

Field Summary
 
Fields inherited from interface de.tabacha.cgo.Constants
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W
 
Constructor Summary
HumanPlayer()
          Constructor.
HumanPlayer(BoardComponent editor)
          Constructor.
 
Method Summary
 boolean canPlayBothSides()
          This default implementation always returns false.
 java.lang.String getVersion()
          Returns the localized version of the version property.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void setEditor(BoardComponent editor)
          Sets the GUI object where moves are entered.
 Move think(Board position)
          Registers this object to the editor as a mouse listener and waits until the move is completed.
 
Methods inherited from class de.tabacha.cgo.AbstractEngine
getAuthor, getDescription, getI18nProperty, getName, initGame, random
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HumanPlayer

public HumanPlayer(BoardComponent editor)
Constructor.

Parameters:
editor - The GUI object where moves are entered.

HumanPlayer

public HumanPlayer()
Constructor.

Method Detail

setEditor

public void setEditor(BoardComponent editor)
               throws java.lang.IllegalStateException
Sets the GUI object where moves are entered. Must not be done during editing.

Throws:
java.lang.IllegalStateException - When changing the editor during an edit.

getVersion

public java.lang.String getVersion()
Description copied from class: AbstractEngine
Returns the localized version of the version property. If this property is the same for all languages or needs special treatment, overwrite this method.

Specified by:
getVersion in interface Engine
Overrides:
getVersion in class AbstractEngine
See Also:
Engine.getVersion()

canPlayBothSides

public boolean canPlayBothSides()
Description copied from class: AbstractEngine
This default implementation always returns false.

Specified by:
canPlayBothSides in interface Engine
Overrides:
canPlayBothSides in class AbstractEngine
See Also:
Engine.canPlayBothSides()

think

public Move think(Board position)
Registers this object to the editor as a mouse listener and waits until the move is completed. This method must not be called from the AWTEventThread. (Notification means: the move is completed. Interruption means: the game is aborted.)

Specified by:
think in interface Engine
Parameters:
position - The actual position
Returns:
The move the routine makes

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener