SpeciesInfo tests (#3688)

* Remove unnecessary const

* Test that species ID tables are shared between all forms

* Use P_FAMILY_MELTAN

* Test that form change tables contain only IDs in form species tables

* Fix isPrimalReversion typo

* Test form change targets have appropriate species flags

* Fix #3689
This commit is contained in:
Martin Griffin 2023-12-11 12:54:20 +00:00 committed by GitHub
parent ec9cc9a443
commit ee1fb1d454
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 121 additions and 26 deletions

View file

@ -385,7 +385,7 @@ struct SpeciesInfo /*0x8C*/
u32 isUltraBeast:1;
u32 isParadoxForm:1;
u32 isMegaEvolution:1;
u32 isPrimalRevesion:1;
u32 isPrimalReversion:1;
u32 isUltraBurst:1;
u32 isGigantamax:1;
u32 isAlolanForm:1;
@ -396,11 +396,11 @@ struct SpeciesInfo /*0x8C*/
u32 allPerfectIVs:1;
u32 padding4:18;
// Move Data
/* 0x80 */ const struct LevelUpMove *const levelUpLearnset;
/* 0x84 */ const u16 *const teachableLearnset;
/* 0x88 */ const struct Evolution *const evolutions;
/* 0x84 */ const u16 *const formSpeciesIdTable;
/* 0x84 */ const struct FormChange *const formChangeTable;
/* 0x80 */ const struct LevelUpMove *levelUpLearnset;
/* 0x84 */ const u16 *teachableLearnset;
/* 0x88 */ const struct Evolution *evolutions;
/* 0x84 */ const u16 *formSpeciesIdTable;
/* 0x84 */ const struct FormChange *formChangeTable;
};
struct BattleMove

View file

@ -10395,7 +10395,7 @@ bool32 IsBattlerPrimalReverted(u32 battler)
// While Transform does copy stats and visuals, it shouldn't be counted as true Primal Revesion.
if (gBattleMons[battler].status2 & STATUS2_TRANSFORMED)
return FALSE;
return (gSpeciesInfo[gBattleMons[battler].species].isPrimalRevesion);
return (gSpeciesInfo[gBattleMons[battler].species].isPrimalReversion);
}
bool32 IsBattlerUltraBursted(u32 battler)

View file

@ -829,12 +829,15 @@ static const struct FormChange sNecrozmaDawnWingsFormChangeTable[] = {
{FORM_CHANGE_BATTLE_ULTRA_BURST, SPECIES_NECROZMA_ULTRA, ITEM_ULTRANECROZIUM_Z},
{FORM_CHANGE_TERMINATOR},
};
#endif //P_FAMILY_NECROZMA
#if P_FAMILY_MELTAN
static const struct FormChange sMelmetalFormChangeTable[] =
{
{FORM_CHANGE_BATTLE_GIGANTAMAX, SPECIES_MELMETAL_GIGANTAMAX},
{FORM_CHANGE_TERMINATOR},
};
#endif //P_FAMILY_NECROZMA
#endif //P_FAMILY_MELTAN
#if P_FAMILY_GROOKEY
static const struct FormChange sRillaboomFormChangeTable[] =

View file

@ -1751,3 +1751,13 @@ static const u16 sGimmighoulFormSpeciesIdTable[] = {
FORM_SPECIES_END,
};
#endif //P_FAMILY_GIMMIGHOUL
#if P_FAMILY_OGERPON
static const u16 sOgerponFormSpeciesIdTable[] = {
SPECIES_OGERPON_TEAL_MASK,
SPECIES_OGERPON_WELLSPRING_MASK,
SPECIES_OGERPON_HEARTHFLAME_MASK,
SPECIES_OGERPON_CORNERSTONE_MASK,
FORM_SPECIES_END,
};
#endif //P_FAMILY_OGERPON

View file

