Adds angelscript helper function to check if Pokemon has a type by the types string name.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-20 11:06:39 +01:00
parent 8de1d4d635
commit 4d1b3448ba
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 8 additions and 0 deletions

View File

@ -81,6 +81,11 @@ static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const A
return handle;
}
static bool HasTypeStringWrapper(PkmnLib::Battling::Pokemon* p, const ArbUt::StringView& sv) {
auto typeId = p->GetLibrary()->GetTypeLibrary()->GetTypeId(sv);
return p->HasType(typeId);
}
static float GetEffectivenessHelper(CreatureLib::Library::TypeLibrary* typeLib, u8 attackingType,
PkmnLib::Battling::Pokemon* pokemon) {
return typeLib->GetEffectiveness(attackingType, pokemon->GetTypes());
@ -152,6 +157,9 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(uint8 type) const",
asMETHOD(PkmnLib::Battling::Pokemon, HasType), asCALL_THISCALL);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(const constString& type) const",
asFUNCTION(HasTypeStringWrapper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("Pokemon", "void Damage(uint32 type, DamageSource source)",
asMETHOD(PkmnLib::Battling::Pokemon, Damage), asCALL_THISCALL);
Ensure(r >= 0);