skins/Counter. Counter

This class encapsulates the operation of a numeric counter, used to display the current
values of score, actions and time.

Constructor

new Counter(id, $divopt)

Counter constructor

Parameters:
NameTypeAttributesDescription
idstring

The type of information stored on this counter

$divexternal:jQuery<optional>

The HTML element where this counter will show values (can be null)

Members

$div :external:jQuery

The HTML element where this counter shows its value

MAX_DISPLAY_VALUE :number

Maximum value to be displayed by this counter

Type:
  • number

countDown :number

When set, the counter displays a countdown from this value to zero

Type:
  • number

displayDiffFrom :module:skins/Counter.Counter

An optional Counter used as a subtractor to display the current value.
Useful to display errors subtracting score from actions.

enabled :boolean

Flag indicating if this counter is currently enabled

Type:
  • boolean

id :string

Type of counter (usually: score, actions or time)

Type:
  • string

value :number

Current value of this counter

Type:
  • number

Methods

getDisplayValue() → {number}

Gets the current display value of this counter

Returns:
Type: 
number

incValue()

Increments by one the value of this counter

refreshDisplay()

Paints the value of this counter on screen
(method to be overridden by subclasses)

setCountDown(maxValue)

Sets the initial value of the counter

Parameters:
NameTypeDescription
maxValuenumber

Value from which the countdown will start

setEnabled(enabled)

Enables or disables this counter

Parameters:
NameTypeDescription
enabledboolean

State been assigned to this counter

setValue(value)

Sets a specific value to this counter

Parameters:
NameTypeDescription
valuenumber

The value to set