Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Axie Stats #13

Open
herenickname opened this issue Sep 16, 2021 · 1 comment
Open

Axie Stats #13

herenickname opened this issue Sep 16, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@herenickname
Copy link

Can you add a method for obtaining Axie statistics to the library?
Interested in the fields hp, speed, morale, skill.

It seems that it is possible to summarize the information obtained from genes.
Documentation: https://axie.zone/stats

Thank you for your work.

@ShaneMaglangit
Copy link
Owner

ShaneMaglangit commented Sep 16, 2021

For temporary means, you can use the following code as a reference to perform it outside of the library.

var baseStatsMap = map[agp.Class]map[string]int{
	agp.Aquatic: {"hp": 39, "speed": 39, "skill": 35, "morale": 27},
	agp.Beast:   {"hp": 31, "speed": 35, "skill": 31, "morale": 43},
	agp.Bird:    {"hp": 27, "speed": 43, "skill": 35, "morale": 35},
	agp.Bug:     {"hp": 35, "speed": 31, "skill": 35, "morale": 39},
	agp.Plant:   {"hp": 43, "speed": 31, "skill": 31, "morale": 35},
	agp.Reptile: {"hp": 39, "speed": 35, "skill": 31, "morale": 35},
	agp.Dawn:    {"hp": 35, "speed": 35, "skill": 39, "morale": 31},
	agp.Dusk:    {"hp": 43, "speed": 39, "skill": 27, "morale": 31},
	agp.Mech:    {"hp": 31, "speed": 39, "skill": 43, "morale": 27},
}

func getStatsFromGenes(genes agp.Genes) (int, int, int, int) {
	hp := baseStatsMap[genes.Class]["hp"] + getBonusStats(genes, "hp")
	speed := baseStatsMap[genes.Class]["speed"] + getBonusStats(genes, "speed")
	skill := baseStatsMap[genes.Class]["skill"] + getBonusStats(genes, "skill")
	morale := baseStatsMap[genes.Class]["morale"] + getBonusStats(genes, "morale")
	return hp, speed, skill, morale
}

var bonusStatsMap = map[agp.Class]map[string]int{
	agp.Aquatic: {"hp": 1, "speed": 3, "skill": 0, "morale": 0},
	agp.Beast:   {"hp": 0, "speed": 1, "skill": 0, "morale": 3},
	agp.Bird:    {"hp": 0, "speed": 3, "skill": 0, "morale": 1},
	agp.Bug:     {"hp": 1, "speed": 0, "skill": 0, "morale": 3},
	agp.Plant:   {"hp": 3, "speed": 0, "skill": 0, "morale": 1},
	agp.Reptile: {"hp": 3, "speed": 1, "skill": 0, "morale": 0},
}

func getBonusStats(genes agp.Genes, stat string) int {
	bonusStat := 0
	bonusStat += bonusStatsMap[genes.Eyes.D.Class][stat]
	bonusStat += bonusStatsMap[genes.Ears.D.Class][stat]
	bonusStat += bonusStatsMap[genes.Horn.D.Class][stat]
	bonusStat += bonusStatsMap[genes.Mouth.D.Class][stat]
	bonusStat += bonusStatsMap[genes.Back.D.Class][stat]
	bonusStat += bonusStatsMap[genes.Tail.D.Class][stat]
	return bonusStat
}

This is from the Go library and would most likely get the feature earlier than the NPM one.

@ShaneMaglangit ShaneMaglangit added enhancement New feature or request good first issue Good for newcomers labels Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants