Adds Item registry to WASM.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
4d06a1cd04
commit
634ffce5f8
|
@ -0,0 +1,22 @@
|
||||||
|
#include "WASMItemRegistry.hpp"
|
||||||
|
#include "../../../../Battling/Library/BattleLibrary.hpp"
|
||||||
|
#include "../../WebAssemblyScriptResolver.hpp"
|
||||||
|
#include "../WASMHelperFile.hpp"
|
||||||
|
#include "wasm.h"
|
||||||
|
|
||||||
|
using namespace CreatureLib::Library;
|
||||||
|
|
||||||
|
wasm_func_t* Item_HasFlagByHash(WebAssemblyScriptResolver* resolver) {
|
||||||
|
return WasmHelpers::CreateFunc<bool, Item*, u32>(
|
||||||
|
resolver, {[](WebAssemblyScriptResolver*, Item* item, u32 flag) -> bool { return item->HasFlag(flag); }});
|
||||||
|
}
|
||||||
|
|
||||||
|
void WASMItemRegistry::Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
|
||||||
|
WebAssemblyScriptResolver* resolver) {
|
||||||
|
REGISTER_GETTER("item_get_name", Item, GetName, resolver)
|
||||||
|
REGISTER_GETTER("item_get_category", Item, GetCategory, resolver)
|
||||||
|
REGISTER_GETTER("item_get_battle_category", Item, GetBattleCategory, resolver)
|
||||||
|
REGISTER_GETTER("item_get_price", Item, GetPrice, resolver)
|
||||||
|
REGISTER_GETTER("item_get_fling_power", PkmnLib::Library::Item, GetFlingPower, resolver)
|
||||||
|
externs.Insert("item_has_flag_by_hash", Item_HasFlagByHash(resolver));
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef PKMNLIB_WASMITEMREGISTRY_H
|
||||||
|
#define PKMNLIB_WASMITEMREGISTRY_H
|
||||||
|
#include <Arbutils/Collections/Dictionary.hpp>
|
||||||
|
#include <wasm.h>
|
||||||
|
|
||||||
|
class WebAssemblyScriptResolver;
|
||||||
|
class WASMItemRegistry {
|
||||||
|
public:
|
||||||
|
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
|
||||||
|
WebAssemblyScriptResolver* resolver);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PKMNLIB_WASMITEMREGISTRY_H
|
|
@ -1,5 +1,4 @@
|
||||||
#include "WASMMoveDataRegistry.hpp"
|
#include "WASMMoveDataRegistry.hpp"
|
||||||
#include <type_traits>
|
|
||||||
#include "../../../../Battling/Library/BattleLibrary.hpp"
|
#include "../../../../Battling/Library/BattleLibrary.hpp"
|
||||||
#include "../../WebAssemblyScriptResolver.hpp"
|
#include "../../WebAssemblyScriptResolver.hpp"
|
||||||
#include "../WASMHelperFile.hpp"
|
#include "../WASMHelperFile.hpp"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Arbutils/Collections/Dictionary.hpp"
|
#include "Arbutils/Collections/Dictionary.hpp"
|
||||||
#include "Library/LibraryMethods.hpp"
|
#include "Library/LibraryMethods.hpp"
|
||||||
#include "Library/WASMMoveDataRegistry.hpp"
|
#include "Library/WASMMoveDataRegistry.hpp"
|
||||||
|
#include "Library/WASMItemRegistry.hpp"
|
||||||
#include "WASMCoreMethods.hpp"
|
#include "WASMCoreMethods.hpp"
|
||||||
#include "WASMStringView.hpp"
|
#include "WASMStringView.hpp"
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ public:
|
||||||
WASMStringView::Register(externs, resolver);
|
WASMStringView::Register(externs, resolver);
|
||||||
LibraryMethods::Register(externs, resolver);
|
LibraryMethods::Register(externs, resolver);
|
||||||
WASMMoveDataRegistry::Register(externs, resolver);
|
WASMMoveDataRegistry::Register(externs, resolver);
|
||||||
|
WASMItemRegistry::Register(externs, resolver);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -108,4 +108,16 @@ move_data_get_priority: function(move) -> s8
|
||||||
move_data_has_secondary_effect: function(move) -> bool
|
move_data_has_secondary_effect: function(move) -> bool
|
||||||
move_data_has_flag_by_hash: function(move, u32 hash) -> bool
|
move_data_has_flag_by_hash: function(move, u32 hash) -> bool
|
||||||
|
|
||||||
|
// Item class
|
||||||
|
enum ItemCategory {
|
||||||
|
Misc, Pokeball, Medicine, Berry, MoveLearner, FormeChanger, KeyItem, Mail
|
||||||
|
}
|
||||||
|
enum ItemBattleCategory {
|
||||||
|
None, Healing, StatusHealing, Pokeball, MiscBattleItem
|
||||||
|
}
|
||||||
|
item_get_name: function(item) -> const_string
|
||||||
|
item_get_category: function(item) -> ItemCategory
|
||||||
|
item_get_battle_category: function(item) -> ItemBattleCategory
|
||||||
|
item_get_price: function(item) -> s32
|
||||||
|
item_get_fling_power: function(item) -> u8
|
||||||
|
item_has_flag_by_hash: function(item, u32 hash) -> bool
|
Loading…
Reference in New Issue