yuko1101 / enka-network-api

A Node.js Enka.Network API wrapper for Genshin Impact.
https://enka-network-api.vercel.app
MIT License
96 stars 7 forks source link

convertToGOODStatKey fails for base HP/ATK/DEF #214

Closed Quantum-Pi closed 1 week ago

Quantum-Pi commented 1 week ago

Using the following code:

getCharactersById(characterId, enka)[0].getStats(6, 90).map(stat => ({
    stat: convertToGOODStatKey(stat.fightProp),
    value: stat.value
});

Results in:

[
  { stat: undefined, value: 10222.42024244 },
  { stat: undefined, value: 201.7773324 },
  { stat: undefined, value: 757.59889275 },
  { stat: 'critRate_', value: 0.05 },
  { stat: 'critDMG_', value: 0.5 },
  { stat: 'atk_', value: 0.24 },
  { stat: 'hydro_dmg_', value: 0.2 }
]

(for XQ)

In the linked file, the map contains FIGHT_PROP_HP/ATTACK/DEFENSE but getCharactersById().getStats() is returning FIGHT_PROP_BASE_HP/ATTACK/DEFENSE.

https://github.com/yuko1101/enka-network-api/blob/a91b4911e483befc450c005a2ab0385867181a6c/src/models/good/IGOODResolvable.ts#L25

I haven't investigated the underlying reason for this and for now I'm manually replacing '_BASE' from the FightProps I'm receiving. From what it looks like though the FightProp type does indeed include the _BASE portion. Just wanted to bring it to your attention.

yuko1101 commented 1 week ago

Thanks for your report

convertToGOODStatKey is only designed for artifact stats https://frzyc.github.io/genshin-optimizer/#/doc/StatKey (and I don't know what to name it)

Quantum-Pi commented 1 week ago

Ah, I see the distinction more clearly now. Forgot flat atk doesn't factor into base atk. Thanks!