Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AxieGene

Stores the gene information of an Axie. These informations are parsed from the provided hex representation of the Axie's gene on its constructor call. Supports both 256 and 512 bit hex genes.

Usage

Javascript

const { AxieGene } = require("agp-npm-test/dist/src/axie-gene");
const axieGene = new AxieGene("0x11c642400a028ca14a428c20cc011080c61180a0820180604233082");

Typescript

const axieGene = new AxieGene("0x11c642400a028ca14a428c20cc011080c61180a0820180604233082");

Hierarchy

  • AxieGene

Index

Constructors

constructor

  • Used to initialize an AxieGene object from a hex representation of the Axie's gene.

    Parameters

    • hex: string

      hex representation of the Axie's gene.

    • hexType: HexType = ...

      represents if the provided hex gene is in 256 or 512 bit.

    Returns AxieGene

Properties

Private Readonly _genes

_genes: Gene

Stores the gene details from the parsed binary values.

Private Readonly _hexType

_hexType: HexType

Stores the gene hex type wether its in 256 or 512 bit.

Private geneBinGroup

geneBinGroup: GeneBinGroup

Stores the grouped binary values from the hex value.

Accessors

back

  • Getter for the back genes of the Axie.

    Returns Part

    Genes for the Axie's back.

bodySkin

cls

  • get cls(): Cls
  • Getter for the class of the Axie.

    Returns Cls

    Class of the Axie.

color

ears

  • Getter for the ears genes of the Axie.

    Returns Part

    Genes for the Axie's ears.

eyes

  • Getter for the eye genes of the Axie.

    Returns Part

    Genes for the Axie's eye.

genes

  • Getter for all of the details of the Axie's gene.

    Returns Gene

    Objects that contains all of the details about of the Axie's gene.

horn

  • Getter for the horn genes of the Axie.

    Returns Part

    Genes for the Axie's horns.

mouth

  • Getter for the mouth genes of the Axie.

    Returns Part

    Genes for the Axie's mouth.

pattern

region

tag

  • get tag(): Tag
  • Getter for the tag associated with the Axie.

    Returns Tag

    Tag associated with the Axie.

tail

  • Getter for the tail genes of the Axie.

    Returns Part

    Genes for the Axie's tail.

Methods

getGeneQuality

  • getGeneQuality(): number
  • Calculates the purity or gene quality of the Axie's gene.

    Returns number

    a number that represents the quality of the gene in percentage.

Private getPartQuality

  • getPartQuality(part: Part): number
  • Calculate the purity or gene quality of the Axie's individual parts.

    Parameters

    • part: Part

      part genes the will be used for the calculation.

    Returns number

    an integer that represents the quality of the individual part in percentage.

Private parseBodySkin

  • Parse the body skin binary values from the GeneBinGroup into a BodySkin object.

    Returns BodySkin

    BodySkin body skin of the Axie.

Private parseClass

  • parseClass(): Cls
  • Parse the class binary values from the GeneBinGroup into a Cls object.

    Returns Cls

    Cls class of the Axie.

Private parseColorGenes

  • Parse the color gene binary values from the GeneBinGroup into a ColorGene object.

    Returns ColorGene

    ColorGene color gene of the Axie.

Private parseGenes

  • parseGenes(): Gene
  • Converts the binary values into a human-readable format in the form of a Gene object.

    Returns Gene

    Gene Gene object that contains the set of gene information.

Private parseHex

  • Converts the hex into its binary representation and divides them based on their respective respective groups. Each group represents a part of an Axie.

    Parameters

    • hex: string

      hex representation of an Axie's gene.

    Returns GeneBinGroup

    An object that contains the binary value from the hex. The binary values are divided into their respective group based on the gene detail that they represent.

Private parsePart

  • Parse the part gene binary values from the GeneBinGroup into a Part object.

    Parameters

    • partBin: string

      binary of the part that will be parsed.

    • partType: PartType

      part type that will be parsed. A part type refers to an Axie's body part including: Eyes, Ears, Mouth, Back, Horn, Tail

    Returns Part

    Part part gene of the Axie.

Private parsePartClass

  • parsePartClass(bin: string): Cls
  • Parse the class of the given part into a Cls object.

    Parameters

    • bin: string

      binary representation of an Axie's body part.

    Returns Cls

    Cls class of the Axie's body part.

Private parsePartGene

  • Converts the part type and name into a format used as the partId. A lookup is then performed from the contents of the parts.json file to match the partId with the part gene presets.

    Parameters

    • partType: PartType

      body part that will be parsed.

    • partName: string

      name of the specific body part.

    Returns PartGene

    PartGene an objects that contains the part class, id, name, type, and if it is a special gene.

Private parsePartName

  • parsePartName(cls: Cls, partType: PartType, regionBin: string, partBin: string, skin: PartSkin): string
  • Parse the name of an Axie's body part based on its class, part type, region, part binary, and skin binary.

    Parameters

    • cls: Cls

      class of the Axie's body part.

    • partType: PartType

      part type that will be parsed.

    • regionBin: string

      region binary of the Axie.

    • partBin: string

      part binary of the Axie.

    • skin: PartSkin

      skin type of the Axie's part.

    Returns string

    Cls class of the Axie.

Private parsePartSkin

  • parsePartSkin(regionBin: string, skinBin: string): PartSkin
  • Parses the skin of the part based on its region and skin binary value.

    Parameters

    • regionBin: string

      region binary of the Axie.

    • skinBin: string

      skin binary of the Axie.

    Returns PartSkin

    PartSkin skin of the Axie's body part.

Private parsePatternGenes

  • Parse the pattern gene binary values from the GeneBinGroup into a PatternGene object.

    Returns PatternGene

    PatternGene pattern gene of the Axie.

Private parseRegion

  • Parse the region binary values from the GeneBinGroup into a Region object.

    Returns Region

    Region region of the Axie.

Private parseTag

  • parseTag(): Tag
  • Parse the tag binary values from the GeneBinGroup into a Tag object.

    Returns Tag

    Tag tag of the Axie.

Generated using TypeDoc