ballwar.model.strategy
Class ScoreStrategy

java.lang.Object
  extended by ballwar.model.strategy.ANoOpStrategy
      extended by ballwar.model.strategy.ScoreStrategy
All Implemented Interfaces:
IUpdateStrategy

public class ScoreStrategy
extends ANoOpStrategy

An ANoOpStrategy-based strategy that increments an associated player's score at every collision and resets that player's score if it is killed. Note that more than one ScoreStrategy can be associated with any given player.


Field Summary
private  IPlayer _player
          The IPlayer associated with this scoring strategy.
 
Fields inherited from interface ballwar.model.IUpdateStrategy
NullObject
 
Constructor Summary
ScoreStrategy()
           
 
Method Summary
 void init(Ball context)
          Associates this strategy with the currently selected player
 void kill(Ball context)
          Sets the player's score to zero.
 void updateCollision(Ball context, Ball target)
          Adds one to the associated player's score.
 
Methods inherited from class ballwar.model.strategy.ANoOpStrategy
updateState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_player

private IPlayer _player
The IPlayer associated with this scoring strategy.

Constructor Detail

ScoreStrategy

public ScoreStrategy()
Method Detail

init

public void init(Ball context)
Associates this strategy with the currently selected player

Specified by:
init in interface IUpdateStrategy
Overrides:
init in class ANoOpStrategy
Parameters:
context - This strategy's context.

updateCollision

public void updateCollision(Ball context,
                            Ball target)
Adds one to the associated player's score.

Specified by:
updateCollision in interface IUpdateStrategy
Overrides:
updateCollision in class ANoOpStrategy
Parameters:
context - This strategy's context.
target - The ball the context collided with.

kill

public void kill(Ball context)
Sets the player's score to zero. Does not kill the context ball.

Specified by:
kill in interface IUpdateStrategy
Overrides:
kill in class ANoOpStrategy
Parameters:
context - This strategy's context.