Class: Inventory
Defined in: | src/inventory.coffee |
Overview
The Inventory abstracts away communication with HAPI, providing a convenient API to access goods and assets belonging to a User.
Instance Method Summary
- - (void) constructor(categories, assets) Constructor Create a new Inventory.
- - (void) setAssets(assets) Set the assets to be used by the inventory.
- - (void) representation(_representation) Set the default representation to be used.
- - (void) good(_good) Set the default good to be used.
- - (void) category(_category) Set the default category to be used.
- - (Object/Array) get(options = {}) Get data from the inventory.
- - (Object) getAsset(assetLabel, representation = @_representation) Get an asset by label and representation.
- - (Object) assetById(assetId, representation = null) Find an asset by its Id.
- - (Object) assetByLabel(assetLabel, representation = null) Find an asset by its Label.
- - (Object) randomEnsemble(options) Get a random ensemble.
- - (Object) avatarEnsemble(assets, representation) Get an ensemble based on a list of assets.
Constructor Details
- (void) constructor(categories, assets)
Create a new Inventory.
Instance Method Details
- (void) setAssets(assets)
Set the assets to be used by the inventory.
- (void) representation(_representation)
Set the default representation to be used. Setting a default representation allows you to call other methods that may require a representation without supplying one.
- (void) good(_good)
Set the default good to be used. Setting a default good allows you to call other methods that may require a good without supplying one.
- (void) category(_category)
Set the default category to be used. Setting a default category allows you to call other methods that may require a category without supplying one.
- (Object/Array) get(options = {})
Get data from the inventory.
The data must be scoped by representation; other scopings are optional.
If only a representation is supplied, the returned data is in the form
category: [assets]
. If a category is given, an array of assets belonging
to the given category is returned. If a good is given, assets are restricted
to the given good.
- (Object) getAsset(assetLabel, representation = @_representation)
Get an asset by label and representation.
- (Object) assetById(assetId, representation = null)
Find an asset by its Id.
- (Object) assetByLabel(assetLabel, representation = null)
Find an asset by its Label.
- (Object) randomEnsemble(options)
Get a random ensemble. This can be used to build an Avatar.
- (Object) avatarEnsemble(assets, representation)
Get an ensemble based on a list of assets.
This can be used to build an Avatar.
The list of assets will typically have been obtained by
a call to HAPI, and each element will be of the form
AssetId:, Colour1:, Colour2:
.