Combu Server  3.1.1
PHP API Documentation
Public Member Functions | Static Public Member Functions | Data Fields
LeaderBoard Class Reference
Inheritance diagram for LeaderBoard:
DataClass

Public Member Functions

 __construct ($src=null, $stripSlashes=false)
 
 ExistsCode ()
 
 Save ()
 
 Delete ()
 
 LoadHighscore ($timeInterval, $userScope, $groupPlayer=FALSE, $sumPlayer=FALSE, $limit=NULL, $offset=NULL, &$count=NULL)
 
 GetOrderBy (&$order, &$field)
 
 LoadHighscoreForAccount ($timeInterval, $groupPlayer, $sumPlayer, $idAccount)
 
 PostScore ($account, $scoreValue)
 
- Public Member Functions inherited from DataClass
 Save ()
 
 Delete ()
 
 ToJson ()
 
 ToArray ()
 

Static Public Member Functions

static GetScoreTypes ()
 
static Load ($idApp=0, $limit=null, $offset=null, &$count=null, $returnArray=false)
 
static Prune ()
 
- Static Public Member Functions inherited from DataClass
static GetTableName ($class)
 
static LoadRecords ($query, $returnedClass="")
 
static CountRecords ($tableName, $filter=null)
 
static TruncateTable ($tableName)
 
static TruncateClass ($class)
 

Data Fields

const TABLE_NAME = "LeaderBoard"
 
const VALUE_INT = 0
 
const VALUE_FLOAT = 1
 
const ORDER_DESC = 0
 
const ORDER_ASC = 1
 
const SCORE_UNIQUE_NONE = 0
 
const SCORE_UNIQUE_INCREASE = 1
 
const SCORE_UNIQUE_REPLACE_HIGHER = 2
 
const SCORE_UNIQUE_REPLACE_ANY = 3
 
const HIGHSCORE_TOTAL = 0
 
const HIGHSCORE_MONTH = 1
 
const HIGHSCORE_WEEK = 2
 
const HIGHSCORE_TODAY = 3
 
const USERSCOPE_GLOBAL = 0
 
const USERSCOPE_FRIENDS = 1
 
 $Id = 0
 
 $IdApp = 0
 
 $Code = ""
 
 $Title = ""
 
 $Description = ""
 
 $UniqueRecords = self::SCORE_UNIQUE_INCREASE
 
 $ValueType = self::VALUE_INT
 
 $OrderType = self::ORDER_DESC
 
 $AllowAnonymous = 0
 

Additional Inherited Members

- Protected Member Functions inherited from DataClass
 _loadFilter ($tableName, $filter)
 
 _loadByRow ($row, $stripSlashes=false, $callbackOnExists=false)
 
 _Delete ($tableName, $filter=null)
 
- Static Protected Member Functions inherited from DataClass
static _count ($tableName, $filter=null)
 
static _load ($tableName, $returnedClass="", $where="", $order=null, $limit=null, $offset=null, &$count=null)
 
static _loadEx ($select, $from, $returnedClass="", $where="", $order=null, $limit=null, $offset=null, &$count=null, $debug=false)
 
static _loadQuery ($query, $returnedClass="")
 

Detailed Description

Class to handle Leaderboards

Author
Skared Creations

Definition at line 10 of file LeaderBoard.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $src = null,
  $stripSlashes = false 
)

Contructor

Definition at line 82 of file LeaderBoard.php.

Member Function Documentation

◆ Delete()

Delete ( )

Delete the record from the database

Returns
bool Returns TRUE on success

Definition at line 197 of file LeaderBoard.php.

◆ ExistsCode()

ExistsCode ( )

Check if the current Code already exists

Returns
boolean Returns TRUE if Code exists

Definition at line 106 of file LeaderBoard.php.

◆ GetOrderBy()

GetOrderBy ( $order,
$field 
)

Definition at line 307 of file LeaderBoard.php.

◆ GetScoreTypes()

static GetScoreTypes ( )
static

Get all the available score types of Leaderboards

Returns
array[int]string

Definition at line 127 of file LeaderBoard.php.

◆ Load()

static Load (   $idApp = 0,
  $limit = null,
  $offset = null,
$count = null,
  $returnArray = false 
)
static

Get the registered leaderboards

Parameters
string$idAppFilter IdApp
int$limitMax number of results (for paged results)
int$offsetOffset number of results (for paged results)
int$countWill be set to the total count of results
boolean$returnArrayIf TRUE then it will return associative arrays else objects
Returns
LeaderBoard[] Returns the array of records

Definition at line 146 of file LeaderBoard.php.

◆ LoadHighscore()

LoadHighscore (   $timeInterval,
  $userScope,
  $groupPlayer = FALSE,
  $sumPlayer = FALSE,
  $limit = NULL,
  $offset = NULL,
$count = NULL 
)

Load high scores list with rank, value and user data Account $LoggedAccount

