Style fixes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-06-07 23:23:40 +02:00
parent e4b818c799
commit a05a9ac76d
33 changed files with 120 additions and 117 deletions

View File

@@ -95,7 +95,6 @@ float PkmnLib::Battling::DamageLibrary::GetStatModifier(CreatureLib::Battling::E
PKMN_HOOK(ModifyOffensiveStatValue, attack, attack, target, hit, &offensiveValue);
PKMN_HOOK(ModifyDefensiveStatValue, attack, attack, target, hit, &defensiveValue);
return offensiveValue / defensiveValue;
}
float PkmnLib::Battling::DamageLibrary::GetDamageModifier(CreatureLib::Battling::ExecutingAttack*,

View File

@@ -83,8 +83,7 @@ void PkmnLib::Battling::Pokemon::AttemptCapture(PkmnLib::Library::Item* catchIte
Ensure(_battleData.Side.HasValue());
Ensure(!IsFainted());
Ensure(IsUsable());
auto captureLibrary =
GetLibrary().ForceAs<const BattleLibrary>()->GetCaptureLibrary();
auto captureLibrary = GetLibrary().ForceAs<const BattleLibrary>()->GetCaptureLibrary();
auto result = captureLibrary->TryCatch(this, catchItem, _battleData.Battle.GetValue()->GetRandom());
_battleData.Battle.GetValue()->TriggerEventListener<CaptureAttemptEvent>(this, result);

View File

@@ -8,7 +8,7 @@ namespace PkmnLib::Battling {
public:
PokemonParty(ArbUt::List<CreatureLib::Battling::Creature * nullable> party)
: CreatureLib::Battling::CreatureParty(std::move(party)) {}
PokemonParty(std::initializer_list<CreatureLib::Battling::Creature* nullable> party)
PokemonParty(std::initializer_list<CreatureLib::Battling::Creature * nullable> party)
: CreatureLib::Battling::CreatureParty(party) {}
PokemonParty(size_t size) : CreatureLib::Battling::CreatureParty(size) {}

View File

@@ -11,8 +11,8 @@ namespace PkmnLib::Library {
MoveData(const ArbUt::StringView& name, u8 type, PkmnLib::Library::MoveCategory category, u8 power, u8 accuracy,
u8 baseUsage, CreatureLib::Library::AttackTarget target, i8 priority,
const CreatureLib::Library::SecondaryEffect* nullable effect, std::unordered_set<u32> flags)
: AttackData(name, type, static_cast<CreatureLib::Library::AttackCategory>(category), power, accuracy, baseUsage,
target, priority, effect, std::move(flags)) {};
: AttackData(name, type, static_cast<CreatureLib::Library::AttackCategory>(category), power, accuracy,
baseUsage, target, priority, effect, std::move(flags)){};
inline PkmnLib::Library::MoveCategory GetCategory() const {
return static_cast<PkmnLib::Library::MoveCategory>(AttackData::GetCategory());

View File

@@ -25,9 +25,7 @@ namespace PkmnLib::Library {
return _items.Get(name);
}
inline ArbUt::BorrowedPtr<const Nature> GetNatureByHash(u32 hash) const {
return _items.GetFromHash(hash);
}
inline ArbUt::BorrowedPtr<const Nature> GetNatureByHash(u32 hash) const { return _items.GetFromHash(hash); }
inline const ArbUt::StringView& GetRandomNatureName(ArbUt::Random rand = ArbUt::Random()) const {
auto i = rand.Get(_items.Count());

View File

@@ -7,7 +7,7 @@ namespace PkmnLib::Library {
return tryGet->get();
}
for (const auto& s : _values) {
const auto* pkmn = dynamic_cast<const PokemonSpecies* nullable>(s.second.get());
const auto* pkmn = dynamic_cast<const PokemonSpecies * nullable>(s.second.get());
if (pkmn == nullptr) {
continue;
}

View File

@@ -33,9 +33,7 @@ namespace PkmnLib::Library {
return CreatureLib::Library::SpeciesLibrary::GetByHash(hashedKey).As<const PokemonSpecies>();
}
ArbUt::BorrowedPtr<const PokemonSpecies> operator[](const ArbUt::StringView& name) const {
return Get(name);
}
ArbUt::BorrowedPtr<const PokemonSpecies> operator[](const ArbUt::StringView& name) const { return Get(name); }
std::optional<ArbUt::BorrowedPtr<const PokemonSpecies>>
FindPreEvolution(const ArbUt::BorrowedPtr<const PokemonSpecies>& species) const noexcept;

View File

@@ -72,8 +72,7 @@ private:
#define ITEM_USE_SCRIPT_HOOK_FUNCTION(name, decl) FunctionInfo __##name = Initialize(decl)
ITEM_USE_SCRIPT_HOOK_FUNCTION(
OnInitialize, "void OnInitialize(const narray<EffectParameter@>@ parameters)");
ITEM_USE_SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const narray<EffectParameter@>@ parameters)");
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsItemUsable, "bool IsItemUsable()");
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsPokemonUseItem, "bool IsPokemonUseItem()");
ITEM_USE_SCRIPT_HOOK_FUNCTION(IsUseValidForPokemon, "bool IsUseValidForPokemon(Pokemon@ target)");

View File

@@ -13,10 +13,11 @@ protected:
IPkmnBinaryStream(size_t angelScriptBound) : _angelScriptBound(angelScriptBound) {}
public:
virtual void WriteTypes(
const ArbUt::Dictionary<ScriptCategory, ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo* non_null>>& types,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo* non_null>& itemUseTypes,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo* non_null>& evolutionTypes) {
virtual void
WriteTypes(const ArbUt::Dictionary<ScriptCategory,
ArbUt::Dictionary<ArbUt::StringView, AngelScriptTypeInfo * non_null>>& types,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo * non_null>& itemUseTypes,
const ArbUt::Dictionary<ArbUt::StringView, asITypeInfo * non_null>& evolutionTypes) {
// We serialize our types in the format
// "[category(byte)][name(str)]\2[decl(str)]\2[name(str)]\2[decl(str)]\1[category(byte)]...."

View File

@@ -26,7 +26,6 @@ static bool GetMove(const PkmnLib::Library::MoveLibrary* obj, const ArbUt::Basic
return obj->Get(str);
}
void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("MoveData", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
@@ -51,7 +50,7 @@ void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("MoveLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ Get(const constString &in name) const",
asFUNCTION(GetMove), asCALL_CDECL_OBJFIRST);
asFUNCTION(GetMove), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
}

View File

@@ -6,8 +6,7 @@
class WebAssemblyScriptResolver;
class LibraryMethods {
public:
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver);
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs, WebAssemblyScriptResolver* resolver);
};
#endif // PKMNLIB_LIBRARYMETHODS_H

View File

@@ -6,8 +6,7 @@
class WebAssemblyScriptResolver;
class WASMItemRegistry {
public:
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver);
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs, WebAssemblyScriptResolver* resolver);
};
#endif // PKMNLIB_WASMITEMREGISTRY_H

View File

@@ -8,9 +8,7 @@ using namespace CreatureLib::Library;
wasm_func_t* MoveData_HasFlagByHash(WebAssemblyScriptResolver* resolver) {
return WasmHelpers::CreateFunc<bool, AttackData*, u32>(
resolver, {[](WebAssemblyScriptResolver*, AttackData* move, u32 flag) -> bool {
return move->HasFlag(flag);
}});
resolver, {[](WebAssemblyScriptResolver*, AttackData* move, u32 flag) -> bool { return move->HasFlag(flag); }});
}
void WASMMoveDataRegistry::Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,

View File

@@ -7,8 +7,7 @@
class WebAssemblyScriptResolver;
class WASMMoveDataRegistry {
public:
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver);
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs, WebAssemblyScriptResolver* resolver);
};
#endif // PKMNLIB_WASMMOVEDATAREGISTRY_H

