Class: WornApparel

.Apparel~ WornApparel

This class, derived from Wardrobe, is meant to track worn Apparel. It overrides preAdd() so that only objects of type GenericApparel (or subclasses thereof) may be added to the Inventory. The Wardrobe parent class also overrides sort() so that the contents are sorted in order of ClothingSlot value rather than alphabetically.


new WornApparel(id)

You should never instantiate a PersistentObject directly! Instead, you must define it with PersistentObject.define(), and then instantiate it with the obj() function when you want to use it. You must also never store PersistentObjects in Sugarcube variables! Just store their ids, instantiate them with obj() as needed, and then let them be garbage-collected.

Parameters:
Name Type Description
id string

The id of the Persistence defaults entry to be associated with this instance.

Source:

Extends

  • LibEcho.Inventory.Wardrobe

Methods


preAdd(id)

This method is overridden, to prevent anything that doesn't ultimately inherit from GenericApparel from being added to the Inventory.

Parameters:
Name Type Description
id string

The id of the object to be added to the Inventory.

Source:
Throws:

Error if the class of the Persistence object referenced by id is not an instanceof GenericApparel (or subclass thereof).

Returns:

true if the PersistentObject referenced by 'id' is an instanceof GenericApparel, or false if it is not.

Type
boolean

postAdd(id)

This method is overridden, to remove all Apparel objects that occupy the same ClothingClot as the object that was added.

Parameters:
Name Type Description
id string

The id of the object to be added to the Inventory.

Source:
Throws:

Error if the class of the Persistence object referenced by id is not an instanceof GenericApparel (or subclass thereof).

Returns:

a list of the items that were removed to make room for the new item, or an empty array if nothing was removed.

Type
array

toString(showAll)

Overridden to display concealed items. FIXME

Parameters:
Name Type Description
showAll boolean

If true, all items in the inventory are printed. If false, only visible items are printed. If undefined, acts as true if this WornApparel's parent is the $viewpointCharacter, otherwise acts as false.

Source:
Returns:

a serial-comma-separated-list of the Inventory's contents' .aName fields.

Type
string

theString(showAll)

Overridden to display concealed items. Like toString(), but using .theName instead. FIXME

Parameters:
Name Type Description
showAll boolean

If true, all items in the inventory are printed. If false, only visible items are printed. If undefined, acts as true if this WornApparel's parent is the $viewpointCharacter, otherwise acts as false.

Source:
Returns:

a serial-comma-separated-list of the Inventory's contents' .theName fields.

Type
string