Fix issues with AngelScript not handling statistics enum well.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b8d7e5624c
commit
c91b1b0906
|
@ -26,17 +26,17 @@ void RegisterSpeciesTypes::RegisterGenderEnum(asIScriptEngine* engine) {
|
|||
void RegisterSpeciesTypes::RegisterStatisticEnum(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterEnum("Statistic");
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "HP", PkmnLib::Library::Statistic::HealthPoints);
|
||||
r = engine->RegisterEnumValue("Statistic", "HP", (int)PkmnLib::Library::Statistic::HealthPoints);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "Attack", PkmnLib::Library::Statistic::PhysicalAttack);
|
||||
r = engine->RegisterEnumValue("Statistic", "Attack", (int)PkmnLib::Library::Statistic::PhysicalAttack);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "Defense", PkmnLib::Library::Statistic::PhysicalDefense);
|
||||
r = engine->RegisterEnumValue("Statistic", "Defense", (int)PkmnLib::Library::Statistic::PhysicalDefense);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "SpecialAttack", PkmnLib::Library::Statistic::SpecialAttack);
|
||||
r = engine->RegisterEnumValue("Statistic", "SpecialAttack", (int)PkmnLib::Library::Statistic::SpecialAttack);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "SpecialDefense", PkmnLib::Library::Statistic::SpecialDefense);
|
||||
r = engine->RegisterEnumValue("Statistic", "SpecialDefense", (int)PkmnLib::Library::Statistic::SpecialDefense);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterEnumValue("Statistic", "Speed", PkmnLib::Library::Statistic::Speed);
|
||||
r = engine->RegisterEnumValue("Statistic", "Speed", (int)PkmnLib::Library::Statistic::Speed);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -145,14 +145,14 @@ TEST_CASE("Validate Forme GetStatistic in Script") {
|
|||
auto mainLib = TestLibrary::GetLibrary();
|
||||
|
||||
// Iterate over each stat, ensure they return the expected value.
|
||||
for (uint8_t statInt = CreatureLib::Core::Statistic::Health; statInt != CreatureLib::Core::Statistic::Speed;
|
||||
statInt++) {
|
||||
for (uint8_t statInt = static_cast<uint8_t>(CreatureLib::Core::Statistic::Health);
|
||||
statInt != static_cast<uint8_t>(CreatureLib::Core::Statistic::Speed); statInt++) {
|
||||
auto stat = static_cast<CreatureLib::Core::Statistic>(statInt);
|
||||
|
||||
auto data = GetScript(mainLib, "testGetStatistic");
|
||||
auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme();
|
||||
data.Context->SetArgObject(0, const_cast<PkmnLib::Library::PokemonForme*>(forme));
|
||||
data.Context->SetArgDWord(1, stat);
|
||||
data.Context->SetArgDWord(1, static_cast<asDWORD>(stat));
|
||||
data.Context->SetArgDWord(2, forme->GetStatistic(stat));
|
||||
REQUIRE(data.Context->Execute() == asEXECUTION_FINISHED);
|
||||
REQUIRE((bool)data.Context->GetReturnWord());
|
||||
|
|
Loading…
Reference in New Issue