View File

@@ -37,7 +37,6 @@ wasm_func_t* Species_HasEggGroupByHash(WebAssemblyScriptResolver* resolver) {
}});
}
void WASMSpeciesRegistry::Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver) {
REGISTER_GETTER("species_get_id", CreatureSpecies, GetId, resolver)

View File

@@ -7,8 +7,7 @@ class WebAssemblyScriptResolver;
class WASMSpeciesRegistry {
public:
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver);
static void Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs, WebAssemblyScriptResolver* resolver);
};
#endif // PKMNLIB_WASMSPECIESREGISTRY_HPP

View File

@@ -39,7 +39,7 @@ wasm_func_t* CreatePrintFunc(WebAssemblyScriptResolver* resolver) {
}
void WASMCoreMethods::Register(ArbUt::Dictionary<std::string, wasm_func_t*>& externs,
WebAssemblyScriptResolver* resolver) {
WebAssemblyScriptResolver* resolver) {
externs.Insert("_error", CreateErrorFunc(resolver));
externs.Insert("_print", CreatePrintFunc(resolver));
}

View File

@@ -6,6 +6,7 @@ public:
WasmExternRef(T* ptr) : _ptr(ptr) {}
[[nodiscard]] inline T* GetPtr() const noexcept { return _ptr; }
private:
T* _ptr;
};