Class: Pet

Pets~ Pet


new Pet(owner, name, species [, petClass])

Contains information about a single user's pet.
Parameters:
Name Type Argument Default Description
owner string ID of the user that owns this pet.
name string The name of this pet.
species string The species of this pet.
petClass string <optional>
<nullable>
null The class name of this pet or null for none.
Source:

Members


<private> _lastInteractTime :number

The timestamp at which this object was last interacted with. This is used for purging from memory when not used for a while.
Type:
  • number
Default Value:
  • Date.now()
Source:

attackMod :number

Attack modifier on top of base species stat.
Type:
  • number
Source:

defenseMod :number

Defense modifier on top of base species stat.
Type:
  • number
Source:

healthMod :number

Health modifier on top of base species stat.
Type:
  • number
Source:

id :string

The ID of this pet. Does not check for uniqueness, but expects the ID to be unique per-user.
Type:
  • string
Source:

lives :number

Current number of lives remaining.
Type:
  • number
Default Value:
  • 3
Source:

name :string

The name of this pet.
Type:
  • string
Source:

numPoints

Get the number of remaining points available to spend on modifiers.
Source:

owner :string

ID of the owner of this pet.
Type:
  • string
Source:

<nullable> petClass :string

The character class for this pet.
Type:
  • string
Source:

restStartTimestamp :number

Timestamp at most recent time the pet has begun resting. Used for regenerating lives.
Type:
  • number
Source:

serializable

Get a serializable version of this class instance. Strips all private variables, and all functions. Assumes all public variables are serializable if they aren't a function.
Source:

species :string

The species ID of this pet.
Type:
  • string
Source:

speedMod :number

Speed modifier on top of base species stat.
Type:
  • number
Source:

xp :number

The number of experience points this pet has.
Type:
  • number
Source:

Methods


<static> from(obj)

Create a Pet from a Pet-like Object. Similar to copy-constructor.
Parameters:
Name Type Description
obj object The Pet-like object to copy.
Source:
Returns:
Created Pet object.
Type
Pet

<static> getLevel(xp)

Get the level number for the given amount of XP. Uses Pets~Pet.levelXP to calculate.
Parameters:
Name Type Description
xp number The amount of XP to find the level number for.
Source:
Returns:
The level number for the amount of XP.
Type
number

<static> levelXP(level)

Calculate the required amount of XP for the given level. This function provides a very steep curve for levelling up. This is to help prevent extremely high leveled characters, and to encourage players to play a lot in order to level up. This is attempting to follow the similar structure to D&D since I wish to have a similar timeline for character development and play speed (characters can last for months and take weeks to level up).
Parameters:
Name Type Description
level number The level number to calculate the required XP for.
Source:
Returns:
XP required to be the given level.
Type
number

addXP(xp [, auto])

Add XP to the pet, and trigger any level-up actions that may need to occur.
Parameters:
Name Type Argument Default Description
xp number Amount of XP to add.
auto boolean <optional>
false Auto level up after adding XP.
Source:

autoLevelUp()

Automatically spend all remaining modifier points automatically until all are used up.
Source:

lostBattle()

Signal this pet just lost a battle, and update accordingly.
Source:

spendPoint(category [, num])

Spend points on a given modifier.
Parameters:
Name Type Argument Default Description
category string The name of the modifier to spend the points on.
num number <optional>
1 The number of points to spend.
Source:

touch()

Touch this object to update the last `_lastInteractTime`.
Source:

wonBattle()

Signal this pet just won a battle, and update accordingly.
Source: