GithubHelp home page GithubHelp logo

lgyaxx / agp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shanemaglangit/agp

0.0 1.0 0.0 125 KB

Gene parsing package for Axie Infinity

Home Page: https://pkg.go.dev/github.com/shanemaglangit/agp

License: GNU General Public License v3.0

Go 100.00%

agp's Introduction

agp

Go project version GoDoc

Package agp is a gene parsing package for Axie Infinity.

The name agp stands for "Axie Gene Parser" which decodes the hex representation of an Axie's gene into a human readable format.

Only supports 256 bit genes



Install

With a correctly configured Go toolchain:

go get -u github.com/shanemaglangit/agp

Usage

Starting on v1.0.3, ParseHexDecode was introduced which combines both ParseHex and Decode into a single function.

To get started, you'll first need to get the gene of an Axie in hex. You may use the Axie Infinity GraphQL endpoint to get this detail. For this example, let's use the hex 0x11c642400a028ca14a428c20cc011080c61180a0820180604233082

Let us first parse this hex into a GeneBinGroup object. ParseHex() first converts the given hex into its binary format. It thens divides these binary bits into their own respective groups, each representing a certain attribute of the Axie's gene.

gbg, err := agp.ParseHex("0x11c642400a028ca14a428c20cc011080c61180a0820180604233082")

Once we generated the GeneBinGroup, we can then use decode this object into human readable format using Decode()

genes, err := agp.Decode(gbg)

The generated output should look like this

&Genes{
  Class:    Beast,
  Region:   Global,
  Tag:      NoTag,
  BodySkin: DefBodySkin,
  Pattern:  PatternGene{"000001", "000111", "000110"},
  Color:    ColorGene{"f0c66e", "ffec51", "f0c66e"},
  Eyes: Part{
    D:  PartGene{"eyes-chubby", Beast, "", Eyes, "Chubby"},
    R1: PartGene{"eyes-chubby", Beast, "", Eyes, "Chubby"},
    R2: PartGene{"eyes-blossom", Plant, "", Eyes, "Blossom"},
  },
  Ears: Part{
    D:  PartGene{"ears-lotus", Plant, "", Ears, "Lotus"},
    R1: PartGene{"ears-nut-cracker", Beast, "", Ears, "Nut Cracker"},
    R2: PartGene{"ears-inkling", Aquatic, "", Ears, "Inkling"},
  },
  Horn: Part{
    D:  PartGene{"horn-rose-bud", Plant, "", Horn, "Rose Bud"},
    R1: PartGene{"horn-caterpillars", Bug, "", Horn, "Caterpillars"},
    R2: PartGene{"horn-dual-blade", Beast, "", Horn, "Dual Blade"},
  },
  Mouth: Part{
    D:  PartGene{"mouth-tiny-turtle", Reptile, "", Mouth, "Tiny Turtle"},
    R1: PartGene{"mouth-piranha", Aquatic, "", Mouth, "Piranha"},
    R2: PartGene{"mouth-serious", Plant, "", Mouth, "Serious"},
  },
  Back: Part{
    D:  PartGene{"back-balloon", Bird, "", Back, "Balloon"},
    R1: PartGene{"back-jaguar", Beast, "", Back, "Jaguar"},
    R2: PartGene{"back-jaguar", Beast, "", Back, "Jaguar"},
  },
  Tail: Part{
    D:  PartGene{"tail-ant", Bug, "", Tail, "Ant"},
    R1: PartGene{"tail-hot-butt", Plant, "", Tail, "Hot Butt"},
    R2: PartGene{"tail-swallow", Bird, "", Tail, "Swallow"},
  },
}

NPM Support

I also released a similar package for NPM. Do check it out!

Support the Author

Love this module? Feel free to buy me a coffee and motivate me to work on more stuffs like this!

Ronin Address: ronin:789c9b253eba265f0079e3ebcaaea2503eb31bb3
ETH Address: 0x9F50E3606caf22ff5E0E03F0eb02DE3Fa2786535
Paypal: paypal.me/shanemaglangit

Support does not need to have any monetary value. I would also appreciate if you leave a star!

agp's People

Contributors

shanemaglangit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.