Adds optional max turn parameters to HistoryHolder interface in Angelscript.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-10-24 11:16:29 +02:00
parent d172273b11
commit 0745b063c8
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 10 additions and 7 deletions

View File

@ -50,19 +50,22 @@ void RegisterBattleHistory::RegisterHistoryElement(asIScriptEngine* engine) {
asFunctionPtr(GetAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0); asFunctionPtr(GetAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0);
} }
OPTIONAL_BORROWED_PTR_GETTER_FUNC(HistoryHolder, const HistoryElement, GetLastUsedAttack); const HistoryElement* GetLastUsedAttackWrapper(const HistoryHolder* holder, u32 maxTurns) {
return holder->GetLastUsedAttack(maxTurns).GetValue();
}
const HistoryElement* GetLastDamageOnTargetWrapper(const HistoryHolder* holder, const Creature* c) { const HistoryElement* GetLastDamageOnTargetWrapper(const HistoryHolder* holder, const Creature* c, u32 maxTurns) {
return holder->GetLastDamageOnTarget(c).GetValue(); return holder->GetLastDamageOnTarget(c, maxTurns).GetValue();
} }
void RegisterBattleHistory::RegisterHistoryHolder(asIScriptEngine* engine) { void RegisterBattleHistory::RegisterHistoryHolder(asIScriptEngine* engine) {
Ensure(engine->RegisterObjectType("BattleHistory", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0); Ensure(engine->RegisterObjectType("BattleHistory", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
REGISTER_GETTER("BattleHistory", "const HistoryElement@ get_TopElement() const property", HistoryHolder, REGISTER_GETTER("BattleHistory", "const HistoryElement@ get_TopElement() const property", HistoryHolder,
GetTopElement); GetTopElement);
Ensure(engine->RegisterObjectMethod("BattleHistory", "const AttackUseHistory@ GetLastUsedAttack() const",
asFunctionPtr(GetLastUsedAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0);
Ensure(engine->RegisterObjectMethod("BattleHistory", Ensure(engine->RegisterObjectMethod("BattleHistory",
"const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target) const", "const AttackUseHistory@ GetLastUsedAttack(uint maxTurns = 0) const",
asFunctionPtr(GetLastUsedAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0);
Ensure(engine->RegisterObjectMethod(
"BattleHistory", "const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target, uint maxTurns = 0) const",
asFunctionPtr(GetLastDamageOnTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0); asFunctionPtr(GetLastDamageOnTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0);
} }