Lamoule Class Reference

Manage lamoule's ladder. More...

#include <lamoule.h>

Inheritance diagram for Lamoule:

Plugin

List of all members.

Public Member Functions

 Lamoule (BotKernel *)
 Constructor.
vector< string > getTopShot ()
 Get the lamoule's topshot.
void setTopShot (string, string, string)
 Set the lamoule's topshot.
void addPlayer (string, unsigned int)
 Add a player in the ladder.
char increaseScore (string, int, unsigned int, bool)
 Increase score for a player.
vector< TiXmlElement * > sort (sort_criterion, int)
 Sort elements to get stats.
vector< string > get5first (sort_criterion, int)
 Get 5 first.
vector< string > getInfosPlayer (string, int)
 Get informations about a player.
bool deletePlayer (string)
 Remove a player from the ladder.
void purifyFile (int)
 Purify File.
bool setNextScore (int)
 Set next score.
int generateScore ()
 generate score

Private Member Functions

void initFile ()
 Initialize the XML file.

Private Attributes

TiXmlDocument * doc
 Represent the xml document.
TiXmlNode * root
 Represent documents's root.
unsigned int nextScore
 Stores the next score.
int MAX_SCORE
 Maximul score.
int FIRST_FLOOR
 First floor.
int SECOND_FLOOR
 Second floor.


Detailed Description

Manage lamoule's ladder.

Manage lamoule's ladder. Score are stored in an XML file

Definition at line 57 of file lamoule.h.


Constructor & Destructor Documentation

Lamoule::Lamoule ( BotKernel b  ) 


Member Function Documentation

void Lamoule::addPlayer ( string  nick,
unsigned int  initialScore 
)

Add a player in the ladder.

Add a player in the ladder

Parameters:
nick Nick to add
initialScore Initial player's score

Definition at line 125 of file lamoule.cpp.

References doc, Tools::intToStr(), and root.

Referenced by increaseScore().

bool Lamoule::deletePlayer ( string  nick  ) 

Remove a player from the ladder.

Delete a player from the ladder

Parameters:
nick Nick to delete
Returns:
true i the nick has been deleted, else false

Definition at line 330 of file lamoule.cpp.

References doc, root, and Tools::to_lower().

Referenced by deleteplayer().

int Lamoule::generateScore (  ) 

generate score

Generate a random score. If "nextscore" is set, then it's returned

Returns:
generated score

Definition at line 143 of file lamoule.cpp.

References FIRST_FLOOR, MAX_SCORE, nextScore, Tools::random(), and SECOND_FLOOR.

Referenced by lamoule().

vector< string > Lamoule::get5first ( sort_criterion  criterion,
int  min_attempts 
)

Get 5 first.

Get top 5 depending on score or average

Parameters:
criterion Sort criterion
min_attempts Minimal attempts number to appear in ladder
Returns:
A vector with top 5 players

Definition at line 262 of file lamoule.cpp.

References Tools::doubleToStr(), Tools::intToStr(), sort(), and Tools::strToDouble().

Referenced by top5(), and toptotal().

vector< string > Lamoule::getInfosPlayer ( string  nick,
int  min_attempts 
)

Get informations about a player.

Get informations about a player

  • total
  • nb lamoule
  • average
  • reset time
  • rank
    Parameters:
    nick Player's nick
    min_attempts Minimal attempts number to have a rank
    Returns:
    A vector containing informations

Definition at line 292 of file lamoule.cpp.

References AVERAGE, Tools::doubleToStr(), Tools::intToStr(), root, sort(), Tools::strToDouble(), and Tools::to_lower().

Referenced by player().

vector< string > Lamoule::getTopShot (  ) 

Get the lamoule's topshot.

Get the lamoule's topshot

Returns:
A vector containing the topshot informations (nick,score,date) (Check the vector size before using it ! (empty if a problem append))

Definition at line 89 of file lamoule.cpp.

References doc.

Referenced by increaseScore(), and topshot().

char Lamoule::increaseScore ( string  nick,
int  score,
unsigned int  diffAttempts,
bool  checkTop 
)

Increase score for a player.

Increase score for a player

Parameters:
nick Player's nick
score Player's score
diffAttempts Time between two attempts
checkTop Tell if topshot must be checked
Returns:
'null char' if the player plays too fast, 't' if tophsot, else 'o'

Definition at line 172 of file lamoule.cpp.

References addPlayer(), doc, getTopShot(), Tools::intToStr(), root, setTopShot(), Tools::strToDouble(), Tools::strToInt(), and Tools::to_lower().

Referenced by increase(), and lamoule().

void Lamoule::initFile (  )  [private]

Initialize the XML file.

Initilaize the XML file by creating root and first childs

Definition at line 68 of file lamoule.cpp.

References doc, and root.

Referenced by Lamoule().

void Lamoule::purifyFile ( int  reset_time  ) 

Purify File.

Purify the XML file by deleting player who didn't play since a while

Parameters:
reset_time Time (in seconds) after witch one a player is deleted

Definition at line 346 of file lamoule.cpp.

References doc, root, and Tools::strToInt().

Referenced by purifyFile().

bool Lamoule::setNextScore ( int  score  ) 

Set next score.

Set next score

Parameters:
score Next score

Definition at line 362 of file lamoule.cpp.

References MAX_SCORE, and nextScore.

Referenced by nextscore().

void Lamoule::setTopShot ( string  nick,
string  score,
string  date 
)

Set the lamoule's topshot.

Set the lamoule's topshot

Parameters:
nick Topshoter's nick
score Topshot's score
date Topshot's date

Definition at line 108 of file lamoule.cpp.

References doc.

Referenced by increaseScore().

vector< TiXmlElement * > Lamoule::sort ( sort_criterion  criterion,
int  min_attempts 
)

Sort elements to get stats.

Sort a vector elements depending on scores or average

Parameters:
criterion Sort criterion
min_attempts Minimum attempts to be sorted
Postcondition:
The vector is sorted
Returns:
A vecotr containing nodes sorted

Definition at line 213 of file lamoule.cpp.

References AVERAGE, root, Tools::strToDouble(), Tools::strToInt(), and TOTAL.

Referenced by get5first(), and getInfosPlayer().


Member Data Documentation

TiXmlDocument* Lamoule::doc [private]

Represent the xml document.

Definition at line 61 of file lamoule.h.

Referenced by addPlayer(), deletePlayer(), getTopShot(), increaseScore(), initFile(), Lamoule(), purifyFile(), and setTopShot().

int Lamoule::FIRST_FLOOR [private]

First floor.

Definition at line 71 of file lamoule.h.

Referenced by generateScore(), and Lamoule().

int Lamoule::MAX_SCORE [private]

Maximul score.

Definition at line 69 of file lamoule.h.

Referenced by generateScore(), Lamoule(), and setNextScore().

unsigned int Lamoule::nextScore [private]

Stores the next score.

Definition at line 67 of file lamoule.h.

Referenced by generateScore(), Lamoule(), and setNextScore().

TiXmlNode* Lamoule::root [private]

Represent documents's root.

Definition at line 63 of file lamoule.h.

Referenced by addPlayer(), deletePlayer(), getInfosPlayer(), increaseScore(), initFile(), Lamoule(), purifyFile(), and sort().

int Lamoule::SECOND_FLOOR [private]

Second floor.

Definition at line 73 of file lamoule.h.

Referenced by generateScore(), and Lamoule().


The documentation for this class was generated from the following files:

Generated on Sun Aug 16 15:28:46 2009 for trustyRC by  doxygen 1.5.8