CreatureLib/CInterface/Library/Item.cpp

36 lines
1.9 KiB
C++

#include "../../src/Library/Items/Item.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
export_func Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
i32 price, const char* effectName, EffectParameter* effectParameters[],
size_t effectParameterCount, const char* battleTriggerEffectName,
EffectParameter* battleTriggerEffectParameters[],
size_t battleTriggerEffectParameterCount, const char* flags[],
size_t flagsCount) {
std::unordered_set<u32> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
}
return new Item(
ArbUt::StringView(name), category, battleCategory, price,
new SecondaryEffect(100, effectName,
ArbUt::List<EffectParameter*>(effectParameters, effectParameters + effectParameterCount)),
new SecondaryEffect(
100, battleTriggerEffectName,
ArbUt::List<EffectParameter*>(battleTriggerEffectParameters,
battleTriggerEffectParameters + battleTriggerEffectParameterCount)),
conversedFlags);
};
export_func void CreatureLib_Item_Destruct(const Item* p) { delete p; }
export_func const char* CreatureLib_Item_GetName(const Item* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(Item, GetCategory, ItemCategory);
SIMPLE_GET_FUNC(Item, GetBattleCategory, BattleItemCategory);
SIMPLE_GET_FUNC(Item, GetPrice, i32);
export_func bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}