Class: Highscores

rune.data.Highscores(id, length, tables)

Represents one (or more) (local) highscore tables. A highscore consists of name, score and a timestamp (given in Unix time.) The table is sorted in numerical descending order, based on score. The actual data is saved in localstorage under a (for the application) unique key.

Constructor

new Highscores(id, length, tables)

Creates a new object.
Parameters:
Name Type Description
id string The App ID.
length number The number of positions per highscore table.
tables number The number of highscore tables.
Source:

Members

(readonly) key :string

A string value that uniquely identifies the highscore data in localstorage. Useful when several applications are distributed via the same domain.
Type:
  • string
Source:

Methods

clear() → {undefined}

Removes all highscore data associated with the current application. Note that this action cannot be undone.
Source:
Returns:
Type
undefined

dispose() → {undefined}

Initiates deallocation of this object.
Source:
Returns:
Type
undefined

get(ranking, tableopt) → {Object}

Gets a specific high score based on ranking. Note that first places start with index 0 and not 1.
Parameters:
Name Type Attributes Default Description
ranking number Requested ranking.
table number <optional>
0 Which table the data should be retrieved from.
Source:
Returns:
Type
Object

send(score, nameopt, tableopt) → {number}

Sends data to the highscore list. The data is saved if it qualifies as a highscore.
Parameters:
Name Type Attributes Default Description
score number Score to save.
name string <optional>
Rune Name of score holder.
table number <optional>
0 Which table to use.
Source:
Returns:
Current ranking on the highscore list.
Type
number

test(score, tableopt) → {number}

Tests whether a score can qualify as a high score. The method returns the raking of the score in the form of an integer. The result -1 indicates that the score is outside the scope of the current high score table and thus not a high score. Note that a test does not affect the current high score list, nothing is saved or deleted when a test is performed.
Parameters:
Name Type Attributes Default Description
score number Score to test.
table number <optional>
0 Table to test against.
Source:
Returns:
Current ranking on the highscore list.
Type
number