seanohue / paperdoll

a library for handling equipment/inventory management systems in games such as Ranvier (see also https://en.wikipedia.org/wiki/Paper_doll_(gaming))
2 stars 0 forks source link

Ideation: APIs to set equipment slots on characters #3

Open seanohue opened 5 years ago

seanohue commented 5 years ago

This could be done in a couple of ways, and in fact all of these APIs may be needed:

  1. Have an API to set the default slots and configure them. For instance:
    
    paperdoll.register(config); // This could be a config of all possible parts/slots!

// or

paperdoll.setDefaultParts(config); // These are the default slots. Could be an object mapping slotnames to configs, or an array of slot names if they are registered.

// later paperdoll.init(player);


(API name subject to change)
Where config is an object mapping slot names to their configuration.
Behind the scenes, this API would set up a standard set of properties on the characters metadata, recognized by paperdoll, something like:

```javascript
metadata: { slots: head: { /* etc */ }, torso: { /* etc */ }
  1. Have an API to programmatically change the slots for a character. This could mean adding or removing a slot based on name, or replacing the slots completely:
// in an input event during character creation, or an NPC's spawn event handler...
paperdoll.remove(character, 'head'); // deletes character's head slot
paperdoll.add(character, 'proboscis'); // add a proboscis instead, assuming that proboscis was registered...
paperdoll.add(character, tentaclesConfig); // add tentacles based on a config object similar to above

// or

PaperDoll.replace(character, config); // This replaces the default slots with entirely new ones, config can be an object or an array of registered slot names.
  1. Have a paperdoll behavior that handles all of this in .yaml
    # npcs.yml
    - id: tentacle-monster
    # ...
    behaviors:
    paperdoll:
      parts: ['tentacles', 'proboscis', 'torso'] # could also be a config object