Betty v1.1.0

christophedelory.betty.model.rank
Class PlayerRank

java.lang.Object
  extended by christophedelory.betty.model.rank.PlayerRank

public final class PlayerRank
extends Object

The association between a player and its rank, based on the following statistics: total score and result, result difference with other players.

Version:
$Revision$
Author:
Christophe Delory

Method Summary
 LocalPlayer getPlayer()
          Returns the player EJB object.
static PlayerRank getPlayerRank(List<PlayerRank> playerRanks, LocalPlayer dbPlayer)
          Returns the player rank instance from the list that corresponds to the specified player.
 int getRank()
          Returns the current player rank value.
 int getResult()
          Returns the current total result.
 int getResultDifference()
          Returns the current result difference.
 int getScore()
          Returns the current score.
 void setRank(int rank)
          Initializes the player rank value.
 String toString()
          Returns a string representation of this object.
 PlayerIdDetails toXml(Locale[] locales)
          Returns an XML representation of this object.
 void update(LocalPlayerScore dbPlayerScore)
          Updates the total score and result from the specified player score and result.
 void update(LocalPlayerScore dbPlayerScore, LocalPlayerScore dbOpponentPlayerScore)
          Updates the result difference based on the two player results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getPlayerRank

public static PlayerRank getPlayerRank(List<PlayerRank> playerRanks,
                                       LocalPlayer dbPlayer)
Returns the player rank instance from the list that corresponds to the specified player. If not found in the list, creates it and adds it to the list.

Parameters:
playerRanks - a list of player ranks. Should not be null.
dbPlayer - a player. Should not be null.
Returns:
a player rank. Should not be null.
Throws:
NullPointerException - if playerRanks is null.
NullPointerException - if dbPlayer is null.
EJBException - if any exception occured during the execution of this method.

getPlayer

public LocalPlayer getPlayer()
Returns the player EJB object.

Returns:
a player EJB object. Shall not be null.

getRank

public int getRank()
Returns the current player rank value.

Returns:
a rank value.
See Also:
setRank(int)

setRank

public void setRank(int rank)
Initializes the player rank value.

Parameters:
rank - a rank value.
See Also:
getRank()

getScore

public int getScore()
Returns the current score. There is no constraint on its value.

Returns:
a score value.

getResult

public int getResult()
Returns the current total result. There is no constraint on its value.

Returns:
a result value.

getResultDifference

public int getResultDifference()
Returns the current result difference. Only valid if events involve 2 players. There is no constraint on its value.

Returns:
a result difference.

update

public void update(LocalPlayerScore dbPlayerScore)
Updates the total score and result from the specified player score and result.

Parameters:
dbPlayerScore - a player score EJB object.
Throws:
NullPointerException - if dbPlayerScore is null.
EJBException - if any exception occured during the execution of this method.
See Also:
update(LocalPlayerScore,LocalPlayerScore)

update

public void update(LocalPlayerScore dbPlayerScore,
                   LocalPlayerScore dbOpponentPlayerScore)
Updates the result difference based on the two player results. Only valid if events involve 2 players.

Parameters:
dbPlayerScore - a player score EJB object.
dbOpponentPlayerScore - a player score EJB object.
Throws:
NullPointerException - if dbPlayerScore is null.
NullPointerException - if dbOpponentPlayerScore is null.
EJBException - if any exception occured during the execution of this method.
See Also:
update(LocalPlayerScore)

toXml

public PlayerIdDetails toXml(Locale[] locales)
Returns an XML representation of this object.

Parameters:
locales - the preferred locales that the caller will accept content in. Should not be null.
Returns:
an XML object representing this object.
Throws:
NullPointerException - if locales is null.
EJBException - if any exception occured during the execution of this method.

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a string representing this object.

© 2008-2009 Christophe Delory

Copyright © 2008-2009 Christophe Delory. All Rights Reserved.