Item C Interface.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-17 21:02:17 +02:00
parent a95b6d1817
commit 66060c68c0
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,25 @@
#include "../../src/Library/Items/Item.hpp"
#include <Arbutils/ConstString.hpp>
#include "../Core.hpp"
using namespace PkmnLib::Library;
export Item* PkmnLib_Item_Construct(const char* name, CreatureLib::Library::ItemCategory category,
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
const char* flags[], size_t flagsCount, uint8_t flingPower) {
std::unordered_set<uint32_t> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(Arbutils::CaseInsensitiveConstString::GetHash(flags[i]));
}
return new Item(Arbutils::CaseInsensitiveConstString(name), category, battleCategory, price, conversedFlags,
flingPower);
};
export void PkmnLib_Item_Destruct(const Item* p) { delete p; }
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType PkmnLib_##type##_##name(const PkmnLib::Library::type* p) { return p->name(); }
SIMPLE_GET_FUNC(Item, GetFlingPower, uint8_t)
#undef SIMPLE_GET_FUNC

View File

@ -9,10 +9,10 @@ namespace PkmnLib::Library {
public:
Item(const Arbutils::CaseInsensitiveConstString& name, CreatureLib::Library::ItemCategory category,
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
std::unordered_set<uint32_t> flags, uint8_t flingPower)
const std::unordered_set<uint32_t>& flags, uint8_t flingPower) noexcept
: CreatureLib::Library::Item(name, category, battleCategory, price, flags), _flingPower(flingPower) {}
inline uint8_t GetFlingPower() const { return _flingPower; }
inline uint8_t GetFlingPower() const noexcept { return _flingPower; }
};
}