From 9274b675e9e1ef9c5fe6a05316e3f60894803a51 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 11 Aug 2020 19:36:18 +0200 Subject: [PATCH] SUpport for EggMoves --- CInterface/Core.hpp | 2 ++ CInterface/Library/LearnableMoves.cpp | 14 ++++++++++++++ src/Library/Species/LearnableMoves.cpp | 1 + src/Library/Species/LearnableMoves.hpp | 25 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 CInterface/Library/LearnableMoves.cpp create mode 100644 src/Library/Species/LearnableMoves.cpp create mode 100644 src/Library/Species/LearnableMoves.hpp diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index 7364017..9ac634c 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -29,5 +29,7 @@ public: export returnType PkmnLib_##type##_##name(const type* p) { return p->name(); } #define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \ export returnType PkmnLib_##type##_##name(const type* p) { return p->name().GetRaw(); } +#define DESTRUCTOR(type) \ + export void PkmnLib_##type##_Destruct(const type* p) { delete p; } #endif // PKMNLIB_CORE_HPP diff --git a/CInterface/Library/LearnableMoves.cpp b/CInterface/Library/LearnableMoves.cpp new file mode 100644 index 0000000..c7f15a2 --- /dev/null +++ b/CInterface/Library/LearnableMoves.cpp @@ -0,0 +1,14 @@ +#include "../../src/Library/Species/LearnableMoves.hpp" +#include "../Core.hpp" +using namespace PkmnLib::Library; + +export uint8_t PkmnLib_LearnableMoves_Construct(LearnableMoves*& out, size_t levelAttackCapacity) { + Try(out = new LearnableMoves(levelAttackCapacity)); +} +DESTRUCTOR(LearnableMoves) + +export void PkmnLib_LearnableMoves_AddEggMove(LearnableMoves* p, MoveData* move) { p->AddEggMove(move); } +export size_t PkmnLib_LearnableMoves_GetEggMovesCount(LearnableMoves* p) { return p->GetEggMoves().Count(); } +export const MoveData* const* PkmnLib_LearnableMoves_GetEggMoves(LearnableMoves* p) { + return reinterpret_cast(p->GetEggMoves().RawData()); +} \ No newline at end of file diff --git a/src/Library/Species/LearnableMoves.cpp b/src/Library/Species/LearnableMoves.cpp new file mode 100644 index 0000000..85b687d --- /dev/null +++ b/src/Library/Species/LearnableMoves.cpp @@ -0,0 +1 @@ +#include "LearnableMoves.hpp" diff --git a/src/Library/Species/LearnableMoves.hpp b/src/Library/Species/LearnableMoves.hpp new file mode 100644 index 0000000..2cdcbe4 --- /dev/null +++ b/src/Library/Species/LearnableMoves.hpp @@ -0,0 +1,25 @@ +#ifndef PKMNLIB_LEARNABLEMOVES_HPP +#define PKMNLIB_LEARNABLEMOVES_HPP + +#include +#include +#include +#include "../Moves/MoveData.hpp" + +namespace PkmnLib::Library { + class LearnableMoves : CreatureLib::Library::LearnableAttacks { + ArbUt::List> _eggMoves; + + public: + explicit LearnableMoves(size_t levelAttackCapacity) : LearnableAttacks(levelAttackCapacity) {} + + void AddEggMove(const ArbUt::BorrowedPtr& move) noexcept { + if (!_eggMoves.Contains(move)) + _eggMoves.Append(move); + } + + const ArbUt::List>& GetEggMoves() const noexcept { return _eggMoves; } + }; +} + +#endif // PKMNLIB_LEARNABLEMOVES_HPP