@ -25988,7 +25988,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.backAnimId = BACK_ANIM_SHAKE_GLOW_BLUE,
PALETTES(KyogrePrimal),
ICON(KyogrePrimal, 0),
.isPrimalRevesion = TRUE,
.isPrimalReversion = TRUE,
},
#endif //P_PRIMAL_REVERSIONS
#endif //P_FAMILY_KYOGRE
@ -26080,7 +26080,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.backAnimId = BACK_ANIM_SHAKE_GLOW_RED,
PALETTES(GroudonPrimal),
ICON(GroudonPrimal, 0),
.isPrimalRevesion = TRUE,
.isPrimalReversion = TRUE,
},
#endif //P_PRIMAL_REVERSIONS
#endif //P_FAMILY_GROUDON
@ -48783,6 +48783,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.trainerOffset = 8, \
.footprint = gMonFootprint_Melmetal, \
LEARNSETS(Melmetal), \
.formSpeciesIdTable = sMelmetalFormSpeciesIdTable, \
.formChangeTable = sMelmetalFormChangeTable, \
.isMythical = TRUE
@ -48948,6 +48949,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Drummer"), \
.footprint = gMonFootprint_Rillaboom, \
LEARNSETS(Rillaboom), \
.formSpeciesIdTable = sRillaboomFormSpeciesIdTable, \
.formChangeTable = sRillaboomFormChangeTable
[SPECIES_RILLABOOM] =
@ -48995,7 +48997,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(RillaboomGigantamax),
ICON(RillaboomGigantamax, 1),
.formSpeciesIdTable = sRillaboomFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -49121,6 +49122,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Striker"), \
.footprint = gMonFootprint_Cinderace, \
LEARNSETS(Cinderace), \
.formSpeciesIdTable = sCinderaceFormSpeciesIdTable, \
.formChangeTable = sCinderaceFormChangeTable
[SPECIES_CINDERACE] =
@ -49169,7 +49171,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(CinderaceGigantamax),
ICON(CinderaceGigantamax, 0),
.formSpeciesIdTable = sCinderaceFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -49296,6 +49297,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Secret Agent"), \
.footprint = gMonFootprint_Inteleon, \
LEARNSETS(Inteleon), \
.formSpeciesIdTable = sInteleonFormSpeciesIdTable, \
.formChangeTable = sInteleonFormChangeTable
[SPECIES_INTELEON] =
@ -49569,6 +49571,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Raven"), \
.footprint = gMonFootprint_Corviknight, \
LEARNSETS(Corviknight), \
.formSpeciesIdTable = sCorviknightFormSpeciesIdTable, \
.formChangeTable = sCorviknightFormChangeTable
[SPECIES_CORVIKNIGHT] =
@ -49617,7 +49620,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(CorviknightGigantamax),
ICON(CorviknightGigantamax, 0),
.formSpeciesIdTable = sCorviknightFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -49745,6 +49747,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Seven Spot"), \
.footprint = gMonFootprint_Orbeetle, \
LEARNSETS(Orbeetle), \
.formSpeciesIdTable = sOrbeetleFormSpeciesIdTable, \
.formChangeTable = sOrbeetleFormChangeTable
[SPECIES_ORBEETLE] =
@ -49794,7 +49797,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(OrbeetleGigantamax),
ICON(OrbeetleGigantamax, 0),
.formSpeciesIdTable = sOrbeetleFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -50163,6 +50165,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Bite"), \
.footprint = gMonFootprint_Drednaw, \
LEARNSETS(Drednaw), \
.formSpeciesIdTable = sDrednawFormSpeciesIdTable, \
.formChangeTable = sDrednawFormChangeTable
[SPECIES_DREDNAW] =
@ -50210,7 +50213,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(DrednawGigantamax),
ICON(DrednawGigantamax, 0),
.formSpeciesIdTable = sDrednawFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -50433,6 +50435,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Coal"), \
.footprint = gMonFootprint_Coalossal, \
LEARNSETS(Coalossal), \
.formSpeciesIdTable = sCoalossalFormSpeciesIdTable, \
.formChangeTable = sCoalossalFormChangeTable
[SPECIES_COALOSSAL] =
@ -50481,7 +50484,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(CoalossalGigantamax),
ICON(CoalossalGigantamax, 0),
.formSpeciesIdTable = sCoalossalFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -50562,6 +50564,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Apple Wing"), \
.footprint = gMonFootprint_Flapple, \
LEARNSETS(Flapple), \
.formSpeciesIdTable = sFlappleFormSpeciesIdTable, \
.formChangeTable = sFlappleFormChangeTable
[SPECIES_FLAPPLE] =
@ -50610,7 +50613,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(FlappleGigantamax),
ICON(FlappleGigantamax, 1),
.formSpeciesIdTable = sFlappleFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -50639,6 +50641,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Apple Nectar"), \
.footprint = gMonFootprint_Appletun, \
LEARNSETS(Appletun), \
.formSpeciesIdTable = sAppletunFormSpeciesIdTable, \
.formChangeTable = sAppletunFormChangeTable
[SPECIES_APPLETUN] =
@ -50686,7 +50689,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(AppletunGigantamax),
ICON(AppletunGigantamax, 1),
.formSpeciesIdTable = sAppletunFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -50812,6 +50814,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Sand Snake"), \
.footprint = gMonFootprint_Sandaconda, \
LEARNSETS(Sandaconda), \
.formSpeciesIdTable = sSandacondaFormSpeciesIdTable, \
.formChangeTable = sSandacondaFormChangeTable
[SPECIES_SANDACONDA] =
@ -50861,7 +50864,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(SandacondaGigantamax),
ICON(SandacondaGigantamax, 1),
.formSpeciesIdTable = sSandacondaFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -51307,6 +51309,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Radiator"), \
.footprint = gMonFootprint_Centiskorch, \
LEARNSETS(Centiskorch), \
.formSpeciesIdTable = sCentiskorchFormSpeciesIdTable, \
.formChangeTable = sCentiskorchFormChangeTable
[SPECIES_CENTISKORCH] =
@ -51355,7 +51358,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(CentiskorchGigantamax),
ICON(CentiskorchGigantamax, 0),
.formSpeciesIdTable = sCentiskorchFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -51699,6 +51701,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Silent"), \
.footprint = gMonFootprint_Hatterene, \
LEARNSETS(Hatterene), \
.formSpeciesIdTable = sHattereneFormSpeciesIdTable, \
.formChangeTable = sHattereneFormChangeTable
[SPECIES_HATTERENE] =
@ -51746,7 +51749,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(HattereneGigantamax),
ICON(HattereneGigantamax, 0),
.formSpeciesIdTable = sHattereneFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -51873,6 +51875,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Bulk Up"), \
.footprint = gMonFootprint_Grimmsnarl, \
LEARNSETS(Grimmsnarl), \
.formSpeciesIdTable = sGrimmsnarlFormSpeciesIdTable, \
.formChangeTable = sGrimmsnarlFormChangeTable
[SPECIES_GRIMMSNARL] =
@ -51920,7 +51923,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(GrimmsnarlGigantamax),
ICON(GrimmsnarlGigantamax, 0),
.formSpeciesIdTable = sGrimmsnarlFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -52677,6 +52679,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Copperderm"), \
.footprint = gMonFootprint_Copperajah, \
LEARNSETS(Copperajah), \
.formSpeciesIdTable = sCopperajahFormSpeciesIdTable, \
.formChangeTable = sCopperajahFormChangeTable
[SPECIES_COPPERAJAH] =
@ -52724,8 +52727,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(CopperajahGigantamax),
ICON(CopperajahGigantamax, 0),
.formSpeciesIdTable = sCopperajahFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -52951,6 +52952,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.categoryName = _("Alloy"), \
.footprint = gMonFootprint_Duraludon, \
LEARNSETS(Duraludon), \
.formSpeciesIdTable = sDuraludonFormSpeciesIdTable, \
.formChangeTable = sDuraludonFormChangeTable
[SPECIES_DURALUDON] =
@ -52998,7 +53000,6 @@ const struct SpeciesInfo gSpeciesInfo[] =
//.backAnimId = BACK_ANIM_NONE,
PALETTES(DuraludonGigantamax),
ICON(DuraludonGigantamax, 0),
.formSpeciesIdTable = sDuraludonFormSpeciesIdTable,
.isGigantamax = TRUE,
},
#endif //P_GIGANTAMAX_FORMS
@ -59449,6 +59450,7 @@ const struct SpeciesInfo gSpeciesInfo[] =
.palette = gMonPalette_Ogerpon##Form, \
ICON(OgerponTealMask, 1), \
LEARNSETS(Ogerpon), \
.formSpeciesIdTable = sOgerponFormSpeciesIdTable, \
.formChangeTable = sOgerponFormChangeTable, \
.isLegendary = TRUE, \
}

