Constructor
new NewgroundsMedal(id, name, descriptionopt, iconopt, srcopt)
Create a NewgroundsMedal and add it to the list of medals
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id | number | The unique identifier of the medal | |
name | string | Name of the medal | |
description | string | <optional> | Description of the medal |
icon | string | <optional> | Icon for the medal |
src | string | <optional> | Image location for the medal |
- Source
Extends
- Medal
Members
difficulty :number|undefined
Type:
Properties- number |
undefined
| Type | Description |
|---|---|
| number | | Difficulty from the server once ready, 1 easy to 5 brutal |
- Source
value :number|undefined
Type:
Properties- number |
undefined
| Type | Description |
|---|---|
| number | | Point value from the server once ready |
- Source
Methods
isLocal() → {boolean}
Whether the local save holds this medal, false while logged in when Newgrounds holds it
- Source
Returns:
- Type:
- boolean
unlock() → {Promise.<boolean>}
Unlocks a medal if not already unlocked, once Newgrounds confirms it when logged in
- The promise is optional, for when a game wants to know the outcome
- A request that did not reach the server is sent again after the session check every minute, and calling unlock again while the medal is pending returns the same promise
- One the server refused is not sent again this visit, calling unlock again resolves false without a request
- An answer that the session is gone makes the game play as not logged in, and the pending medals, this one too, unlock locally unless unlocks are prevented; a refused one only unlocks if it is earned again
- Source
Returns:
- Whether the medal is unlocked, once the server has answered when logged in
- Type:
- Promise.<boolean>