Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: SubstanceMixer

Extends: adventurejs.Atom

Defined in: adventure/SubstanceMixer.js, line 6

Todos: Solid+liquid->slurry.

Framework class

Public Constructor:

var mixer = new adventurejs.SubstanceMixer( this.game.game_name )

SubstanceMixer is a special internal class that is instantiated whenever Substances are mixed together from two (or in theory, more) sources. For instance, if player pours a glass full of liquid into a bowl that also contains liquid, we make a new SubstanceMixer to handle the interaction. This is true even if both Vessels contain the same Substance. SubstanceMixer handles:

  • temperature conversion, if SubstancesContainers are at different temperatures
  • volume operations - comparing available volume in source and destination, removing part or all from source as needed
  • mixwith handling, if two Substances are set to mix with each other to form a third Substance
  • overflow of the target container if needed

Example:


Private Constructor:

var foo = new adventurejs.SubstanceMixer(game_name)

Parameters:

  • game_name String
    Name of top level game instance that is scoped to window.
Inherited Overrides
IndexMethodsProperties

Methods Collapse all  |  Expand all

getInheritance() → {Array}

Defined in: adventure/Atom.js, line 238

Inherited from: adventurejs.Atom#getInheritance

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

Returns:

Array
getProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 184

Inherited from: adventurejs.Atom#getProperty

Parameters:

  • prop String
    Name of the property to test for. Can include dot notation.
A method to get a deep property without throwing an error. Allows for getting deep properties, ie "foo.bar.baz". Returns false if property doesn't exist, so beware of if(false === foo.bar.baz) comparisons.

Returns:

Boolean
hasClass(prop) → {Boolean}

Defined in: adventure/Atom.js, line 216

Inherited from: adventurejs.Atom#hasClass

Parameters:

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

Returns:

Boolean
hasProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 148

Inherited from: adventurejs.Atom#hasProperty

Parameters:

  • prop String
    Name of the property to test for. Can include dot notation.
A method to test whether the Atom has a given property. Allows for testing deep properties, ie "foo.bar.baz". For stupid and unaccountable reasons Ivan has decided to code adventurejs entirely in Javascript ES5, so we don't have the nicety of optional chaining introduced in ES6. This method fills in for optional chaining until we someday upgrade to ES6.

Returns:

Boolean
mix() → {boolean}

Defined in: adventure/SubstanceMixer.js, line 292

Mix two substances. This function acts upon the source / target objects, and saves its results to the SubstanceMixer object for reference by the caller.

Returns:

boolean
set(props) → {Object}

Defined in: adventure/Atom.js, line 134

Inherited 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.)

Properties Collapse all  |  Expand all

can_drain_target :Boolean

Defined in: adventure/SubstanceMixer.js, line 231

Default value: false

can_drain_target is used to indicate that the target vessel can be drained.
can_overflow_target :Boolean

Defined in: adventure/SubstanceMixer.js, line 248

Default value: false

can_overflow_target overrides did_overflow_target if it's true. It's used by fill verb, the idea being that, while an automated emitter might overflow a target, a person consciously filling a vessel would not.
class :String

Defined in: adventure/Atom.js, line 74

Inherited from: adventurejs.Atom#class

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.
did_displace_substance :Boolean

Defined in: adventure/SubstanceMixer.js, line 222

Default value: false

did_displace_substance is used if no mixwiths are provided. Source substance will simply displace target substance.
did_fill_target :Boolean

Defined in: adventure/SubstanceMixer.js, line 207

Default value: false

did_fill_target is used to indicate that the target vessel was filled by the source substance.
did_mix_substances :Boolean

Defined in: adventure/SubstanceMixer.js, line 215

Default value: false

did_mix_substances
did_overflow_target :Boolean

Defined in: adventure/SubstanceMixer.js, line 239

Default value: false

did_overflow_target may be set to true if the source is an emitter that emits a greater volume than the target can hold.
game :Getter

Defined in: adventure/Atom.js, line 123

Inherited from: adventurejs.Atom#game

Getter function that returns the top level game object. Use this.game.
game_name :Getter/Setter

Defined in: adventure/Atom.js, line 100

Inherited from: adventurejs.Atom#game_name

game_name holds a copy of the variable name used to store the current game instance, to which every asset in the game world holds a reference. (By default, we use "MyGame", but you can use any name.) The variable is scoped to window, and in order to get the game object, we call window[this.game_name]. Though it would be easier to use a direct object reference, doing so creates a circular reference, which complicates JSON encoding, which is how we save/restore the game state.
id :String

