Fix gendered form evolutions always assigning male

This commit is contained in:
Flashfyre committed 2024-04-06 20:48:58 -04:00
1 parent e5ffc1e2db
commit 59cb4daa52
2 files changed
+20 -17

No files matched your search

+14 -11
View File
@@ -143,17 +143,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.id = Utils.randSeedInt(4294967296);
this.ivs = ivs || Utils.getIvsFromId(this.id);
if (this.gender === undefined) {
if (this.species.malePercent === null)
this.gender = Gender.GENDERLESS;
else {
const genderChance = (this.id % 256) * 0.390625;
if (genderChance < this.species.malePercent)
this.gender = Gender.MALE;
else
this.gender = Gender.FEMALE;
}
}
if (this.gender === undefined)
this.generateGender();
if (this.formIndex === undefined)
this.formIndex = this.scene.getSpeciesFormIndex(species, this.gender, this.nature, this.isPlayer());
@@ -602,6 +593,18 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return Math.floor((this.hp / this.getMaxHp()) * 100) / 100;
}
generateGender(): void {
if (this.species.malePercent === null)
this.gender = Gender.GENDERLESS;
else {
const genderChance = (this.id % 256) * 0.390625;
if (genderChance < this.species.malePercent)
this.gender = Gender.MALE;
else
this.gender = Gender.FEMALE;
}
}
getGender(ignoreOverride?: boolean): Gender {
if (!ignoreOverride && this.summonData?.gender !== undefined)
return this.summonData.gender;