FRjs/convert. DragonTraits

A class representing the traits of a single dragon within the context of FRjs. The class is intended to convert between indices in FRjs/data arrays, dragon profile pages, and scrying workshop links; hence, the trait data is immutable after object construction and all objects should be short-lived.

TutorialsFRjs/convert: Usage Guide

Constructor

new DragonTraits(indices)

Constructs a formal DragonTraits object from a generic object containing indices in FRjs/data arrays for any/all of a single dragon's traits. Calling the constructor directly is useful for converting traits into scrying workshop links, and for quickly getting the actual data objects for all traits.

Any traits that are left undefined, or which are invalid, will be set to a default value; index 0 for most traits, and for genes the index of Basic.

Parameters:
NameTypeDescription
indicesObject

An object defining any/all of a single dragon's traits. It may contain any of the following keys, with values being indices in the appropriate array from FRjs/data:

{
	breed: number,
	eye: number,
	element: number,
	gender: number,
	age: number,
	colour: {
		primary: number,
		secondary: number,
		tertiary: number
	},
	gene: {
		primary: number,
		secondary: number,
		tertiary: number
	}
}

Members

indices :Object

Object containing all traits as indices in the applicable array from FRjs/data.

The structure of the object is:

{
	breed: number,
	eye: number,
	element: number,
	gender: number,
	age: number,
	colour: {
		primary: number,
		secondary: number,
		tertiary: number
	},
	gene: {
		primary: number,
		secondary: number,
		tertiary: number
	}
}
Type:
  • Object

A link to the scrying workshop for a dragon with all defined traits.

Type:
  • string

values :Object

An object containing all traits as data objects from FRjs/data.

The structure of the object is:

{
	breed: FR.Breed,
	eye: FR.EyeType,
	element: FR.BasicTrait,
	gender: FR.BasicTrait,
	age: FR.BasicTrait,
	colour: {
		primary: FR.Colour,
		secondary: FR.Colour,
		tertiary: FR.Colour
	},
	gene: {
		primary: FR.Gene,
		secondary: FR.Gene,
		tertiary: FR.Gene
	}
}
Type:
  • Object

Methods

(static) fromProfile(profile) → {DragonTraits}

Returns a DragonTraits object containing all traits defined in the contents of the given dragon profile. Note: gender is not present in text on dragon profiles, and will be the default of Male.

Parameters:
NameTypeDescription
profilestring

The text contents of a dragon's profile page. NOT the page HTML; what you get by selecting all text on the page in the browser window and copying it.

Returns:
Type: 
DragonTraits

Returns a DragonTraits object containing all the traits defined in the given scrying workshop link.

Parameters:
NameTypeDescription
linkstring

A scrying workshop link. NOT a link to a saved morphology; a URL for exact morphology parameters.

Returns:
Type: 
DragonTraits