Newgrounds. NewgroundsMedal

NewgroundsMedal: its id is the medal's id on the Newgrounds API Tools page; when logged in it only unlocks once the server confirms

Constructor

new NewgroundsMedal(id, name, descriptionopt, iconopt, srcopt)

Create a NewgroundsMedal and add it to the list of medals

Parameters:
NameTypeAttributesDescription
idnumber

The unique identifier of the medal

namestring

Name of the medal

descriptionstring<optional>

Description of the medal

iconstring<optional>

Icon for the medal

srcstring<optional>

Image location for the medal

Extends

  • Medal

Members

difficulty :number|undefined

Type:
  • number | undefined
Properties
TypeDescription
number | undefined

Difficulty from the server once ready, 1 easy to 5 brutal

value :number|undefined

Type:
  • number | undefined
Properties
TypeDescription
number | undefined

Point value from the server once ready

Methods

isLocal() → {boolean}

Whether the local save holds this medal, false while logged in when Newgrounds holds it

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
Returns:
  • Whether the medal is unlocked, once the server has answered when logged in
Type: 
Promise.<boolean>