Defined in: adventure/Atom.js, line 86

Inherited from: adventurejs.Atom#id

A unique ID for the game asset, based on the object name provided in the asset definition.
name :String

Defined in: adventure/Atom.js, line 54

Inherited from: adventurejs.Atom#name

String provided by author in game file. The name gets serialized - which here means removing periods and spaces and converting to lowercase - and saved as a unique id for the asset.
output_substance_asset :Object|null

Defined in: adventure/SubstanceMixer.js, line 183

Default value: null

output_substance_asset is the asset of the substance that results from mixing (which may just be the source substance).
output_substance_id :String

Defined in: adventure/SubstanceMixer.js, line 191

Default value: ""

output_substance_id is the id of the substance asset that is that results from mixing, ie 'sand' or 'water'.
source_aspect :String

Defined in: adventure/SubstanceMixer.js, line 65

Default value: ""

source_aspect is the asset aspect that contains the source substance.
source_asset :Object|null

Defined in: adventure/SubstanceMixer.js, line 58

Default value: null

source_asset is an asset with a vessel that contains the source substance.
source_input :String

Defined in: adventure/SubstanceMixer.js, line 49

Default value: ""

source_input might be an asset id or a tri-part asset:aspect:substance id string. We're prepared to handle either to get an asset, or receive an asset object directly.
source_split :Array|String|null

Defined in: adventure/SubstanceMixer.js, line 94

Default value: null

source_split is used to store the provided source_input if it is a tri-part string.
source_substance_asset :Object|null

Defined in: adventure/SubstanceMixer.js, line 80

Default value: null

source_substance_asset is the asset of the substance that is contained.
source_substance_id :String

Defined in: adventure/SubstanceMixer.js, line 87

Default value: ""

source_substance_id is the id of the substance asset that is contained, ie 'sand' or 'water'.
source_vessel :Object|null

Defined in: adventure/SubstanceMixer.js, line 73

Default value: null

source_vessel is a reference to the Vessel object in the source asset.
source_volume :int

Defined in: adventure/SubstanceMixer.js, line 101

Default value: 0

source_volume is the volume of the substance in the source vessel.
source_volume_used :int

Defined in: adventure/SubstanceMixer.js, line 108

Default value: 0

source_volume_used stores the volume of the source substance that has been used.
target_already_full :Boolean

Defined in: adventure/SubstanceMixer.js, line 199

Default value: false

target_already_full is used to indicate that the target vessel is already full.
target_aspect :String

Defined in: adventure/SubstanceMixer.js, line 131

Default value: ""

target_aspect is the asset aspect which will receive the source substance.
target_asset :Object|null

Defined in: adventure/SubstanceMixer.js, line 124

Default value: null

target_asset is an asset with a vessel that receives the source substance.
target_freevolume :float

Defined in: adventure/SubstanceMixer.js, line 176

Default value: 0.0

target_freevolume is the free volume of the substance in the target vessel.
target_input :String

Defined in: adventure/SubstanceMixer.js, line 115

Default value: ""

target_input might be an asset id or a tri-part asset:aspect:substance id string. We're prepared to handle either to get an asset, or receive an asset object directly.
target_split :Array|String|null

Defined in: adventure/SubstanceMixer.js, line 162

Default value: null

target_split is used to store the provided target_input if it is a tri-part string.
target_substance_asset :Object|null

Defined in: adventure/SubstanceMixer.js, line 146

Default value: null

target_substance_asset is the asset of the substance that is contained by the target asset.
target_substance_id :String

Defined in: adventure/SubstanceMixer.js, line 154

Default value: ""

target_substance_id is the id of the substance asset that is contained in the target asset, ie 'sand' or 'water'.
target_vessel :Object|null

Defined in: adventure/SubstanceMixer.js, line 139

Default value: null

target_vessel is a reference to the Vessel object in the target asset.
target_volume :float

Defined in: adventure/SubstanceMixer.js, line 169

Default value: 0.0

target_volume is the volume of the substance in the target vessel.
UID :String

Defined in: adventure/Atom.js, line 93

Inherited from: adventurejs.Atom#UID

A unique numerical ID for the game asset. Currently unused but included as a potential alternative to id.
Documentation generated by JSDoc 3.6.11 on Mon Nov 20 2023 18:02:48 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to docs@adventurejs.com.