Parameters
int$timeIntervalSpecify the interval type, can be: self::HIGHSCORE_TOTAL, self::HIGHSCORE_WEEK, self::HIGHSCORE_TODAY
int[]$userScope Specify the interval type, can be: self::HIGHSCORE_TOTAL, self::HIGHSCORE_WEEK, self::HIGHSCORE_TODAY
boolean$groupPlayerReturns only the highest scores per players (only for non UniqueRecords leaderboards)
boolean$sumPlayerReturns the sum of scores per players (only for non UniqueRecords leaderboards)
int$limitNumber of records to fetch
int$offsetOffset limit to fetch
int$countIt will contain the total number of records, counted without LIMIT clause
Returns
array[int]array[string]string Highscore records list

Definition at line 228 of file LeaderBoard.php.

◆ LoadHighscoreForAccount()

LoadHighscoreForAccount (   $timeInterval,
  $groupPlayer,
  $sumPlayer,
  $idAccount 
)

Definition at line 326 of file LeaderBoard.php.

◆ PostScore()

PostScore (   $account,
  $scoreValue 
)

Post a score in the leaderboard from a user

Parameters
Account$accountAccount who scored
mixed$scoreValueValue to save (can actually be int or float)
Returns
boolean Returns TRUE on success, otherwise FALSE

Definition at line 400 of file LeaderBoard.php.

◆ Prune()

static Prune ( )
static

Delete all records associated to this class

Definition at line 211 of file LeaderBoard.php.

◆ Save()

Save ( )

Save the record in the database

Returns
bool Returns TRUE on success

Definition at line 159 of file LeaderBoard.php.

Field Documentation

◆ $AllowAnonymous

$AllowAnonymous = 0

Definition at line 77 of file LeaderBoard.php.

◆ $Code

$Code = ""

Definition at line 71 of file LeaderBoard.php.

◆ $Description

$Description = ""

Definition at line 73 of file LeaderBoard.php.

◆ $Id

$Id = 0

Definition at line 69 of file LeaderBoard.php.

◆ $IdApp

$IdApp = 0

Definition at line 70 of file LeaderBoard.php.

◆ $OrderType

$OrderType = self::ORDER_DESC

Definition at line 76 of file LeaderBoard.php.

◆ $Title

$Title = ""

Definition at line 72 of file LeaderBoard.php.

◆ $UniqueRecords

$UniqueRecords = self::SCORE_UNIQUE_INCREASE

Definition at line 74 of file LeaderBoard.php.

◆ $ValueType

$ValueType = self::VALUE_INT

Definition at line 75 of file LeaderBoard.php.

◆ HIGHSCORE_MONTH

const HIGHSCORE_MONTH = 1

Retrieves the highscore of current month

Definition at line 56 of file LeaderBoard.php.

◆ HIGHSCORE_TODAY

const HIGHSCORE_TODAY = 3

Retrieves the highscore of today

Definition at line 64 of file LeaderBoard.php.

◆ HIGHSCORE_TOTAL

const HIGHSCORE_TOTAL = 0

Retrieves the highscore of all time

Definition at line 52 of file LeaderBoard.php.

◆ HIGHSCORE_WEEK

const HIGHSCORE_WEEK = 2

Retrieves the highscore of last 7 days

Definition at line 60 of file LeaderBoard.php.

◆ ORDER_ASC

const ORDER_ASC = 1

Scores are sorted by ascendant order

Definition at line 30 of file LeaderBoard.php.

◆ ORDER_DESC

const ORDER_DESC = 0

Scores are sorted by descendant order

Definition at line 26 of file LeaderBoard.php.

◆ SCORE_UNIQUE_INCREASE

const SCORE_UNIQUE_INCREASE = 1

The score of a player is a unique record and is increased by every value received

Definition at line 39 of file LeaderBoard.php.

◆ SCORE_UNIQUE_NONE

const SCORE_UNIQUE_NONE = 0

Each score of a player is stored as separate records

Definition at line 35 of file LeaderBoard.php.

◆ SCORE_UNIQUE_REPLACE_ANY

const SCORE_UNIQUE_REPLACE_ANY = 3

The score of a player is a unique record and is replaced with the latest value received

Definition at line 47 of file LeaderBoard.php.

◆ SCORE_UNIQUE_REPLACE_HIGHER

const SCORE_UNIQUE_REPLACE_HIGHER = 2

The score of a player is a unique record and is replaced with the highest value received

Definition at line 43 of file LeaderBoard.php.

◆ TABLE_NAME

const TABLE_NAME = "LeaderBoard"

Definition at line 12 of file LeaderBoard.php.

◆ USERSCOPE_FRIENDS

const USERSCOPE_FRIENDS = 1

Definition at line 67 of file LeaderBoard.php.

◆ USERSCOPE_GLOBAL

const USERSCOPE_GLOBAL = 0

Definition at line 66 of file LeaderBoard.php.

◆ VALUE_FLOAT

const VALUE_FLOAT = 1

Score is a float

Definition at line 21 of file LeaderBoard.php.

◆ VALUE_INT

const VALUE_INT = 0

Score is an integer

Definition at line 17 of file LeaderBoard.php.