Player

new Player()

Properties:
Name Type Description
account Account
experience number

current experience this level

password string
prompt string

default prompt string

socket net.Socket
questTracker QuestTracker
extraPrompts Map.<string, function()>

Extra prompts to render after the default prompt

questData Object

Extends

Members

isNpc

Inherited From:

Methods

addAttribute()

Inherited From:
See:

addCombatant(target)

Parameters:
Name Type Description
target Character
Inherited From:

addEffect(effect) → {boolean}

Parameters:
Name Type Description
effect Effect
Returns:
boolean
Inherited From:

addFollower(follower)

Parameters:
Name Type Description
follower Character
Inherited From:

addItem(item)

Move an item to the character's inventory

Parameters:
Name Type Description
item Item
Inherited From:

addPrompt(id, renderer, removeOnRendernullable)

Add a line of text to be displayed immediately after the prompt when the prompt is displayed

Parameters:
Name Type Attributes Default Description
id string

Unique prompt id

renderer function

Function to call to render the prompt string

removeOnRender boolean <nullable>
false

When true prompt will remove itself once rendered otherwise prompt will continue to be rendered until removed.

canGo(direction) → {boolean}

Determine if a player can leave the current room to a given direction TODO: This shouldn't be here but there's not better place at the moment

Parameters:
Name Type Description
direction string
Returns:
boolean

emit(event, …args)

Proxy all events on the player to the quest tracker

Parameters:
Name Type Attributes Description
event string
args * <repeatable>
Overrides:

evaluateIncomingDamage(damage) → {number}

Parameters:
Name Type Description
damage Damage
Returns:
number
Inherited From:
See:
  • EffectList.evaluateIncomingDamage

evaluateOutgoingDamage(damage, currentAmount) → {number}

Parameters:
Name Type Description
damage Damage
currentAmount number
Returns:
number
Inherited From:
See:
  • EffectList.evaluateOutgoingDamage

follow(target)

Begin following another character. If the character follows itself they stop following.

Parameters:
Name Type Description
target Character
Inherited From:

getAttribute(attr) → {number}

Get the current value of an attribute (base modified by delta)

Parameters:
Name Type Description
attr string
Returns:
number
Inherited From:

getBaseAttribute(attr) → {number}

Get the base value for a given attribute

Parameters:
Name Type Description
attr string

Attribute name

Returns:
number
Inherited From:

getBroadcastTargets() → {Array.<Character>}

Used by Broadcaster

Returns:
Array.<Character>
Overrides:

getMaxAttribute(attr) → {number}

Get current maximum value of attribute (as modified by effects.)

Parameters:
Name Type Description
attr string
Returns:
number
Inherited From:

getMeta(key) → {*}

Get metadata about a player

Parameters:
Name Type Description
key string

Key to fetch. Supports dot notation e.g., "foo.bar"

Returns:
*

hasAttribute(attr) → {boolean}

Parameters:
Name Type Description
attr string

Attribute name

Returns:
boolean
Inherited From:

hasEffectType(type) → {boolean}

Parameters:
Name Type Description
type string
Returns:
boolean
Inherited From:
See:

hasFollower(target) → {boolean}

Parameters:
Name Type Description
target Character
Returns:
boolean
Inherited From:

hasPrompt(id) → {boolean}

Parameters:
Name Type Description
id string
Returns:
boolean

hydrate(state)

Initialize the character from storage

Parameters:
Name Type Description
state GameState
Overrides:

initiateCombat(target, lagnullable)

Start combat with a given target.

Parameters:
Name Type Attributes Default Description
target Character
lag number <nullable>
0

Optional milliseconds of lag to apply before the first attack

Inherited From:

interpolatePrompt(promptStr, extraData)

Convert prompt tokens into actual data

Parameters:
Name Type Description
promptStr string
extraData object

Any extra data to give the prompt access to

isFollowing(target) → {boolean}

Parameters:
Name Type Description
target Character
Returns:
boolean
Inherited From:

isInCombat(targetnullable)

Check to see if this character is currently in combat or if they are currently in combat with a specific character

Parameters:
Name Type Attributes Description
target Character <nullable>
Returns:
-

boolean

Inherited From:

isInventoryFull() → {boolean}

Returns:
boolean
Inherited From:

lowerAttribute(attr, amount)

Lower an attribute by name

Parameters:
Name Type Description
attr string
amount number
Inherited From:
See:
  • Attributes#lower

moveTo(nextRoom, onMoved)

Move the player to the given room, emitting events appropriately

Parameters:
Name Type Description
nextRoom Room
onMoved function

Function to run after the player is moved to the next room but before enter events are fired

queueCommand()

See:
  • CommandQueue::enqueue

raiseAttribute(attr, amount)

Raise an attribute by name

Parameters:
Name Type Description
attr string
amount number
Inherited From:
See:
  • Attributes#raise

removeCombatant(target)

Parameters:
Name Type Description
target Character
Inherited From:

removeEffect(effect)

Parameters:
Name Type Description
effect Effect
Inherited From:
See:

removeFollower(target)

Parameters:
Name Type Description
target Character
Inherited From:

removeFromCombat()

Fully remove this character from combat

Inherited From:

removeItem(item)

Remove an item from the character's inventory. Warning: This does not automatically place the item in any particular place. You will need to manually add it to the room or another character's inventory

Parameters:
Name Type Description
item Item
Inherited From:

removePrompt(id)

Parameters:
Name Type Description
id string

serialize() → {Object}

Gather data to be persisted

Returns:
Object
Overrides:

setAttributeBase(attr, newBase)

Update an attribute's base value.

NOTE: You probably don't want to use this the way you think you do. You should not use this for any temporary modifications to an attribute, instead you should use an Effect modifier.

This will permanently update the base value for an attribute to be used for things like a player purchasing a permanent upgrade or increasing a stat on level up

Parameters:
Name Type Description
attr string

Attribute name

newBase number

New base value

Inherited From:

setAttributeToMax(attr)

Clears any changes to the attribute, setting it to its base value.

Parameters:
Name Type Description
attr string
Inherited From:

setMeta(key, value)

Set a metadata value. Does not autovivify, you will need to create the parent objects if they don't exist

Parameters:
Name Type Description
key string

Key to set. Supports dot notation e.g., "foo.bar"

value *

Value must be JSON.stringify-able

unequip(slot)

Remove equipment in a given slot and move it to the character's inventory

Parameters:
Name Type Description
slot string
Inherited From:

unfollow()

Stop following whoever the character was following

Inherited From:

Events

damaged

Parameters:
Name Type Description
damage Damage
Inherited From:

heal

Parameters:
Name Type Description
heal Heal
target Character
Inherited From:

healed

Parameters:
Name Type Description
heal Heal
Inherited From:

hit

Parameters:
Name Type Description
damage Damage
target Character
Inherited From:

save

Parameters:
Name Type Description
playerCallback function

updateTick