Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0

Extends: adventurejs.Atom

Defined in: adventure/Platonic.js, line 4

Constructor:

MyGame.createAsset({ "class":"Platonic", "name":"foo" })

Description

Platonic is subclassed from the foundational class Atom, and is used to make platonic assets, which are stand-ins for one-from-many assets, such as one grape from a bunch of grapes or one nut from a sack of nuts. Platonic assets are never instantiated by authors - they're created automatically any time an asset is set to dispense.

Example:

MyGame.createAsset({
  class: "Pouch",
  name: "small pouch",
  place: { in: "Nomad" },
  synonyms: ["leather", "lace", "strip", "pistachio", "pistachios"],
  description: `A tiny pouch – really, hardly more than a scrap of leather – folded on itself and laced with a thin strip. The pouch contains a handful of pistachios. `,
  is: { closed: false },
  aspects: {
    in: {
      dispense: "Pistachio",
    },
  },
});

MyGame.createClass({
  class: "Pistachio",
  extend: "Edible",
  singular: "pistachio",
  plural: "pistachios",
  description: `It's a pistachio. `,
});

Private Constructor:

var foo = new adventurejs.Platonic(game_name, name)

Though all in-game glasses use a standard constructor method under the hood, it's unlikely that you'd need to call it directly. To create an instance of the Platonic class, it must be defined in a game file as a generic object. That object will be used at runtime to construct a new game class instance, which will be validated and initialized before adding it to the Game. See above for the public constructor, or see Game#createAsset to learn more.

Parameters:

  • game_name String
    The name of the top level game object.
  • name String
    A name for the object, to be serialized and used as ID.
Inherited Overrides

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

getClassInheritance
getClassInheritance() → {Array}

Defined in: adventure/Atom.js, line 191

Inherited from: adventurejs.Atom#getClassInheritance

getClassInheritance is a utility method to get an asset's class inheritance chain. Returns a list of class names from high to low.

Returns:

Array
hasClass
hasClass(prop) → {Boolean}

Defined in: adventure/Atom.js, line 171

Inherited from: adventurejs.Atom#hasClass

Parameters:

  • prop String
    Name of the class to test for.
A method to test whether the Atom is an instance of a given class.

Returns:

Boolean
initialize
initialize()
set
set(props) → {Object}

Defined in: adventure/Atom.js, line 159

Overrides from: adventurejs.Atom#set

Parameters:

  • props Object
    A generic object containing properties to copy to the Object instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

Object Returns the instance the method is called on (useful for chaining calls.)
validate
validate()

Properties  | 

game
game :Getter

Defined in: adventure/Atom.js, line 138

Inherited from: adventurejs.Atom#game

Returns the top level game object. Use this.game.
id
id :String

Defined in: adventure/Atom.js, line 114

Inherited from: adventurejs.Atom#id

id returns the id of the class instance.
name
name :String

Defined in: adventure/Atom.js, line 62

Overrides from: adventurejs.Atom#name

Class identifier to be provided in the asset definition. All game objects start as generic objects that get passed to createAsset, which uses an object's class field to specify a class constructor.
Name
Name :String

Defined in: adventure/Atom.js, line 125

Inherited from: adventurejs.Atom#Name

Name returns the name of the class instance with the first character uppercased.