PlayerClass

This is an example implementation of a base player class. This, along with CommandParser is one of the few core classes Ranvier encourages you to modify if you want more functionality. Almost all other features can be overridden in bundles.

Constructor

new PlayerClass(id, config)

Parameters:
Name Type Description
id string

id corresponding to classes/.js file

config object

Definition, this object is completely arbitrary. In this example implementation it has a name, description, and ability table. You are free to change this class as you wish

Members

abilityTable :Object.<number, Array.<string>>

Table of level: abilities learned. Example: { 1: { skills: ['kick'] }, 2: { skills: ['bash'], spells: ['fireball']}, 5: { skills: ['rend', 'secondwind'] }, }

Methods

canUseAbility(player, abilityId) → {boolean}

Check if a player can use a given ability

Parameters:
Name Type Description
player Player
abilityId string
Returns:
boolean

getAbilitiesForPlayer(player) → {Array.<string>}

Get a flattened list of all the abilities available to a given player

Parameters:
Name Type Description
player Player
Returns:
Array.<string> -

Array of ability ids

hasAbility(id) → {boolean}

Check to see if this class has a given ability

Parameters:
Name Type Description
id string
Returns:
boolean

setupPlayer(player)

Override this method in your class to do initial setup of the player. This includes things like adding the resource attribute to the player or anything else that should be done when the player is initially given this class

Parameters:
Name Type Description
player Player