View file

@ -9239,10 +9239,12 @@ static const union AnimCmd sAnim_Togedemaru_1[] =
ANIMCMD_FRAME(0, 5),
ANIMCMD_END,
};
#endif //P_FAMILY_TOGEDEMARU
#if P_FAMILY_MIMIKYU
PLACEHOLDER_ANIM_SINGLE_FRAME(MimikyuDisguised);
PLACEHOLDER_ANIM_SINGLE_FRAME(MimikyuBusted);
#endif //P_FAMILY_TOGEDEMARU
#endif //P_FAMILY_MIMIKYU
#if P_FAMILY_BRUXISH
PLACEHOLDER_ANIM_SINGLE_FRAME(Bruxish);

78
test/species.c Normal file
View file

@ -0,0 +1,78 @@
#include "global.h"
#include "test/test.h"
#include "constants/form_change_types.h"
TEST("Form species ID tables are shared between all forms")
{
u32 i;
u32 species = SPECIES_NONE;
for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formSpeciesIdTable) PARAMETRIZE { species = i; }
}
const u16 *formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
for (i = 0; formSpeciesIdTable[i] != FORM_SPECIES_END; i++)
{
u32 formSpeciesId = formSpeciesIdTable[i];
EXPECT_EQ(gSpeciesInfo[formSpeciesId].formSpeciesIdTable, formSpeciesIdTable);
}
}
TEST("Form change tables contain only forms in the form species ID table")
{
u32 i, j;
u32 species = SPECIES_NONE;
for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formChangeTable) PARAMETRIZE { species = i; }
}
const struct FormChange *formChangeTable = gSpeciesInfo[species].formChangeTable;
const u16 *formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
EXPECT(formSpeciesIdTable);
for (i = 0; formChangeTable[i].method != FORM_CHANGE_TERMINATOR; i++)
{
for (j = 0; formSpeciesIdTable[j] != FORM_SPECIES_END; j++)
{
if (formChangeTable[i].targetSpecies == formSpeciesIdTable[j])
{
break;
}
}
EXPECT(formSpeciesIdTable[j] != FORM_SPECIES_END);
}
}
TEST("Form change targets have the appropriate species flags")
{
u32 i;
u32 species = SPECIES_NONE;
for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formChangeTable) PARAMETRIZE { species = i; }
}
const struct FormChange *formChangeTable = gSpeciesInfo[species].formChangeTable;
for (i = 0; formChangeTable[i].method != FORM_CHANGE_TERMINATOR; i++)
{
const struct SpeciesInfo *targetSpeciesInfo = &gSpeciesInfo[formChangeTable[i].targetSpecies];
switch (formChangeTable[i].method)
{
case FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM:
case FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE:
EXPECT(targetSpeciesInfo->isMegaEvolution);
break;
case FORM_CHANGE_BATTLE_PRIMAL_REVERSION:
EXPECT(targetSpeciesInfo->isPrimalReversion);
break;
case FORM_CHANGE_BATTLE_ULTRA_BURST:
EXPECT(targetSpeciesInfo->isUltraBurst);
break;
case FORM_CHANGE_BATTLE_GIGANTAMAX:
EXPECT(targetSpeciesInfo->isGigantamax);
break;
}
}
}