fi.cs.helsinki.ohtur6.gamemanagement.bowlinggamemanagement
Class BowlingGameEventHandler

java.lang.Object
  |
  +--fi.cs.helsinki.ohtur6.gamemanagement.GameEventHandler
        |
        +--fi.cs.helsinki.ohtur6.gamemanagement.bowlinggamemanagement.BowlingGameEventHandler

public class BowlingGameEventHandler
extends GameEventHandler

This class implements the event handler of Bowling Application.


Field Summary
private  int CREATE_PLAYER
           
private  int END_GAME
           
private  int FAIL_CREATE_PLAYER
           
private  int FAIL_MODIFY_POINTS
           
private  int FAIL_NOT_SLASH_ADD
           
private  int FAIL_NOT_X_ADD
           
private  int FAIL_TO_SLASH
           
private  int FAIL_TO_X
           
private  int FAIL_X_ADD
           
private  int FINAL_TO_SLASH
           
private  int FINAL_TO_X
           
private  int[][] finalRound
          Final round tracker
private  int GAME_FINISHED
          Indexes for events
private  int MODIFY_POINTS
           
private  int NEW_GAME_CREATED
           
private  int NOT_SLASH_ADD
           
private  int NOT_X_ADD
          Bowlingstate events:
private  int PLAYER_FINISHED
           
private  int[] playerIndexes
          This is used to sort who is the 1st player.
private  int TO_SLASH
           
private  int TO_X
           
private  int VIEW_REPORT
           
private  int X_ADD
           
 
Constructor Summary
BowlingGameEventHandler()
          Plain constructor of this class
 
Method Summary
protected  void addPoints(int playerIndex, java.lang.String result)
          Save points to player dataHolder, please note that this method does not override the addPoints(int,int) given in GameEventHandler.
 int haveEvent(int event, GameEventComponent gec)
          This is the main event handler.
protected  boolean modifyPoints(int playerIndex, int fieldNumber, java.lang.String result)
          Save points to player dataHolder, please note that this method does not override the addPoints(int,int) given in GameEventHandler.
private  int parseScoreToInt(java.lang.String scoreString)
          This method tries to parse the string given to it as a scorevalue.
private  int playerResolve(int playerToBeSolved)
          This maps the player index to range 0-3, regardless of what the player index might be.
 
Methods inherited from class fi.cs.helsinki.ohtur6.gamemanagement.GameEventHandler
addPoints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GAME_FINISHED

private final int GAME_FINISHED
Indexes for events

See Also:
Constant Field Values

MODIFY_POINTS

private final int MODIFY_POINTS
See Also:
Constant Field Values

CREATE_PLAYER

private final int CREATE_PLAYER
See Also:
Constant Field Values

FAIL_CREATE_PLAYER

private final int FAIL_CREATE_PLAYER
See Also:
Constant Field Values

FAIL_MODIFY_POINTS

private final int FAIL_MODIFY_POINTS
See Also:
Constant Field Values

VIEW_REPORT

private final int VIEW_REPORT
See Also:
Constant Field Values

END_GAME

private final int END_GAME
See Also:
Constant Field Values

NEW_GAME_CREATED

private final int NEW_GAME_CREATED
See Also:
Constant Field Values

NOT_X_ADD

private final int NOT_X_ADD
Bowlingstate events:

See Also:
Constant Field Values

NOT_SLASH_ADD

private final int NOT_SLASH_ADD
See Also:
Constant Field Values

X_ADD

private final int X_ADD
See Also:
Constant Field Values

TO_SLASH

private final int TO_SLASH
See Also:
Constant Field Values

TO_X

private final int TO_X
See Also:
Constant Field Values

FINAL_TO_SLASH

private final int FINAL_TO_SLASH
See Also:
Constant Field Values

FINAL_TO_X

private final int FINAL_TO_X
See Also:
Constant Field Values

PLAYER_FINISHED

private final int PLAYER_FINISHED
See Also:
Constant Field Values

FAIL_NOT_X_ADD

private final int FAIL_NOT_X_ADD
See Also:
Constant Field Values

FAIL_NOT_SLASH_ADD

private final int FAIL_NOT_SLASH_ADD
See Also:
Constant Field Values

FAIL_X_ADD

private final int FAIL_X_ADD
See Also:
Constant Field Values

FAIL_TO_SLASH

private final int FAIL_TO_SLASH
See Also:
Constant Field Values

FAIL_TO_X

private final int FAIL_TO_X
See Also:
Constant Field Values

finalRound

private int[][] finalRound
Final round tracker


playerIndexes

private int[] playerIndexes
This is used to sort who is the 1st player.

Constructor Detail

BowlingGameEventHandler

public BowlingGameEventHandler()
Plain constructor of this class

Method Detail

haveEvent

public int haveEvent(int event,
                     GameEventComponent gec)
Description copied from class: GameEventHandler
This is the main event handler. Each game must implement this to provide its own set of events.

Specified by:
haveEvent in class GameEventHandler
Parameters:
event - defines the event number to be given.
gec - is a reference to EventComponent where the event originated from.
Returns:
returns the new state of the game
See Also:
GameEventHandler.haveEvent(int, fi.cs.helsinki.ohtur6.gui.GameEventComponent)

addPoints

protected void addPoints(int playerIndex,
                         java.lang.String result)
Save points to player dataHolder, please note that this method does not override the addPoints(int,int) given in GameEventHandler.

Parameters:
playerIndex - Index of the player to the points are added

modifyPoints

protected boolean modifyPoints(int playerIndex,
                               int fieldNumber,
                               java.lang.String result)
Save points to player dataHolder, please note that this method does not override the addPoints(int,int) given in GameEventHandler.

Parameters:
playerIndex - Index of the player to the points are added
fieldNumber - number of the field to be modified
result - String result to be added.

parseScoreToInt

private int parseScoreToInt(java.lang.String scoreString)
This method tries to parse the string given to it as a scorevalue. It maps "/" mark to value -1, and "X","x" to value 10;

Returns:
the string in int;

playerResolve

private int playerResolve(int playerToBeSolved)
This maps the player index to range 0-3, regardless of what the player index might be.
due to improvements, usage of this method is not required, yet due to timing reasons, references to it have not been removed.

Parameters:
playerToBeSolved - the playerindex to be used later
Returns:
the index in the gameStateView.

(c) ohtuR6