LittleJS 1.28.0

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

Extends Medal

Constructor

new NewgroundsMedal(id, name, description, icon, src)newgrounds.js:45

Create a NewgroundsMedal and add it to the list of medals

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

Members

Methods

Inherited from Medal

Members

difficulty : number|undefinednewgrounds.js:60

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

value : number|undefinednewgrounds.js:64

Point value from the server once ready

Methods

isLocal() → booleannewgrounds.js:69

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

unlock() → Promise<boolean>newgrounds.js:79

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