net.jetrix.winlist
Class SimpleWinlist

java.lang.Object
  extended by net.jetrix.winlist.SimpleWinlist
All Implemented Interfaces:
Winlist
Direct Known Subclasses:
TetrixWinlist

public class SimpleWinlist
extends Object
implements Winlist

A standard winlist using the same scoring as the original TetriNET : the winner gets 3 points if there was 3 or more players (or different teams) involved in the game, 2 points otherwise; the second gets 1 point if there was 5 or more players in the game. The winlist is saved in a xxxx.winlist file.

Version:
$Revision: 506 $, $Date: 2004-12-14 13:07:06 +0100 (mar., 14 déc. 2004) $
Author:
Emmanuel Bourg

Field Summary
protected  WinlistConfig config
           
protected  boolean initialized
           
protected  Logger log
           
protected  boolean persistent
           
protected  List<Score> scores
           
 
Constructor Summary
SimpleWinlist()
           
 
Method Summary
 void clear()
          Remove all entries in the winlist
 WinlistConfig getConfig()
          Return the configuration necessary to create the same winlist
protected  PlineMessage getGainMessage(Score score, long previousScore, long previousRank)
          Build a message displaying the new score and rank of a winner.
 String getId()
          Return the id for this winlist.
 Score getScore(String name, int type)
          Return the score of the specified player or team
 List<Score> getScores(long offset, long length)
          Return the score list in the specified range.
 void init(WinlistConfig config)
          Initialize the winlist.
 boolean isPersistent()
           
protected  void load()
          Load the winlist from a file.
protected  void save()
          Save the winlist to a file.
 void saveGameResult(GameResult result)
          Update the winlist with the specified game result.
 void setId(String id)
          Set the id for this winlist.
 void setPersistent(boolean persistent)
           
 int size()
          Return the number of entries in the winlist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scores

protected List<Score> scores

initialized

protected boolean initialized

persistent

protected boolean persistent

log

protected Logger log

config

protected WinlistConfig config
Constructor Detail

SimpleWinlist

public SimpleWinlist()
Method Detail

getId

public String getId()
Description copied from interface: Winlist
Return the id for this winlist.

Specified by:
getId in interface Winlist

setId

public void setId(String id)
Description copied from interface: Winlist
Set the id for this winlist.

Specified by:
setId in interface Winlist

init

public void init(WinlistConfig config)
Description copied from interface: Winlist
Initialize the winlist.

Specified by:
init in interface Winlist
Parameters:
config - the winlist configuration

getConfig

public WinlistConfig getConfig()
Description copied from interface: Winlist
Return the configuration necessary to create the same winlist

Specified by:
getConfig in interface Winlist

isPersistent

public boolean isPersistent()

setPersistent

public void setPersistent(boolean persistent)

getScore

public Score getScore(String name,
                      int type)
Description copied from interface: Winlist
Return the score of the specified player or team

Specified by:
getScore in interface Winlist
Parameters:
name - the name of the player or team
type - the score type (0: player, 1: team)

getScores

public List<Score> getScores(long offset,
                             long length)
Description copied from interface: Winlist
Return the score list in the specified range.

Specified by:
getScores in interface Winlist
Parameters:
offset - the beginning of the range
length - the length of the range

saveGameResult

public void saveGameResult(GameResult result)
Description copied from interface: Winlist
Update the winlist with the specified game result.

Specified by:
saveGameResult in interface Winlist

clear

public void clear()
Description copied from interface: Winlist
Remove all entries in the winlist

Specified by:
clear in interface Winlist

size

public int size()
Description copied from interface: Winlist
Return the number of entries in the winlist

Specified by:
size in interface Winlist

load

protected void load()
Load the winlist from a file.


save

protected void save()
Save the winlist to a file.


getGainMessage

protected PlineMessage getGainMessage(Score score,
                                      long previousScore,
                                      long previousRank)
Build a message displaying the new score and rank of a winner.



Copyright © 2001-2008 Emmanuel Bourg. All Rights Reserved.