bluegammon.logic
Class LocalPlayer

java.lang.Object
  extended bybluegammon.logic.Player
      extended bybluegammon.logic.LocalPlayer
All Implemented Interfaces:
PopupListener, StringInputHandler

public class LocalPlayer
extends Player
implements StringInputHandler, PopupListener

A local player has access to the actual device. A LocalPlayer is coupled with the BoardCanvas, knowing the low-level gui states and receives interaction calls from the gui.

Author:
Peter Andersson

Constructor Summary
LocalPlayer(int id, char[] name, boolean white, BoardCanvas canvas)
          Constructs a local player.
 
Method Summary
 boolean commandAction(javax.microedition.lcdui.Command c)
          Called from BoardCanvas when a command is executed.
 void handleStringInput(java.lang.String s)
          Called when user has entered some input as string.
 boolean keyPressed(int keyCode, int gameCode)
          Called from BoardCanvas when a key is pressed.
 void selectedChoice(byte choice, boolean timeOut)
          PopupListener implementation, called from a popup.
 
Methods inherited from class bluegammon.logic.Player
addListener, getId, getName, init, isWhite, setWhite
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalPlayer

public LocalPlayer(int id,
                   char[] name,
                   boolean white,
                   BoardCanvas canvas)
Constructs a local player.

Parameters:
id - The id of the local player.
name - The name of the local player.
white - The color of the local player.
canvas - The backgammon board canvas this local player acts upon.
Method Detail

keyPressed

public boolean keyPressed(int keyCode,
                          int gameCode)
Called from BoardCanvas when a key is pressed.

Parameters:
keyCode - The key code.
gameCode - The game code.
Returns:
true if the keypress is consumed, false otherwise

commandAction

public boolean commandAction(javax.microedition.lcdui.Command c)
Called from BoardCanvas when a command is executed.

Parameters:
c - The command.
Returns:
true if event is consumed, false otherwise.

handleStringInput

public void handleStringInput(java.lang.String s)
Description copied from interface: StringInputHandler
Called when user has entered some input as string.

Specified by:
handleStringInput in interface StringInputHandler
Parameters:
s - The input.

selectedChoice

public void selectedChoice(byte choice,
                           boolean timeOut)
PopupListener implementation, called from a popup.

Specified by:
selectedChoice in interface PopupListener
Parameters:
choice - The index of the alternatives that were chosen.
timeOut - True if the choice was made because of a time out.