Update to newer Arbutils version.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-05-26 18:31:06 +02:00
parent d746b3ecce
commit 25f65eb47b
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
68 changed files with 334 additions and 354 deletions

View File

@ -5,13 +5,13 @@ using namespace CreatureLib::Battling;
export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
size_t numberOfParties, bool canFlee, uint8_t numberOfSides,
uint8_t creaturesPerSide) {
Try(List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide);)
}
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary(); }
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
export uint8_t CreatureLib_Battle_CanUse(bool& out, Battle* p, const BaseTurnChoice* turnChoice) {
Try(out = p->CanUse(turnChoice);)
}
@ -49,7 +49,9 @@ export size_t CreatureLib_Battle_GetSidesCount(const Battle* p) { return p->GetS
export BattleSide* const* CreatureLib_Battle_GetSides(const Battle* p) { return p->GetSides().RawData(); }
export size_t CreatureLib_Battle_GetPartiesCount(const Battle* p) { return p->GetParties().Count(); }
export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) { return p->GetParties().RawData(); }
export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
return reinterpret_cast<BattleParty* const*>(p->GetParties().RawData());
}
export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
return p->GetVolatileScript(ConstString::GetHash(key));

View File

@ -6,10 +6,9 @@ using namespace CreatureLib::Battling;
// side, one after the other.
export uint8_t CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, uint8_t creatureIndices[],
size_t numberOfIndices) {
Try(Arbutils::Collections::List<CreatureIndex> indices(numberOfIndices);
for (size_t i = 0; i < numberOfIndices; i++) {
indices[i] = CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]);
} out = new BattleParty(p, indices);)
Try(ArbUt::List<CreatureIndex> indices(numberOfIndices); for (size_t i = 0; i < numberOfIndices; i++) {
indices[i] = CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]);
} out = new BattleParty(p, indices);)
}
export void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }

View File

@ -1,7 +1,6 @@
#include "../../src/Battling/Models/Creature.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Battling;
using ConstString = Arbutils::CaseInsensitiveConstString;
export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
const CreatureLib::Library::CreatureSpecies* species,
@ -10,11 +9,11 @@ export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrar
uint8_t coloring, const CreatureLib::Library::Item* heldItem,
const char* nickname, bool secretTalent, uint8_t talent,
LearnedAttack* attacks[], size_t attacksNum, bool allowedExperienceGain) {
Try(auto attacksVec = List<LearnedAttack*>(attacks, attacks + attacksNum);
out = new Creature(library, borrowed_ptr<const CreatureLib::Library::CreatureSpecies>(species), variant, level,
experience, uid, gender, coloring, borrowed_ptr<const CreatureLib::Library::Item>(heldItem),
nickname, CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec,
allowedExperienceGain);)
Try(auto attacksVec = ArbUt::List<LearnedAttack*>(attacks, attacks + attacksNum);
out = new Creature(library, ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species), variant,
level, experience, uid, gender, coloring,
ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(heldItem), nickname,
CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec, allowedExperienceGain);)
};
export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
@ -32,16 +31,16 @@ SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
SIMPLE_GET_FUNC(Creature, GetColoring, uint8_t);
export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
return p->HasHeldItem(ConstString(name));
return p->HasHeldItem(ArbUt::CaseInsensitiveConstString(name));
}
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetHeldItem, const CreatureLib::Library::Item*);
export uint8_t CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
Try(p->SetHeldItem(ConstString(name));)
Try(p->SetHeldItem(ArbUt::CaseInsensitiveConstString(name));)
}
export uint8_t CreatureLib_Creature_SetHeldItemWithHash(Creature* p, uint32_t hash) { Try(p->SetHeldItem(hash);) }
export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
return p->SetHeldItem(borrowed_ptr<const CreatureLib::Library::Item>(item));
return p->SetHeldItem(ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(item));
}
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
SIMPLE_GET_FUNC(Creature, GetBattle, Battle*);
@ -60,33 +59,33 @@ export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canR
Try(p->Heal(health, canRevive);)
}
export uint8_t CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
Try(p->OverrideActiveTalent(ConstString(talent));)
Try(p->OverrideActiveTalent(ArbUt::CaseInsensitiveConstString(talent));)
}
export uint8_t CreatureLib_Creature_AddExperience(Creature* p, uint32_t experience) {
Try(p->AddExperience(experience);)
}
export uint8_t CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
export uint8_t CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->AddVolatileScript(ConstString(scriptName));)
Try(p->AddVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));)
}
export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, Script* script) {
Try(p->AddVolatileScript(script);)
}
export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->RemoveVolatileScript(ConstString(scriptName));)
Try(p->RemoveVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));)
}
export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, Script* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
return p->HasVolatileScript(ConstString(scriptName));
return p->HasVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));
}
export size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
export LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { return p->GetAttacks().RawData(); }
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetDisplaySpecies, const CreatureLib::Library::CreatureSpecies*);
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetDisplayVariant, const CreatureLib::Library::SpeciesVariant*);
export void CreatureLib_Creature_SetDisplaySpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species) {
return p->SetDisplaySpecies(borrowed_ptr<const CreatureLib::Library::CreatureSpecies>(species));
return p->SetDisplaySpecies(ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species));
}
export void CreatureLib_Creature_SetDisplayVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
return p->SetDisplayVariant(variant);

View File

@ -4,7 +4,7 @@ using namespace CreatureLib::Battling;
export CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); }
export CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* creatures[], size_t size) {
return new CreatureParty(Arbutils::Collections::List<Creature*>(creatures, creatures + size));
return new CreatureParty(ArbUt::List<Creature*>(creatures, creatures + size));
}
export void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }

View File

@ -5,7 +5,7 @@ using namespace CreatureLib::Battling;
export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, uint8_t numberHits, Creature* user,
LearnedAttack* attack, Script* script) {
Try(auto ls = List<Creature*>(targets, targets + targetCount);
Try(auto ls = ArbUt::List<Creature*>(targets, targets + targetCount);
out = new ExecutingAttack(ls, numberHits, user, attack, script);)
}

View File

@ -4,7 +4,8 @@ using namespace CreatureLib::Battling;
export uint8_t CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
uint8_t maxUses, AttackLearnMethod learnMethod) {
Try(out = new LearnedAttack(borrowed_ptr<const CreatureLib::Library::AttackData>(attack), maxUses, learnMethod);)
Try(out = new LearnedAttack(ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>(attack), maxUses,
learnMethod);)
}
export void CreatureLib_LearnedAttack_Destruct(LearnedAttack* p) { delete p; }

View File

@ -11,7 +11,8 @@ export const char* CreatureLib_Script_GetName(Script* p) { return p->GetName().c
export uint8_t CreatureLib_Script_OnBeforeTurn(Script* p, const BaseTurnChoice* choice) {
Try(p->OnBeforeTurn(choice));
}
export uint8_t CreatureLib_Script_ChangeAttack(Script* p, AttackTurnChoice* choice, ConstString* outAttack) {
export uint8_t CreatureLib_Script_ChangeAttack(Script* p, AttackTurnChoice* choice,
ArbUt::CaseInsensitiveConstString* outAttack) {
Try(p->ChangeAttack(choice, outAttack));
}
export uint8_t CreatureLib_Script_PreventAttack(Script* p, ExecutingAttack* attack, bool* outResult) {

View File

@ -11,5 +11,5 @@ export uint8_t CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLi
};
export uint8_t CreatureLib_ScriptResolver_LoadScript(Script*& out, ScriptResolver* p, ScriptCategory category,
const char* scriptName) {
Try(out = p->LoadScript(category, ConstString(scriptName));)
Try(out = p->LoadScript(category, ArbUt::CaseInsensitiveConstString(scriptName));)
};

View File

@ -11,18 +11,18 @@ export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* na
Try({
std::unordered_set<uint32_t> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ConstString::GetHash(flags[i]));
conversedFlags.insert(ArbUt::CaseInsensitiveConstString::GetHash(flags[i]));
}
Arbutils::Collections::List<EffectParameter*> effectParameterList(effectParameterCount);
ArbUt::List<EffectParameter*> effectParameterList(effectParameterCount);
for (size_t i = 0; i < effectParameterCount; i++) {
effectParameterList[i] = effectParameters[i];
}
auto effect =
new SecondaryEffect(effectChance, Arbutils::CaseInsensitiveConstString(effectName), effectParameterList);
new SecondaryEffect(effectChance, ArbUt::CaseInsensitiveConstString(effectName), effectParameterList);
out = new AttackData(ConstString(name), type, category, power, accuracy, baseUsage, target, priority, effect,
conversedFlags);
out = new AttackData(ArbUt::CaseInsensitiveConstString(name), type, category, power, accuracy, baseUsage,
target, priority, effect, conversedFlags);
})
};
@ -51,7 +51,7 @@ export const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackDat
}
export bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
return p->HasFlag(ConstString::GetHash(key));
return p->HasFlag(ArbUt::CaseInsensitiveConstString::GetHash(key));
}
#undef SIMPLE_GET_FUNC

View File

@ -2,7 +2,7 @@
#define BASELIBRARY(simpleName, fullname, returnType) \
export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
Try(p->Insert(Arbutils::CaseInsensitiveConstString::GetHash(name), t);) \
Try(p->Insert(ArbUt::CaseInsensitiveConstString::GetHash(name), t);) \
} \
\
export uint8_t simpleName##_InsertWithHash(fullname* p, uint32_t hashedKey, returnType* t) { \
@ -10,27 +10,27 @@
} \
\
export uint8_t simpleName##_Delete(fullname* p, const char* name) { \
Try(p->Delete(Arbutils::CaseInsensitiveConstString::GetHash(name));) \
Try(p->Delete(ArbUt::CaseInsensitiveConstString::GetHash(name));) \
} \
\
export uint8_t simpleName##_DeleteWithHash(fullname* p, uint32_t hashedKey) { Try(p->Delete(hashedKey);) } \
\
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
borrowed_ptr<const returnType> o; \
auto v = p->TryGet(Arbutils::CaseInsensitiveConstString::GetHash(name), o); \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(ArbUt::CaseInsensitiveConstString::GetHash(name), o); \
out = o.operator->(); \
return v; \
} \
\
export bool simpleName##_TryGetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \
borrowed_ptr<const returnType> o; \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(hashedKey, o); \
out = o.operator->(); \
return v; \
} \
\
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
Try(out = p->Get(Arbutils::CaseInsensitiveConstString::GetHash(name)).operator->();) \
Try(out = p->Get(ArbUt::CaseInsensitiveConstString::GetHash(name)).operator->();) \
} \
\
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \

View File

@ -6,8 +6,8 @@ export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint
SpeciesVariant* defaultVariant, float genderRatio,
const char* growthRate, uint8_t captureRate) {
Try(out = new CreatureSpecies(id, Arbutils::CaseInsensitiveConstString(name), defaultVariant, genderRatio,
Arbutils::CaseInsensitiveConstString(growthRate), captureRate);)
Try(out = new CreatureSpecies(id, ArbUt::CaseInsensitiveConstString(name), defaultVariant, genderRatio,
ArbUt::CaseInsensitiveConstString(growthRate), captureRate);)
}
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
@ -23,21 +23,21 @@ export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpeci
return p->GetGrowthRate().c_str();
}
export bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
return p->HasVariant(Arbutils::CaseInsensitiveConstString::GetHash(name));
return p->HasVariant(ArbUt::CaseInsensitiveConstString::GetHash(name));
}
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, uint32_t hash) {
return p->HasVariant(hash);
}
export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
const SpeciesVariant*& out) {
borrowed_ptr<const SpeciesVariant> o;
auto res = p->TryGetVariant(Arbutils::CaseInsensitiveConstString::GetHash(name), o);
ArbUt::BorrowedPtr<const SpeciesVariant> o;
auto res = p->TryGetVariant(ArbUt::CaseInsensitiveConstString::GetHash(name), o);
out = o.GetRaw();
return res;
}
export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, uint32_t hash,
const SpeciesVariant*& out) {
borrowed_ptr<const SpeciesVariant> o;
ArbUt::BorrowedPtr<const SpeciesVariant> o;
auto res = p->TryGetVariant(hash, o);
out = o.GetRaw();
return res;
@ -45,14 +45,14 @@ export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpec
export uint8_t CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
const char* name) {
Try(out = p->GetVariant(Arbutils::CaseInsensitiveConstString::GetHash(name)).GetRaw();)
Try(out = p->GetVariant(ArbUt::CaseInsensitiveConstString::GetHash(name)).GetRaw();)
}
export uint8_t CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant* out, const CreatureSpecies* p,
uint32_t hash) {
Try(out = p->GetVariant(hash).GetRaw();)
}
export uint8_t CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
Try(p->SetVariant(Arbutils::CaseInsensitiveConstString(name), variant);)
Try(p->SetVariant(ArbUt::CaseInsensitiveConstString(name), variant);)
}
#undef SIMPLE_GET_FUNC

View File

@ -6,7 +6,7 @@ export EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return ne
export EffectParameter* CreatureLib_EffectParameter_FromInt(int64_t i) { return new EffectParameter(i); }
export EffectParameter* CreatureLib_EffectParameter_FromFloat(float f) { return new EffectParameter(f); }
export EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
return new EffectParameter(Arbutils::CaseInsensitiveConstString(c));
return new EffectParameter(ArbUt::CaseInsensitiveConstString(c));
}
export void CreatureLib_EffectParameter_Destruct(const EffectParameter* p) { delete p; }

View File

@ -5,7 +5,7 @@
using namespace CreatureLib::Library;
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePerLevel[], size_t count) {
Arbutils::Collections::List<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
ArbUt::List<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
return new LookupGrowthRate(exp);
};

View File

@ -10,7 +10,7 @@ export void CreatureLib_GrowthRateLibrary_Destruct(GrowthRateLibrary* p) { delet
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevel(uint8_t& out, GrowthRateLibrary* library,
const char* growthRate, uint32_t experience) {
Try(out = library->CalculateLevel(Arbutils::CaseInsensitiveConstString::GetHash(growthRate), experience);)
Try(out = library->CalculateLevel(ArbUt::CaseInsensitiveConstString::GetHash(growthRate), experience);)
}
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(uint8_t& out, GrowthRateLibrary* library,
uint32_t growthRateHash, uint32_t experience) {
@ -19,7 +19,7 @@ export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(uint8_t& out
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperience(uint32_t& out, GrowthRateLibrary* library,
const char* growthRate, uint8_t level) {
Try(out = library->CalculateExperience(Arbutils::CaseInsensitiveConstString::GetHash(growthRate), level);)
Try(out = library->CalculateExperience(ArbUt::CaseInsensitiveConstString::GetHash(growthRate), level);)
}
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(uint32_t& out, GrowthRateLibrary* library,
@ -28,7 +28,7 @@ export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(uint32_
}
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
GrowthRate* growthRate) {
Try(library->AddGrowthRate(Arbutils::CaseInsensitiveConstString::GetHash(growthRateName), growthRate);)
Try(library->AddGrowthRate(ArbUt::CaseInsensitiveConstString::GetHash(growthRateName), growthRate);)
}
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, uint32_t growthRateHash,

View File

@ -1,7 +1,7 @@
#include "../../src/Library/Items/Item.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
using ConstString = Arbutils::CaseInsensitiveConstString;
using ConstString = ArbUt::CaseInsensitiveConstString;
export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
int32_t price, const char* flags[], size_t flagsCount) {

View File

@ -2,7 +2,6 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
using ConstString = Arbutils::CaseInsensitiveConstString;
export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
const char* name, float height, float weight, uint32_t baseExperience, uint8_t types[], size_t typeLength,
@ -10,17 +9,17 @@ export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
uint16_t baseMagicalDefense, uint16_t baseSpeed, const char* talents[], size_t talentsLength,
const char* secretTalents[], size_t secretTalentsLength, const LearnableAttacks* attacks) {
auto talentsWrapped = Arbutils::Collections::List<ConstString>(talentsLength);
auto talentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(talentsLength);
for (size_t i = 0; i < talentsLength; i++) {
talentsWrapped.Append(ConstString(talents[i]));
talentsWrapped.Append(ArbUt::CaseInsensitiveConstString(talents[i]));
}
auto secretTalentsWrapped = Arbutils::Collections::List<ConstString>(secretTalentsLength);
auto secretTalentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(secretTalentsLength);
for (size_t i = 0; i < secretTalentsLength; i++) {
secretTalentsWrapped.Append(ConstString(secretTalents[i]));
secretTalentsWrapped.Append(ArbUt::CaseInsensitiveConstString(secretTalents[i]));
}
return new SpeciesVariant(Arbutils::CaseInsensitiveConstString(name), height, weight, baseExperience,
Arbutils::Collections::List<uint8_t>(types, types + typeLength),
return new SpeciesVariant(ArbUt::CaseInsensitiveConstString(name), height, weight, baseExperience,
ArbUt::List<uint8_t>(types, types + typeLength),
CreatureLib::Library::StatisticSet<uint16_t>(baseHealth, baseAttack, baseDefense,
baseMagicalAttack, baseMagicalDefense,
baseSpeed),

View File

@ -9,14 +9,14 @@ export TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
export void CreatureLib_TypeLibrary_Destruct(const TypeLibrary* p) { delete p; }
export uint8_t CreatureLib_TypeLibrary_GetTypeId(uint8_t& out, const TypeLibrary* p, const char* type) {
Try(out = p->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(type));)
Try(out = p->GetTypeId(ArbUt::CaseInsensitiveConstString::GetHash(type));)
}
export uint8_t CreatureLib_TypeLibrary_GetTypeIdWithHash(uint8_t& out, const TypeLibrary* p, uint32_t type) {
Try(out = p->GetTypeId(type);)
}
export uint8_t CreatureLib_TypeLibrary_RegisterType(uint8_t& out, TypeLibrary* p, const char* type) {
Try(out = p->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(type));)
Try(out = p->RegisterType(ArbUt::CaseInsensitiveConstString::GetHash(type));)
}
export uint8_t CreatureLib_TypeLibrary_RegisterTypeWithHash(uint8_t& out, TypeLibrary* p, uint32_t type) {
Try(out = p->RegisterType(type);)
@ -34,5 +34,5 @@ export uint8_t CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLi
export uint8_t CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, uint8_t attacking,
uint8_t defensive[], size_t defensiveCount) {
Try(out = p->GetEffectiveness(attacking, List<uint8_t>(defensive, defensive + defensiveCount));)
Try(out = p->GetEffectiveness(attacking, ArbUt::List<uint8_t>(defensive, defensive + defensiveCount));)
}

View File

@ -60,7 +60,7 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
// FIXME: Resolve all targets
auto target = choice->GetUser()->GetBattle()->GetCreature(choice->GetTarget());
Arbutils::Collections::List<Creature*> targets = {target};
ArbUt::List<Creature*> targets = {target};
auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
bool prevented = false;

View File

@ -29,6 +29,6 @@ public:
}
};
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand) {
void TurnOrdering::OrderChoices(std::vector<BaseTurnChoice*>& vec, ArbUt::Random& rand) {
std::sort(vec.begin(), vec.end(), ChoiceCompare());
}

View File

@ -8,7 +8,7 @@
namespace CreatureLib::Battling {
class TurnOrdering {
public:
static void OrderChoices(std::vector<BaseTurnChoice*>& vec, Arbutils::Random& rand);
static void OrderChoices(std::vector<BaseTurnChoice*>& vec, ArbUt::Random& rand);
};
}

View File

@ -43,7 +43,6 @@ const std::unique_ptr<const DamageLibrary>& BattleLibrary::GetDamageLibrary() co
const std::unique_ptr<const MiscLibrary>& BattleLibrary::GetMiscLibrary() const noexcept { return _miscLibrary; }
Script* BattleLibrary::LoadScript(ScriptCategory category,
const Arbutils::CaseInsensitiveConstString& scriptName) const {
Script* BattleLibrary::LoadScript(ScriptCategory category, const ArbUt::CaseInsensitiveConstString& scriptName) const {
return _scriptResolver->LoadScript(category, scriptName);
}

View File

@ -42,7 +42,7 @@ namespace CreatureLib::Battling {
}
[[nodiscard]] Script* LoadScript(ScriptCategory category,
const Arbutils::CaseInsensitiveConstString& scriptName) const;
const ArbUt::CaseInsensitiveConstString& scriptName) const;
};
}

View File

@ -13,7 +13,7 @@ bool CreatureLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::Execu
static CreatureLib::Battling::LearnedAttack* _replacementAttack = nullptr;
static std::unique_ptr<const CreatureLib::Library::AttackData> _replacementAttackData = nullptr;
static borrowed_ptr<const CreatureLib::Library::AttackData> GetReplacementAttackData() {
static ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData> GetReplacementAttackData() {
if (_replacementAttackData == nullptr) {
_replacementAttackData =
std::unique_ptr<const CreatureLib::Library::AttackData>(new CreatureLib::Library::AttackData(

View File

@ -7,7 +7,7 @@
using namespace CreatureLib;
using namespace CreatureLib::Battling;
const BattleLibrary* Battle::GetLibrary() const noexcept { return _library; }
const ArbUt::BorrowedPtr<const BattleLibrary>& Battle::GetLibrary() const noexcept { return _library; }
bool Battle::CanUse(const BaseTurnChoice* choice) {
AssertNotNull(choice)
@ -86,7 +86,7 @@ bool Battle::CreatureInField(const Creature* creature) const {
void Battle::ForceRecall(uint8_t side, uint8_t index) { _sides[side]->SetCreature(nullptr, index); }
size_t Battle::ScriptCount() const { return 1; }
void Battle::GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) {
void Battle::GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) {
scripts.Append(ScriptWrapper::FromSet(&_volatile));
}

View File

@ -3,6 +3,7 @@
#include <Arbutils/Assert.hpp>
#include <Arbutils/Collections/List.hpp>
#include <memory>
#include "../EventHooks/EventHook.hpp"
#include "../Flow/ChoiceQueue.hpp"
#include "../Library/BattleLibrary.hpp"
@ -13,17 +14,15 @@
#include "BattleSide.hpp"
#include "CreatureIndex.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class Battle : public ScriptSource {
protected:
const BattleLibrary* _library;
List<BattleParty*> _parties;
ArbUt::BorrowedPtr<const BattleLibrary> _library;
ArbUt::List<std::unique_ptr<BattleParty>> _parties;
bool _canFlee;
uint8_t _numberOfSides;
uint8_t _creaturesPerSide;
List<BattleSide*> _sides;
ArbUt::List<BattleSide*> _sides;
BattleRandom _random;
ChoiceQueue* _currentTurnQueue = nullptr;
bool _hasEnded = false;
@ -34,14 +33,17 @@ namespace CreatureLib::Battling {
ScriptSet _volatile;
public:
Battle(const BattleLibrary* library, List<BattleParty*> parties, bool canFlee = true, uint8_t numberOfSides = 2,
uint8_t creaturesPerSide = 1)
: _library(library), _parties(std::move(parties)), _canFlee(canFlee), _numberOfSides(numberOfSides),
Battle(const BattleLibrary* library, ArbUt::List<BattleParty*> parties, bool canFlee = true,
uint8_t numberOfSides = 2, uint8_t creaturesPerSide = 1)
: _library(library), _parties(parties.Count()), _canFlee(canFlee), _numberOfSides(numberOfSides),
_creaturesPerSide(creaturesPerSide) {
AssertNotNull(_library);
AssertAllNotNull(parties);
for (size_t i = 0; i < parties.Count(); i++) {
_parties.GetStdList().push_back(std::unique_ptr<BattleParty>(parties[i]));
}
_sides = List<BattleSide*>(numberOfSides);
_sides = ArbUt::List<BattleSide*>(numberOfSides);
for (size_t i = 0; i < numberOfSides; i++) {
_sides.Append(new BattleSide(i, this, creaturesPerSide));
}
@ -51,13 +53,10 @@ namespace CreatureLib::Battling {
for (auto s : _sides) {
delete s;
}
for (auto party : _parties) {
delete party;
}
delete _currentTurnQueue;
}
[[nodiscard]] const BattleLibrary* GetLibrary() const noexcept;
[[nodiscard]] const ArbUt::BorrowedPtr<const BattleLibrary>& GetLibrary() const noexcept;
[[nodiscard]] uint32_t GetCurrentTurn() const noexcept { return _currentTurn; }
virtual bool CanUse(const BaseTurnChoice* choice);
@ -82,14 +81,14 @@ namespace CreatureLib::Battling {
bool CanSlotBeFilled(uint8_t side, uint8_t index) const;
size_t ScriptCount() const override;
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override;
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override;
void ValidateBattleState();
inline bool HasEnded() const noexcept { return _hasEnded; }
inline const BattleResult& GetResult() const noexcept { return _battleResult; }
const List<BattleParty*>& GetParties() const noexcept { return _parties; }
const List<BattleSide*>& GetSides() const noexcept { return _sides; }
const ArbUt::List<std::unique_ptr<BattleParty>>& GetParties() const noexcept { return _parties; }
const ArbUt::List<BattleSide*>& GetSides() const noexcept { return _sides; }
Script* GetVolatileScript(const ConstString& key) const { return _volatile.Get(key); }
Script* GetVolatileScript(uint32_t keyHash) const noexcept { return _volatile.Get(keyHash); }
void AddVolatileScript(const ConstString& key);

View File

@ -6,21 +6,19 @@
#include "CreatureIndex.hpp"
#include "CreatureParty.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class BattleParty {
CreatureParty* _party;
List<CreatureIndex> _responsibleIndices;
ArbUt::List<CreatureIndex> _responsibleIndices;
public:
BattleParty(CreatureParty* party, const List<CreatureIndex>& responsibleIndices)
BattleParty(CreatureParty* party, const ArbUt::List<CreatureIndex>& responsibleIndices)
: _party(party), _responsibleIndices(responsibleIndices) {
AssertNotNull(_party)
}
inline CreatureParty* GetParty() const { return _party; }
inline const List<CreatureIndex>& GetResponsibleIndices() const { return _responsibleIndices; }
inline const ArbUt::List<CreatureIndex>& GetResponsibleIndices() const { return _responsibleIndices; }
inline bool IsResponsibleForIndex(const CreatureIndex& index) const {
return _responsibleIndices.Contains(index);

View File

@ -9,7 +9,7 @@ namespace CreatureLib::Battling {
class BattleRandom {
private:
Arbutils::Random _random;
ArbUt::Random _random;
public:
BattleRandom() noexcept : _random() {}
@ -19,7 +19,7 @@ namespace CreatureLib::Battling {
int32_t Get() noexcept { return _random.Get(); }
int32_t Get(int32_t max) noexcept { return _random.Get(max); }
int32_t Get(int32_t min, int32_t max) noexcept { return _random.Get(min, max); }
Arbutils::Random& GetRNG() noexcept { return _random; }
ArbUt::Random& GetRNG() noexcept { return _random; }
uint_fast32_t GetSeed() const noexcept { return _random.GetSeed(); }
};
}

View File

@ -26,7 +26,7 @@ void BattleSide::ResetChoices() noexcept {
}
}
const List<BaseTurnChoice*>& BattleSide::GetChoices() const noexcept { return _choices; }
const ArbUt::List<BaseTurnChoice*>& BattleSide::GetChoices() const noexcept { return _choices; }
void BattleSide::SetChoice(BaseTurnChoice* choice) {
AssertNotNull(choice)
@ -69,7 +69,7 @@ bool BattleSide::CreatureOnSide(const Creature* creature) const {
Creature* BattleSide::GetCreature(uint8_t index) const { return _creatures[index]; }
void BattleSide::GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) {
void BattleSide::GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) {
scripts.Append(ScriptWrapper::FromSet(&_volatile));
_battle->GetActiveScripts(scripts);
}

View File

@ -7,15 +7,13 @@
#include "../TurnChoices/BaseTurnChoice.hpp"
#include "Creature.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class BattleSide : public ScriptSource {
uint8_t _index;
uint8_t _creaturesPerSide;
List<Creature*> _creatures;
List<BaseTurnChoice*> _choices;
List<bool> _fillableSlots;
ArbUt::List<Creature*> _creatures;
ArbUt::List<BaseTurnChoice*> _choices;
ArbUt::List<bool> _fillableSlots;
uint8_t _choicesSet = 0;
ScriptSet _volatile;
Battle* _battle;
@ -36,7 +34,7 @@ namespace CreatureLib::Battling {
virtual ~BattleSide() = default;
[[nodiscard]] bool AllChoicesSet() const noexcept;
[[nodiscard]] const List<BaseTurnChoice*>& GetChoices() const noexcept;
[[nodiscard]] const ArbUt::List<BaseTurnChoice*>& GetChoices() const noexcept;
[[nodiscard]] bool AllPossibleSlotsFilled() const;
@ -49,9 +47,9 @@ namespace CreatureLib::Battling {
bool CreatureOnSide(const Creature* creature) const;
size_t ScriptCount() const override;
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override;
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override;
const List<Creature*>& GetCreatures() { return _creatures; }
const ArbUt::List<Creature*>& GetCreatures() { return _creatures; }
uint8_t GetSideIndex() noexcept { return _index; }
uint8_t GetCreatureIndex(Creature* c) {

View File

@ -5,7 +5,7 @@
using namespace CreatureLib::Battling;
CreateCreature CreateCreature::WithVariant(const Arbutils::CaseInsensitiveConstString& variant) {
CreateCreature CreateCreature::WithVariant(const ArbUt::CaseInsensitiveConstString& variant) {
this->_variant = variant;
return *this;
}
@ -20,7 +20,7 @@ CreateCreature CreateCreature::WithGender(Library::Gender gender) {
return *this;
}
CreateCreature CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
CreateCreature CreateCreature::WithAttack(const ArbUt::CaseInsensitiveConstString& attackName,
AttackLearnMethod learnMethod) {
if (_attacks.Count() >= _library->GetSettings()->GetMaximalMoves())
throw CreatureException("You have already set the maximum amount of allowed moves.");
@ -31,7 +31,7 @@ CreateCreature CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstSt
}
Creature* CreateCreature::Create() {
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
auto species = this->_library->GetSpeciesLibrary()->Get(this->_species.GetHash());
auto variant = species->GetVariant(this->_variant);
Library::TalentIndex talent;
@ -48,7 +48,7 @@ Creature* CreateCreature::Create() {
if (gender == static_cast<Library::Gender>(-1)) {
gender = species->GetRandomGender(rand);
}
borrowed_ptr<const Library::Item> heldItem;
ArbUt::BorrowedPtr<const Library::Item> heldItem;
if (!this->_heldItem.Empty()) {
if (!_library->GetItemLibrary()->TryGet(this->_heldItem.GetHash(), heldItem)) {
throw CreatureException("Invalid held item.");
@ -56,7 +56,7 @@ Creature* CreateCreature::Create() {
}
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
auto attacks = List<LearnedAttack*>(_attacks.Count());
auto attacks = ArbUt::List<LearnedAttack*>(_attacks.Count());
for (size_t i = 0; i < _attacks.Count(); i++) {
auto kv = _attacks[i];
attacks.Append(new LearnedAttack(std::get<0>(kv), std::get<1>(kv)));

View File

@ -6,33 +6,30 @@
#include "../Library/BattleLibrary.hpp"
#include "Creature.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class CreateCreature {
const BattleLibrary* _library;
Arbutils::CaseInsensitiveConstString _species;
Arbutils::CaseInsensitiveConstString _variant = "default"_cnc;
ArbUt::CaseInsensitiveConstString _species;
ArbUt::CaseInsensitiveConstString _variant = "default"_cnc;
uint8_t _level;
std::string _nickname = "";
Arbutils::CaseInsensitiveConstString _talent = ""_cnc;
ArbUt::CaseInsensitiveConstString _talent = ""_cnc;
Library::Gender _gender = static_cast<Library::Gender>(-1);
uint8_t _coloring = 0;
Arbutils::CaseInsensitiveConstString _heldItem = ""_cnc;
ArbUt::CaseInsensitiveConstString _heldItem = ""_cnc;
uint32_t _identifier = 0;
List<std::tuple<borrowed_ptr<const Library::AttackData>, AttackLearnMethod>> _attacks;
ArbUt::List<std::tuple<ArbUt::BorrowedPtr<const Library::AttackData>, AttackLearnMethod>> _attacks;
public:
CreateCreature(const BattleLibrary* library, const Arbutils::CaseInsensitiveConstString& species, uint8_t level)
CreateCreature(const BattleLibrary* library, const ArbUt::CaseInsensitiveConstString& species, uint8_t level)
: _library(library), _species(species), _level(level), _attacks(library->GetSettings()->GetMaximalMoves()) {
}
CreateCreature WithVariant(const Arbutils::CaseInsensitiveConstString& variant);
CreateCreature WithVariant(const ArbUt::CaseInsensitiveConstString& variant);
CreateCreature WithNickname(std::string nickname);
CreateCreature WithGender(Library::Gender gender);
CreateCreature WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
AttackLearnMethod learnMethod);
CreateCreature WithAttack(const ArbUt::CaseInsensitiveConstString& attackName, AttackLearnMethod learnMethod);
Creature* Create();
};

View File

@ -6,11 +6,12 @@
using namespace CreatureLib;
Battling::Creature::Creature(const BattleLibrary* library, const borrowed_ptr<const Library::CreatureSpecies>& species,
const borrowed_ptr<const Library::SpeciesVariant>& variant, uint8_t level,
Battling::Creature::Creature(const BattleLibrary* library,
const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, uint8_t level,
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
const borrowed_ptr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const List<LearnedAttack*>& attacks,
const ArbUt::BorrowedPtr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const ArbUt::List<LearnedAttack*>& attacks,
bool allowedExperienceGain)
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
@ -146,7 +147,7 @@ void Battling::Creature::OverrideActiveTalent(const ConstString& talent) {
_activeTalent = this->_library->LoadScript(ScriptCategory::Talent, talent);
}
const List<uint8_t>& Battling::Creature::GetTypes() const noexcept {
const ArbUt::List<uint8_t>& Battling::Creature::GetTypes() const noexcept {
// HOOK: override types.
return this->_variant->GetTypes();
}
@ -164,7 +165,7 @@ size_t Battling::Creature::ScriptCount() const {
return c;
}
void Battling::Creature::GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) {
void Battling::Creature::GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) {
scripts.Append(ScriptWrapper::FromScript(&_activeTalent));
scripts.Append(ScriptWrapper::FromScript(&_status));
scripts.Append(ScriptWrapper::FromSet(&_volatile));
@ -186,27 +187,27 @@ void Battling::Creature::AddExperience(uint32_t amount) {
_experience = exp;
_level = level;
}
borrowed_ptr<const Library::CreatureSpecies> Battling::Creature::GetDisplaySpecies() const noexcept {
ArbUt::BorrowedPtr<const Library::CreatureSpecies> Battling::Creature::GetDisplaySpecies() const noexcept {
auto species = _displaySpecies;
if (species == nullptr)
species = _species;
return species;
}
borrowed_ptr<const Library::SpeciesVariant> Battling::Creature::GetDisplayVariant() const noexcept {
ArbUt::BorrowedPtr<const Library::SpeciesVariant> Battling::Creature::GetDisplayVariant() const noexcept {
auto variant = _displayVariant;
if (variant == nullptr)
variant = _variant;
return variant;
}
void Battling::Creature::SetHeldItem(const ConstString& itemName) {
borrowed_ptr<const Library::Item> item;
ArbUt::BorrowedPtr<const Library::Item> item;
if (!_library->GetItemLibrary()->TryGet(itemName.GetHash(), item)) {
throw CreatureException("Item not found.");
}
_heldItem = item;
}
void Battling::Creature::SetHeldItem(uint32_t itemNameHash) {
borrowed_ptr<const Library::Item> item;
ArbUt::BorrowedPtr<const Library::Item> item;
if (!_library->GetItemLibrary()->TryGet(itemNameHash, item)) {
throw CreatureException("Item not found.");
}

View File

@ -2,7 +2,7 @@
#define CREATURELIB_BATTLECREATURE_HPP
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/Memory/borrowed_ptr.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include "../../Library/ClampedStatisticSet.hpp"
#include "../../Library/CreatureData/CreatureSpecies.hpp"
#include "../../Library/Items/Item.hpp"
@ -12,8 +12,6 @@
#include "DamageSource.hpp"
#include "LearnedAttack.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
// Forward declare battle class
class Battle;
@ -24,18 +22,18 @@ namespace CreatureLib::Battling {
protected:
const BattleLibrary* _library;
borrowed_ptr<const Library::CreatureSpecies> _species;
borrowed_ptr<const Library::SpeciesVariant> _variant;
ArbUt::BorrowedPtr<const Library::CreatureSpecies> _species;
ArbUt::BorrowedPtr<const Library::SpeciesVariant> _variant;
borrowed_ptr<const Library::CreatureSpecies> _displaySpecies = nullptr;
borrowed_ptr<const Library::SpeciesVariant> _displayVariant = nullptr;
ArbUt::BorrowedPtr<const Library::CreatureSpecies> _displaySpecies = nullptr;
ArbUt::BorrowedPtr<const Library::SpeciesVariant> _displayVariant = nullptr;
uint8_t _level;
uint32_t _experience;
uint32_t _uniqueIdentifier;
Library::Gender _gender;
uint8_t _coloring;
borrowed_ptr<const Library::Item> _heldItem;
ArbUt::BorrowedPtr<const Library::Item> _heldItem;
uint32_t _currentHealth;
Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost;
@ -51,10 +49,10 @@ namespace CreatureLib::Battling {
Script* _activeTalent = nullptr;
bool _hasOverridenTalent;
ConstString _overridenTalentName = ""_cnc;
ArbUt::CaseInsensitiveConstString _overridenTalentName = ""_cnc;
std::unordered_set<Creature*> _seenOpponents = {};
List<LearnedAttack*> _attacks;
ArbUt::List<LearnedAttack*> _attacks;
bool _allowedExperienceGain;
Script* _status = nullptr;
@ -64,11 +62,11 @@ namespace CreatureLib::Battling {
void OnFaint();
public:
Creature(const BattleLibrary* library, const borrowed_ptr<const Library::CreatureSpecies>& species,
const borrowed_ptr<const Library::SpeciesVariant>& variant, uint8_t level, uint32_t experience,
Creature(const BattleLibrary* library, const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species,
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, uint8_t level, uint32_t experience,
uint32_t uid, Library::Gender gender, uint8_t coloring,
const borrowed_ptr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const List<LearnedAttack*>& attacks,
const ArbUt::BorrowedPtr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const ArbUt::List<LearnedAttack*>& attacks,
bool allowedExperienceGain = true);
virtual ~Creature() {
@ -84,22 +82,24 @@ namespace CreatureLib::Battling {
_currentHealth = GetBoostedStat(Library::Statistic::Health);
}
inline const borrowed_ptr<const Library::CreatureSpecies>& GetSpecies() const noexcept { return _species; }
inline const borrowed_ptr<const Library::SpeciesVariant>& GetVariant() const noexcept { return _variant; }
inline const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& GetSpecies() const noexcept {
return _species;
}
inline const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& GetVariant() const noexcept { return _variant; }
inline uint8_t GetLevel() const noexcept { return _level; }
inline uint32_t GetExperience() const noexcept { return _experience; }
inline Library::Gender GetGender() const noexcept { return _gender; }
inline uint8_t GetColoring() const noexcept { return _coloring; }
inline bool HasHeldItem(const ConstString& name) const noexcept {
inline bool HasHeldItem(const ArbUt::CaseInsensitiveConstString& name) const noexcept {
return _heldItem != nullptr && _heldItem->GetName() == name;
}
inline bool HasHeldItem(uint32_t nameHash) const noexcept {
return _heldItem != nullptr && _heldItem->GetName() == nameHash;
}
inline const borrowed_ptr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
void SetHeldItem(const ConstString& itemName);
inline const ArbUt::BorrowedPtr<const Library::Item>& GetHeldItem() const noexcept { return _heldItem; }
void SetHeldItem(const ArbUt::CaseInsensitiveConstString& itemName);
void SetHeldItem(uint32_t itemNameHash);
inline void SetHeldItem(const borrowed_ptr<const Library::Item>& item) noexcept { _heldItem = item; };
inline void SetHeldItem(const ArbUt::BorrowedPtr<const Library::Item>& item) noexcept { _heldItem = item; };
inline uint32_t GetCurrentHealth() const noexcept { return _currentHealth; }
@ -110,37 +110,37 @@ namespace CreatureLib::Battling {
bool IsOnBattleField() const { return _onBattleField; }
const std::string& GetNickname() const noexcept { return _nickname; }
const ConstString& GetActiveTalent() const;
const ArbUt::CaseInsensitiveConstString& GetActiveTalent() const;
[[nodiscard]] bool IsFainted() const noexcept;
[[nodiscard]] const List<uint8_t>& GetTypes() const noexcept;
[[nodiscard]] const ArbUt::List<uint8_t>& GetTypes() const noexcept;
[[nodiscard]] bool HasType(uint8_t type) const noexcept;
uint32_t GetMaxHealth() const noexcept { return _boostedStats.GetHealth(); }
void ChangeLevelBy(int8_t amount);
void Damage(uint32_t damage, DamageSource source);
void Heal(uint32_t amount, bool canRevive = false);
void OverrideActiveTalent(const ConstString& talent);
void OverrideActiveTalent(const ArbUt::CaseInsensitiveConstString& talent);
void AddExperience(uint32_t amount);
void MarkOpponentAsSeen(Creature* creature) { _seenOpponents.insert(creature); }
const std::unordered_set<Creature*>& GetSeenOpponents() const { return _seenOpponents; }
size_t ScriptCount() const override;
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override;
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override;
void ClearVolatileScripts();
void AddVolatileScript(const ConstString& name);
void AddVolatileScript(const ArbUt::CaseInsensitiveConstString& name);
void AddVolatileScript(Script* script);
void RemoveVolatileScript(const ConstString& name);
void RemoveVolatileScript(const ArbUt::CaseInsensitiveConstString& name);
void RemoveVolatileScript(Script* script);
bool HasVolatileScript(const ConstString& name) const;
bool HasVolatileScript(const ArbUt::CaseInsensitiveConstString& name) const;
const List<LearnedAttack*>& GetAttacks() noexcept { return _attacks; }
const ArbUt::List<LearnedAttack*>& GetAttacks() noexcept { return _attacks; }
borrowed_ptr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept;
borrowed_ptr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept;
ArbUt::BorrowedPtr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept;
ArbUt::BorrowedPtr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept;
void SetDisplaySpecies(const borrowed_ptr<const Library::CreatureSpecies>& species) noexcept {
void SetDisplaySpecies(const ArbUt::BorrowedPtr<const Library::CreatureSpecies>& species) noexcept {
_displaySpecies = species;
}
void SetDisplayVariant(const Library::SpeciesVariant* variant) noexcept { _displayVariant = variant; };

View File

@ -6,11 +6,11 @@
namespace CreatureLib::Battling {
class CreatureParty {
Arbutils::Collections::List<Creature*> _party;
ArbUt::List<Creature*> _party;
public:
CreatureParty(size_t size) noexcept : _party(size) {}
CreatureParty(Arbutils::Collections::List<Creature*> party) noexcept : _party(party) {}
CreatureParty(ArbUt::List<Creature*> party) noexcept : _party(party) {}
CreatureParty(std::initializer_list<Creature*> party) noexcept : _party(party) {}
virtual ~CreatureParty() noexcept {
@ -38,8 +38,8 @@ namespace CreatureLib::Battling {
return false;
}
Arbutils::Collections::List<Creature*>& GetParty() noexcept { return _party; }
const Arbutils::Collections::List<Creature*>& GetParty() const noexcept { return _party; }
ArbUt::List<Creature*>& GetParty() noexcept { return _party; }
const ArbUt::List<Creature*>& GetParty() const noexcept { return _party; }
size_t GetLength() const noexcept { return _party.Count(); }
};

View File

@ -9,8 +9,6 @@
#include <vector>
#include "Creature.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class ExecutingAttack : public ScriptSource {
public:
@ -38,16 +36,16 @@ namespace CreatureLib::Battling {
};
private:
List<Creature*> _targets;
ArbUt::List<Creature*> _targets;
uint8_t _numberHits;
List<HitData> _hits;
ArbUt::List<HitData> _hits;
Creature* _user;
LearnedAttack* _attack;
Script* _script;
public:
ExecutingAttack(const List<Creature*>& targets, uint8_t numberHits, Creature* user, LearnedAttack* attack,
Script* script)
ExecutingAttack(const ArbUt::List<Creature*>& targets, uint8_t numberHits, Creature* user,
LearnedAttack* attack, Script* script)
: _targets(targets.Count()), _numberHits(numberHits), _hits(targets.Count() * numberHits), _user(user),
_attack(attack), _script(script) {
AssertNotNull(user)
@ -79,7 +77,7 @@ namespace CreatureLib::Battling {
}
bool IsCreatureTarget(Creature* creature) noexcept { return _targets.IndexOf(creature) != (size_t)-1; }
const List<Creature*>& GetTargets() noexcept { return _targets; }
const ArbUt::List<Creature*>& GetTargets() noexcept { return _targets; }
uint8_t GetNumberOfHits() const noexcept { return _numberHits; }
Creature* GetUser() noexcept { return _user; }
@ -88,7 +86,7 @@ namespace CreatureLib::Battling {
size_t ScriptCount() const override { return _user->ScriptCount() + 1; }
protected:
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {
scripts.Append(ScriptWrapper::FromScript(&_script));
_user->GetActiveScripts(scripts);
}

View File

@ -1,18 +1,19 @@
#include "LearnedAttack.hpp"
#include <Arbutils/Assert.hpp>
CreatureLib::Battling::LearnedAttack::LearnedAttack(const borrowed_ptr<const CreatureLib::Library::AttackData>& attack,
uint8_t maxUses, AttackLearnMethod learnMethod)
CreatureLib::Battling::LearnedAttack::LearnedAttack(
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
AttackLearnMethod learnMethod)
: _attack(attack), _maxUses(maxUses), _remainingUses(maxUses), _learnMethod(learnMethod) {
AssertNotNull(_attack)
}
CreatureLib::Battling::LearnedAttack::LearnedAttack(const borrowed_ptr<const CreatureLib::Library::AttackData>& attack,
AttackLearnMethod learnMethod)
CreatureLib::Battling::LearnedAttack::LearnedAttack(
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, AttackLearnMethod learnMethod)
: _attack(attack), _maxUses(attack->GetBaseUsages()), _remainingUses(_maxUses), _learnMethod(learnMethod) {
AssertNotNull(_attack)
}
const borrowed_ptr<const CreatureLib::Library::AttackData>&
const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>&
CreatureLib::Battling::LearnedAttack::GetAttack() const noexcept {
return _attack;
}

View File

@ -1,27 +1,27 @@
#ifndef CREATURELIB_LEARNEDATTACK_HPP
#define CREATURELIB_LEARNEDATTACK_HPP
#include <Arbutils/Memory/borrowed_ptr.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include <memory>
#include "../../Library/Attacks/AttackData.hpp"
#include "AttackLearnMethod.hpp"
namespace CreatureLib::Battling {
class LearnedAttack {
borrowed_ptr<const Library::AttackData> _attack;
ArbUt::BorrowedPtr<const Library::AttackData> _attack;
uint8_t _maxUses;
uint8_t _remainingUses;
AttackLearnMethod _learnMethod;
public:
LearnedAttack(const borrowed_ptr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
LearnedAttack(const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack, uint8_t maxUses,
AttackLearnMethod learnMethod);
LearnedAttack(const borrowed_ptr<const CreatureLib::Library::AttackData>& attack,
LearnedAttack(const ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>& attack,
AttackLearnMethod learnMethod);
virtual ~LearnedAttack() = default;
const borrowed_ptr<const Library::AttackData>& GetAttack() const noexcept;
const ArbUt::BorrowedPtr<const Library::AttackData>& GetAttack() const noexcept;
uint8_t GetMaxUses() const noexcept;
uint8_t GetRemainingUses() const noexcept;
AttackLearnMethod GetLearnMethod() const noexcept;

View File

@ -5,8 +5,6 @@
#include <Arbutils/ConstString.hpp>
#include "../../Library/EffectParameter.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
namespace CreatureLib::Battling {
class BaseTurnChoice;
class AttackTurnChoice;
@ -21,13 +19,12 @@ namespace CreatureLib::Battling {
virtual void Stack(){};
virtual void OnRemove(){};
virtual const ConstString& GetName() const noexcept = 0;
virtual const ArbUt::CaseInsensitiveConstString& GetName() const noexcept = 0;
virtual void
OnInitialize(const Arbutils::Collections::List<CreatureLib::Library::EffectParameter*>& parameters){};
virtual void OnInitialize(const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
virtual void ChangeAttack(AttackTurnChoice* choice, ConstString* outAttack){};
virtual void ChangeAttack(AttackTurnChoice* choice, ArbUt::CaseInsensitiveConstString* outAttack){};
virtual void PreventAttack(ExecutingAttack* attack, bool* outResult){};
virtual void FailAttack(ExecutingAttack* attack, bool* outFailed){};
virtual void StopBeforeAttack(ExecutingAttack* attack, bool* outResult){};

View File

@ -7,8 +7,6 @@
#include "ScriptSet.hpp"
#include "ScriptWrapper.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Battling {
class ScriptAggregator {
const ScriptWrapper* _scripts;
@ -18,7 +16,7 @@ namespace CreatureLib::Battling {
public:
ScriptAggregator(){};
explicit ScriptAggregator(const List<ScriptWrapper>& scripts)
explicit ScriptAggregator(const ArbUt::List<ScriptWrapper>& scripts)
: _scripts(scripts.RawData()), _size(scripts.Count()){};
inline void Reset() {

View File

@ -14,7 +14,9 @@ namespace CreatureLib::Battling {
virtual ~ScriptResolver() = default;
virtual void Initialize(BattleLibrary* library){};
virtual Script* LoadScript(ScriptCategory category, const ConstString& scriptName) const { return nullptr; };
virtual Script* LoadScript(ScriptCategory category, const ArbUt::CaseInsensitiveConstString& scriptName) const {
return nullptr;
};
};
}

View File

@ -8,8 +8,8 @@
namespace CreatureLib::Battling {
class ScriptSet {
Arbutils::Collections::List<Script*> _scripts;
Arbutils::Collections::Dictionary<uint32_t, size_t> _lookup;
ArbUt::List<Script*> _scripts;
ArbUt::Dictionary<uint32_t, size_t> _lookup;
public:
~ScriptSet() {
@ -33,7 +33,7 @@ namespace CreatureLib::Battling {
_lookup.Insert(script->GetName(), _scripts.Count() - 1);
}
Script* Get(const ConstString& key) const { return Get(key.GetHash()); }
Script* Get(const ArbUt::CaseInsensitiveConstString& key) const { return Get(key.GetHash()); }
Script* Get(uint32_t keyHash) const noexcept {
size_t v;
@ -43,7 +43,7 @@ namespace CreatureLib::Battling {
return nullptr;
}
void Remove(const ConstString& key) { Remove(key.GetHash()); }
void Remove(const ArbUt::CaseInsensitiveConstString& key) { Remove(key.GetHash()); }
void Remove(uint32_t keyHash) {
size_t v;
@ -65,13 +65,13 @@ namespace CreatureLib::Battling {
_lookup.Clear();
}
bool Has(const ConstString& key) const { return _lookup.Has(key); }
bool Has(const ArbUt::CaseInsensitiveConstString& key) const { return _lookup.Has(key); }
bool Has(uint32_t keyHash) const { return _lookup.Has(keyHash); }
inline size_t Count() const { return _scripts.Count(); }
const Arbutils::Collections::List<Script*>* GetIterator() const { return &_scripts; }
const ArbUt::List<Script*>* GetIterator() const { return &_scripts; }
};
}

View File

@ -8,11 +8,11 @@
namespace CreatureLib::Battling {
class ScriptSource {
bool _areScriptsInitialized = false;
List<ScriptWrapper> _scripts;
ArbUt::List<ScriptWrapper> _scripts;
ScriptAggregator _scriptsIterator;
protected:
virtual void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) = 0;
virtual void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) = 0;
void ResetActiveScripts() { _areScriptsInitialized = false; }
public:

View File

@ -56,7 +56,7 @@ namespace CreatureLib::Battling {
size_t ScriptCount() const override { return 1 + GetUser()->ScriptCount(); }
protected:
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {
scripts.Append(ScriptWrapper::FromScript(&_attackScript));
GetUser()->GetActiveScripts(scripts);
}

View File

@ -13,9 +13,7 @@ namespace CreatureLib::Battling {
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }
protected:
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
GetUser()->GetActiveScripts(scripts);
}
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override { GetUser()->GetActiveScripts(scripts); }
};
}

View File

@ -12,9 +12,7 @@ namespace CreatureLib::Battling {
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }
protected:
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
GetUser()->GetActiveScripts(scripts);
}
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override { GetUser()->GetActiveScripts(scripts); }
};
}

View File

@ -16,9 +16,7 @@ namespace CreatureLib::Battling {
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }
protected:
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
GetUser()->GetActiveScripts(scripts);
}
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override { GetUser()->GetActiveScripts(scripts); }
};
}

View File

@ -1,7 +1,7 @@
#include "AttackData.hpp"
#include <utility>
CreatureLib::Library::AttackData::AttackData(const ConstString& name, uint8_t type,
CreatureLib::Library::AttackData::AttackData(const ArbUt::CaseInsensitiveConstString& name, uint8_t type,
CreatureLib::Library::AttackCategory category, uint8_t power,
uint8_t accuracy, uint8_t baseUsage,
CreatureLib::Library::AttackTarget target, int8_t priority,
@ -9,7 +9,7 @@ CreatureLib::Library::AttackData::AttackData(const ConstString& name, uint8_t ty
: _name(name), _type(type), _category(category), _basePower(power), _accuracy(accuracy), _baseUsages(baseUsage),
_target(target), _priority(priority), _effect(effect), _flags(std::move(flags)) {}
bool CreatureLib::Library::AttackData::HasFlag(const ConstString& key) const noexcept {
bool CreatureLib::Library::AttackData::HasFlag(const ArbUt::CaseInsensitiveConstString& key) const noexcept {
return this->_flags.find(key) != this->_flags.end();
}
bool CreatureLib::Library::AttackData::HasFlag(uint32_t key) const noexcept {

View File

@ -9,12 +9,10 @@
#include "AttackTarget.hpp"
#include "SecondaryEffect.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
namespace CreatureLib::Library {
class AttackData {
protected:
ConstString _name;
ArbUt::CaseInsensitiveConstString _name;
uint8_t _type;
AttackCategory _category;
uint8_t _basePower;
@ -26,12 +24,12 @@ namespace CreatureLib::Library {
std::unordered_set<uint32_t> _flags;
public:
AttackData(const ConstString& name, uint8_t type, AttackCategory category, uint8_t power, uint8_t accuracy,
uint8_t baseUsage, AttackTarget target, int8_t priority, const SecondaryEffect* effect,
std::unordered_set<uint32_t> flags);
AttackData(const ArbUt::CaseInsensitiveConstString& name, uint8_t type, AttackCategory category, uint8_t power,
uint8_t accuracy, uint8_t baseUsage, AttackTarget target, int8_t priority,
const SecondaryEffect* effect, std::unordered_set<uint32_t> flags);
virtual ~AttackData() = default;
inline const ConstString& GetName() const noexcept { return _name; }
inline const ArbUt::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
inline const uint8_t GetType() const noexcept { return _type; }
inline AttackCategory GetCategory() const noexcept { return _category; }
inline uint8_t GetBasePower() const noexcept { return _basePower; }
@ -44,7 +42,7 @@ namespace CreatureLib::Library {
}
inline const std::unique_ptr<const SecondaryEffect>& GetSecondaryEffect() const noexcept { return _effect; }
bool HasFlag(const ConstString& key) const noexcept;
bool HasFlag(const ArbUt::CaseInsensitiveConstString& key) const noexcept;
bool HasFlag(uint32_t keyHash) const noexcept;
};
}

View File

@ -6,18 +6,17 @@
#include <any>
#include "../EffectParameter.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Library {
class SecondaryEffect {
private:
float _chance;
Arbutils::CaseInsensitiveConstString _effectName;
List<EffectParameter*> _parameters;
ArbUt::CaseInsensitiveConstString _effectName;
ArbUt::List<EffectParameter*> _parameters;
public:
SecondaryEffect() noexcept : _chance(0), _effectName() {}
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName,
const List<EffectParameter*>& parameters) noexcept
SecondaryEffect(float chance, const ArbUt::CaseInsensitiveConstString& effectName,
const ArbUt::List<EffectParameter*>& parameters) noexcept
: _chance(chance), _effectName(effectName), _parameters(parameters) {}
~SecondaryEffect() {
@ -27,10 +26,8 @@ namespace CreatureLib::Library {
}
constexpr inline float GetChance() const noexcept { return _chance; }
constexpr inline const Arbutils::CaseInsensitiveConstString& GetEffectName() const noexcept {
return _effectName;
}
const inline List<EffectParameter*>& GetParameters() const noexcept { return _parameters; }
constexpr inline const ArbUt::CaseInsensitiveConstString& GetEffectName() const noexcept { return _effectName; }
const inline ArbUt::List<EffectParameter*>& GetParameters() const noexcept { return _parameters; }
};
}

View File

@ -5,7 +5,7 @@
#include <Arbutils/Collections/Dictionary.hpp>
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/ConstString.hpp>
#include <Arbutils/Memory/borrowed_ptr.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include <Arbutils/Random.hpp>
#include <algorithm>
#include <memory>
@ -13,8 +13,8 @@
namespace CreatureLib::Library {
template <class T> class BaseLibrary {
Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
Arbutils::Collections::List<uint32_t> _listValues;
ArbUt::Dictionary<uint32_t, std::unique_ptr<const T>> _values;
ArbUt::List<uint32_t> _listValues;
size_t _index;
public:
@ -22,7 +22,7 @@ namespace CreatureLib::Library {
virtual ~BaseLibrary() { _values.Clear(); }
inline void Insert(const Arbutils::CaseInsensitiveConstString& key, const T* value) {
inline void Insert(const ArbUt::CaseInsensitiveConstString& key, const T* value) {
AssertNotNull(value)
_values.GetStdMap().insert({key.GetHash(), std::unique_ptr<const T>(value)});
_listValues.Append(key);
@ -33,7 +33,7 @@ namespace CreatureLib::Library {
_listValues.Append(hashedKey);
}
inline void Delete(const Arbutils::CaseInsensitiveConstString& key) {
inline void Delete(const ArbUt::CaseInsensitiveConstString& key) {
_values.erase(key.GetHash());
auto k = _listValues.IndexOf(key);
_listValues.Remove(k);
@ -44,10 +44,10 @@ namespace CreatureLib::Library {
_listValues.Remove(k);
}
bool TryGet(const Arbutils::CaseInsensitiveConstString& name, borrowed_ptr<const T>& out) const {
bool TryGet(const ArbUt::CaseInsensitiveConstString& name, ArbUt::BorrowedPtr<const T>& out) const {
return TryGet(name.GetHash(), out);
}
bool TryGet(uint32_t hashedKey, borrowed_ptr<const T>& out) const {
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const {
auto find = _values.GetStdMap().find(hashedKey);
if (find == _values.GetStdMap().end())
return false;
@ -55,27 +55,29 @@ namespace CreatureLib::Library {
return true;
}
[[nodiscard]] inline borrowed_ptr<const T> Get(const Arbutils::CaseInsensitiveConstString& name) const {
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(const ArbUt::CaseInsensitiveConstString& name) const {
return _values.Get(name.GetHash());
}
[[nodiscard]] inline borrowed_ptr<const T> Get(uint32_t hashedKey) const { return _values.Get(hashedKey); }
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(uint32_t hashedKey) const {
return _values.Get(hashedKey);
}
[[nodiscard]] inline borrowed_ptr<const T> operator[](const Arbutils::CaseInsensitiveConstString& name) const {
[[nodiscard]] inline ArbUt::BorrowedPtr<const T>
operator[](const ArbUt::CaseInsensitiveConstString& name) const {
return Get(name);
}
[[nodiscard]] inline borrowed_ptr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
[[nodiscard]] inline const Arbutils::Collections::Dictionary<uint32_t, const std::unique_ptr<const T>>&
GetIterator() const {
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> operator[](uint32_t hashedKey) const { return Get(hashedKey); }
[[nodiscard]] inline const ArbUt::Dictionary<uint32_t, const std::unique_ptr<const T>>& GetIterator() const {
return _values;
}
[[nodiscard]] size_t GetCount() const { return _values.Count(); }
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random rand = Arbutils::Random()) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random rand = ArbUt::Random()) const {
auto i = rand.Get(_listValues.Count());
return _values[_listValues[i]];
}
inline borrowed_ptr<const T> GetRandomValue(Arbutils::Random* rand) const {
inline ArbUt::BorrowedPtr<const T> GetRandomValue(ArbUt::Random* rand) const {
auto i = rand->Get(_listValues.Count());
return _values[_listValues[i]];
}

View File

@ -3,19 +3,21 @@
using namespace CreatureLib::Library;
CreatureSpecies::CreatureSpecies(uint16_t id, const ConstString& name, const SpeciesVariant* defaultVariant,
float genderRatio, const ConstString& growthRate, uint8_t captureRate)
CreatureSpecies::CreatureSpecies(uint16_t id, const ArbUt::CaseInsensitiveConstString& name,
const SpeciesVariant* defaultVariant, float genderRatio,
const ArbUt::CaseInsensitiveConstString& growthRate, uint8_t captureRate)
: _name(name), _id(id), _genderRate(genderRatio), _growthRate(growthRate), _captureRate(captureRate), _variants(1) {
AssertNotNull(defaultVariant)
SetVariant("default"_cnc, defaultVariant);
}
bool CreatureSpecies::HasVariant(const ConstString& name) const { return _variants.Has(name); }
bool CreatureSpecies::HasVariant(const ArbUt::CaseInsensitiveConstString& name) const { return _variants.Has(name); }
bool CreatureSpecies::TryGetVariant(const ConstString& name, borrowed_ptr<const SpeciesVariant>& out) const {
bool CreatureSpecies::TryGetVariant(const ArbUt::CaseInsensitiveConstString& name,
ArbUt::BorrowedPtr<const SpeciesVariant>& out) const {
return TryGetVariant(name.GetHash(), out);
}
bool CreatureSpecies::TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVariant>& out) const {
bool CreatureSpecies::TryGetVariant(uint32_t hash, ArbUt::BorrowedPtr<const SpeciesVariant>& out) const {
auto find = _variants.GetStdMap().find(hash);
if (find == _variants.end())
return false;
@ -23,17 +25,18 @@ bool CreatureSpecies::TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVar
return true;
}
borrowed_ptr<const SpeciesVariant> CreatureSpecies::GetVariant(const ConstString& name) const {
ArbUt::BorrowedPtr<const SpeciesVariant>
CreatureSpecies::GetVariant(const ArbUt::CaseInsensitiveConstString& name) const {
return _variants.Get(name);
}
borrowed_ptr<const SpeciesVariant> CreatureSpecies::GetVariant(uint32_t key) const { return _variants.Get(key); }
ArbUt::BorrowedPtr<const SpeciesVariant> CreatureSpecies::GetVariant(uint32_t key) const { return _variants.Get(key); }
bool CreatureSpecies::HasVariant(uint32_t hash) const { return _variants.Has(hash); }
void CreatureSpecies::SetVariant(const ConstString& name, const SpeciesVariant* variant) {
void CreatureSpecies::SetVariant(const ArbUt::CaseInsensitiveConstString& name, const SpeciesVariant* variant) {
_variants.GetStdMap().insert({name, std::unique_ptr<const SpeciesVariant>(variant)});
}
Gender CreatureSpecies::GetRandomGender(Arbutils::Random& rand) const {
Gender CreatureSpecies::GetRandomGender(ArbUt::Random& rand) const {
// TODO: Genderless creatures
auto val = rand.GetDouble();
if (val >= this->_genderRate)

View File

@ -3,52 +3,52 @@
#include <Arbutils/Collections/Dictionary.hpp>
#include <Arbutils/ConstString.hpp>
#include <Arbutils/Memory/borrowed_ptr.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include <memory>
#include <string>
#include <unordered_map>
#include "../Gender.hpp"
#include "SpeciesVariant.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
namespace CreatureLib::Library {
/*!
\brief This holds the data required for a species of a creature, so the general data we can describe different
creatures with.
*/
class CreatureSpecies {
const ConstString _name;
const ArbUt::CaseInsensitiveConstString _name;
uint16_t _id;
float _genderRate;
const ConstString _growthRate;
const ArbUt::CaseInsensitiveConstString _growthRate;
uint8_t _captureRate;
Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>> _variants;
ArbUt::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>> _variants;
public:
CreatureSpecies(uint16_t id, const ConstString& name, const SpeciesVariant* defaultVariant, float genderRatio,
const ConstString& growthRate, uint8_t captureRate);
CreatureSpecies(uint16_t id, const ArbUt::CaseInsensitiveConstString& name,
const SpeciesVariant* defaultVariant, float genderRatio,
const ArbUt::CaseInsensitiveConstString& growthRate, uint8_t captureRate);
virtual ~CreatureSpecies() { _variants.Clear(); }
inline uint16_t GetId() const { return _id; }
inline float GetGenderRate() const { return _genderRate; }
inline const ConstString& GetGrowthRate() const { return _growthRate; }
inline const ArbUt::CaseInsensitiveConstString& GetGrowthRate() const { return _growthRate; }
inline uint8_t GetCaptureRate() const { return _captureRate; }
[[nodiscard]] bool HasVariant(const ConstString& key) const;
[[nodiscard]] bool HasVariant(const ArbUt::CaseInsensitiveConstString& key) const;
[[nodiscard]] bool HasVariant(uint32_t hash) const;
[[nodiscard]] bool TryGetVariant(const ConstString& name, borrowed_ptr<const SpeciesVariant>& out) const;
[[nodiscard]] bool TryGetVariant(uint32_t hash, borrowed_ptr<const SpeciesVariant>& out) const;
[[nodiscard]] borrowed_ptr<const SpeciesVariant> GetVariant(const ConstString& key) const;
[[nodiscard]] borrowed_ptr<const SpeciesVariant> GetVariant(uint32_t key) const;
[[nodiscard]] Gender GetRandomGender(Arbutils::Random& rand) const;
[[nodiscard]] const ConstString& GetName() const { return _name; }
[[nodiscard]] bool TryGetVariant(const ArbUt::CaseInsensitiveConstString& name,
ArbUt::BorrowedPtr<const SpeciesVariant>& out) const;
[[nodiscard]] bool TryGetVariant(uint32_t hash, ArbUt::BorrowedPtr<const SpeciesVariant>& out) const;
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant>
GetVariant(const ArbUt::CaseInsensitiveConstString& key) const;
[[nodiscard]] ArbUt::BorrowedPtr<const SpeciesVariant> GetVariant(uint32_t key) const;
[[nodiscard]] Gender GetRandomGender(ArbUt::Random& rand) const;
[[nodiscard]] const ArbUt::CaseInsensitiveConstString& GetName() const { return _name; }
void SetVariant(const ConstString& name, const SpeciesVariant* variant);
void SetVariant(const ArbUt::CaseInsensitiveConstString& name, const SpeciesVariant* variant);
const Arbutils::Collections::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>>&
GetVariantsIterator() const {
const ArbUt::Dictionary<uint32_t, std::unique_ptr<const SpeciesVariant>>& GetVariantsIterator() const {
return _variants;
}
};

View File

@ -3,8 +3,7 @@
using namespace CreatureLib::Library;
void LearnableAttacks::AddLevelAttack(uint8_t level, const AttackData* attack) {
List<const AttackData*> levelData;
ArbUt::List<const AttackData*> levelData;
if (_learnedByLevel.TryGet(level, levelData)) {
levelData.Append(attack);
} else {
@ -14,6 +13,6 @@ void LearnableAttacks::AddLevelAttack(uint8_t level, const AttackData* attack) {
_distinctAttacks.insert(attack);
}
const List<const AttackData*>& LearnableAttacks::GetAttacksForLevel(uint8_t level) const {
const ArbUt::List<const AttackData*>& LearnableAttacks::GetAttacksForLevel(uint8_t level) const {
return _learnedByLevel.Get(level);
}

View File

@ -8,17 +8,15 @@
#include <unordered_map>
#include "../Attacks/AttackData.hpp"
using namespace Arbutils::Collections;
namespace CreatureLib::Library {
class LearnableAttacks {
protected:
Dictionary<uint8_t, List<const AttackData*>> _learnedByLevel;
ArbUt::Dictionary<uint8_t, ArbUt::List<const AttackData*>> _learnedByLevel;
std::unordered_set<const AttackData*> _distinctAttacks;
public:
explicit LearnableAttacks(size_t levelAttackCapacity)
: _learnedByLevel(Dictionary<uint8_t, List<const AttackData*>>(levelAttackCapacity)) {
: _learnedByLevel(ArbUt::Dictionary<uint8_t, ArbUt::List<const AttackData*>>(levelAttackCapacity)) {
for (auto kv : _learnedByLevel) {
for (auto attack : kv.second) {
AssertNotNull(attack)
@ -31,9 +29,9 @@ namespace CreatureLib::Library {
void AddLevelAttack(uint8_t level, const AttackData* attack);
const List<const AttackData*>& GetAttacksForLevel(uint8_t level) const;
const ArbUt::List<const AttackData*>& GetAttacksForLevel(uint8_t level) const;
virtual const AttackData* GetRandomAttack(Arbutils::Random& rand) const {
virtual const AttackData* GetRandomAttack(ArbUt::Random& rand) const {
if (_distinctAttacks.empty()) {
return nullptr;
}

View File

@ -2,7 +2,7 @@
#include <algorithm>
#include <utility>
const List<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const { return _types; }
const ArbUt::List<uint8_t>& CreatureLib::Library::SpeciesVariant::GetTypes() const { return _types; }
size_t CreatureLib::Library::SpeciesVariant::GetTypeCount() const { return _types.Count(); }
@ -13,7 +13,7 @@ uint16_t CreatureLib::Library::SpeciesVariant::GetStatistic(CreatureLib::Library
}
const CreatureLib::Library::TalentIndex
CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ConstString& talent) const {
CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ArbUt::CaseInsensitiveConstString& talent) const {
for (size_t i = 0; i < _talents.Count(); i++) {
if (_talents.At(i) == talent) {
return TalentIndex(false, i);
@ -27,7 +27,7 @@ CreatureLib::Library::SpeciesVariant::GetTalentIndex(const ConstString& talent)
throw CreatureException("The given talent is not a valid talent for this creature.");
}
CreatureLib::Library::TalentIndex CreatureLib::Library::SpeciesVariant::GetRandomTalent(Arbutils::Random* rand) const {
CreatureLib::Library::TalentIndex CreatureLib::Library::SpeciesVariant::GetRandomTalent(ArbUt::Random* rand) const {
return TalentIndex(false, rand->Get(_talents.Count()));
}
@ -36,10 +36,11 @@ CreatureLib::Library::SpeciesVariant::GetLearnableAttacks() const {
return _attacks;
}
CreatureLib::Library::SpeciesVariant::SpeciesVariant(ConstString name, float height, float weight,
uint32_t baseExperience, List<uint8_t> types,
CreatureLib::Library::SpeciesVariant::SpeciesVariant(ArbUt::CaseInsensitiveConstString name, float height, float weight,
uint32_t baseExperience, ArbUt::List<uint8_t> types,
CreatureLib::Library::StatisticSet<uint16_t> baseStats,
List<ConstString> talents, List<ConstString> secretTalents,
ArbUt::List<ArbUt::CaseInsensitiveConstString> talents,
ArbUt::List<ArbUt::CaseInsensitiveConstString> secretTalents,
const LearnableAttacks* attacks)
: _name(std::move(name)), _height(height), _weight(weight), _baseExperience(baseExperience),
_types(std::move(types)), _baseStatistics(baseStats), _talents(std::move(talents)),

View File

@ -8,8 +8,6 @@
#include "../StatisticSet.hpp"
#include "LearnableAttacks.hpp"
#include "TalentIndex.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
using namespace Arbutils::Collections;
namespace CreatureLib::Library {
/*!
@ -17,47 +15,52 @@ namespace CreatureLib::Library {
*/
class SpeciesVariant {
protected:
ConstString _name;
ArbUt::CaseInsensitiveConstString _name;
float _height;
float _weight;
uint32_t _baseExperience;
private:
List<uint8_t> _types;
ArbUt::List<uint8_t> _types;
Library::StatisticSet<uint16_t> _baseStatistics;
List<ConstString> _talents;
List<ConstString> _secretTalents;
ArbUt::List<ArbUt::CaseInsensitiveConstString> _talents;
ArbUt::List<ArbUt::CaseInsensitiveConstString> _secretTalents;
std::unique_ptr<const LearnableAttacks> _attacks;
public:
SpeciesVariant(ConstString name, float height, float weight, uint32_t baseExperience, List<uint8_t> types,
Library::StatisticSet<uint16_t> baseStats, List<ConstString> talents,
List<ConstString> secretTalents, const LearnableAttacks* attacks);
SpeciesVariant(ArbUt::CaseInsensitiveConstString name, float height, float weight, uint32_t baseExperience,
ArbUt::List<uint8_t> types, Library::StatisticSet<uint16_t> baseStats,
ArbUt::List<ArbUt::CaseInsensitiveConstString> talents,
ArbUt::List<ArbUt::CaseInsensitiveConstString> secretTalents, const LearnableAttacks* attacks);
virtual ~SpeciesVariant() = default;
inline const ConstString& GetName() const { return _name; }
inline const ArbUt::CaseInsensitiveConstString& GetName() const { return _name; }
inline float GetHeight() const { return _height; }
inline float GetWeight() const { return _weight; }
inline uint32_t GetBaseExperience() const { return _baseExperience; }
[[nodiscard]] size_t GetTypeCount() const;
[[nodiscard]] uint8_t GetType(size_t index) const;
[[nodiscard]] const List<uint8_t>& GetTypes() const;
[[nodiscard]] const ArbUt::List<uint8_t>& GetTypes() const;
[[nodiscard]] uint16_t GetStatistic(Library::Statistic stat) const;
[[nodiscard]] const size_t GetTalentCount() const { return _talents.Count(); }
[[nodiscard]] const size_t GetSecretTalentCount() const { return _secretTalents.Count(); }
[[nodiscard]] const ConstString& GetTalent(const TalentIndex& index) const {
[[nodiscard]] const ArbUt::CaseInsensitiveConstString& GetTalent(const TalentIndex& index) const {
if (index.IsSecret())
return _secretTalents.At(index.GetIndex());
return _talents.At(index.GetIndex());
}
[[nodiscard]] const TalentIndex GetTalentIndex(const ConstString& talent) const;
[[nodiscard]] const TalentIndex GetTalentIndex(const ArbUt::CaseInsensitiveConstString& talent) const;
[[nodiscard]] const std::unique_ptr<const CreatureLib::Library::LearnableAttacks>& GetLearnableAttacks() const;
[[nodiscard]] TalentIndex GetRandomTalent(Arbutils::Random* rand) const;
[[nodiscard]] inline const List<ConstString>& GetTalents() const { return _talents; }
[[nodiscard]] inline const List<ConstString>& GetSecretTalents() const { return _secretTalents; }
[[nodiscard]] TalentIndex GetRandomTalent(ArbUt::Random* rand) const;
[[nodiscard]] inline const ArbUt::List<ArbUt::CaseInsensitiveConstString>& GetTalents() const {
return _talents;
}
[[nodiscard]] inline const ArbUt::List<ArbUt::CaseInsensitiveConstString>& GetSecretTalents() const {
return _secretTalents;
}
};
}

View File

@ -11,14 +11,14 @@ namespace CreatureLib::Library {
class EffectParameter {
private:
EffectParameterType _type = EffectParameterType::None;
std::variant<bool, int64_t, float, Arbutils::CaseInsensitiveConstString> _value;
std::variant<bool, int64_t, float, ArbUt::CaseInsensitiveConstString> _value;
public:
EffectParameter() : _type(EffectParameterType::None){};
explicit EffectParameter(bool b) : _type(EffectParameterType::Bool), _value(b){};
explicit EffectParameter(int64_t i) : _type(EffectParameterType::Int), _value(i){};
explicit EffectParameter(float f) : _type(EffectParameterType::Float), _value(f){};
explicit EffectParameter(const Arbutils::CaseInsensitiveConstString& s)
explicit EffectParameter(const ArbUt::CaseInsensitiveConstString& s)
: _type(EffectParameterType::String), _value(s){};
EffectParameter(const EffectParameter& other) = delete;
EffectParameter& operator=(const EffectParameter& other) = delete;
@ -54,13 +54,13 @@ namespace CreatureLib::Library {
}
return std::get<float>(_value);
}
const Arbutils::CaseInsensitiveConstString& AsString() const {
const ArbUt::CaseInsensitiveConstString& AsString() const {
if (_type != EffectParameterType::String) {
std::stringstream ss;
ss << "Cast effect parameter to string, but was " << EffectParameterTypeHelper::ToString(_type);
throw CreatureException(ss.str());
}
return std::get<Arbutils::CaseInsensitiveConstString>(_value);
return std::get<ArbUt::CaseInsensitiveConstString>(_value);
}
};
}

View File

@ -8,7 +8,7 @@
#include <unordered_map>
#include "GrowthRate.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
using ConstString = ArbUt::CaseInsensitiveConstString;
namespace CreatureLib::Library {
class GrowthRateLibrary {

View File

@ -7,10 +7,10 @@
namespace CreatureLib::Library {
class LookupGrowthRate : public GrowthRate {
protected:
Arbutils::Collections::List<uint32_t> _experience;
ArbUt::List<uint32_t> _experience;
public:
LookupGrowthRate(const Arbutils::Collections::List<uint32_t>& experience) : _experience(experience) {}
LookupGrowthRate(const ArbUt::List<uint32_t>& experience) : _experience(experience) {}
uint8_t CalculateLevel(uint32_t experience) const override {
for (uint8_t i = 0; i < _experience.Count(); i++) {

View File

@ -1,13 +1,13 @@
#include "Item.hpp"
bool CreatureLib::Library::Item::HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const noexcept {
bool CreatureLib::Library::Item::HasFlag(const ArbUt::CaseInsensitiveConstString& flag) const noexcept {
return this->_flags.find(flag) != this->_flags.end();
}
bool CreatureLib::Library::Item::HasFlag(uint32_t flag) const noexcept {
return this->_flags.find(flag) != this->_flags.end();
}
CreatureLib::Library::Item::Item(const Arbutils::CaseInsensitiveConstString& name,
CreatureLib::Library::Item::Item(const ArbUt::CaseInsensitiveConstString& name,
CreatureLib::Library::ItemCategory category,
CreatureLib::Library::BattleItemCategory battleCategory, int32_t price,
const std::unordered_set<uint32_t>& flags)

View File

@ -10,22 +10,22 @@
namespace CreatureLib::Library {
class Item {
protected:
Arbutils::CaseInsensitiveConstString _name;
ArbUt::CaseInsensitiveConstString _name;
ItemCategory _category;
BattleItemCategory _battleCategory;
int32_t _price;
std::unordered_set<uint32_t> _flags;
public:
Item(const Arbutils::CaseInsensitiveConstString& name, ItemCategory category, BattleItemCategory battleCategory,
Item(const ArbUt::CaseInsensitiveConstString& name, ItemCategory category, BattleItemCategory battleCategory,
int32_t price, const std::unordered_set<uint32_t>& flags);
inline const Arbutils::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
inline const ArbUt::CaseInsensitiveConstString& GetName() const noexcept { return _name; }
inline ItemCategory GetCategory() const noexcept { return _category; }
inline BattleItemCategory GetBattleCategory() const noexcept { return _battleCategory; }
inline const int32_t GetPrice() const noexcept { return _price; }
bool HasFlag(const Arbutils::CaseInsensitiveConstString& flag) const noexcept;
bool HasFlag(const ArbUt::CaseInsensitiveConstString& flag) const noexcept;
bool HasFlag(uint32_t flag) const noexcept;
};
}

View File

@ -4,7 +4,7 @@
using namespace CreatureLib::Library;
float TypeLibrary::GetEffectiveness(uint8_t attacking, const List<uint8_t>& defensive) const {
float TypeLibrary::GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const {
return std::accumulate(
defensive.begin(), defensive.end(), (float)1,
[this, attacking](float init, uint8_t defense) { return init * GetSingleEffectiveness(attacking, defense); });
@ -14,10 +14,10 @@ float TypeLibrary::GetSingleEffectiveness(uint8_t attacking, uint8_t defensive)
return _effectiveness[attacking][defensive];
}
uint8_t TypeLibrary::GetTypeId(const ConstString& key) const { return _types.Get(key); }
uint8_t TypeLibrary::GetTypeId(const ArbUt::CaseInsensitiveConstString& key) const { return _types.Get(key); }
uint8_t TypeLibrary::GetTypeId(uint32_t s) const { return _types.Get(s); }
uint8_t TypeLibrary::RegisterType(const ConstString& key) {
uint8_t TypeLibrary::RegisterType(const ArbUt::CaseInsensitiveConstString& key) {
_types.Insert(key, _types.Count());
_effectiveness.Resize(_types.Count());
for (auto& eff : _effectiveness) {

View File

@ -6,23 +6,21 @@
#include <Arbutils/ConstString.hpp>
#include <unordered_map>
#include <vector>
using ConstString = Arbutils::CaseInsensitiveConstString;
using namespace Arbutils::Collections;
namespace CreatureLib::Library {
class TypeLibrary {
Dictionary<uint32_t, uint8_t> _types;
List<List<float>> _effectiveness;
ArbUt::Dictionary<uint32_t, uint8_t> _types;
ArbUt::List<ArbUt::List<float>> _effectiveness;
public:
TypeLibrary(size_t initialCapacity = 20) : _types(Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
TypeLibrary(size_t initialCapacity = 20) : _types(ArbUt::Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
uint8_t GetTypeId(const ConstString& s) const;
uint8_t GetTypeId(const ArbUt::CaseInsensitiveConstString& s) const;
uint8_t GetTypeId(uint32_t s) const;
[[nodiscard]] float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const List<uint8_t>& defensive) const;
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const ArbUt::List<uint8_t>& defensive) const;
uint8_t RegisterType(const ConstString& typeName);
uint8_t RegisterType(const ArbUt::CaseInsensitiveConstString& typeName);
uint8_t RegisterType(uint32_t typeHash);
void SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness);
};

View File

@ -9,11 +9,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
ConstString _name;
ArbUt::CaseInsensitiveConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const ConstString& GetName() const noexcept override { return _name; }
const ArbUt::CaseInsensitiveConstString& GetName() const noexcept override { return _name; }
void TestMethod(int& runCount) { runCount++; }
};
@ -21,7 +21,7 @@ public:
TEST_CASE("Script Aggregator properly iterates containing script.", "[Battling, Scripting]") {
Script* script = new TestScript("test");
auto ran = 0;
auto vec = Arbutils::Collections::List<ScriptWrapper>{ScriptWrapper::FromScript(&script)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromScript(&script)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNext();
@ -37,8 +37,8 @@ TEST_CASE("Script Aggregator properly iterates multiple scripts.", "[Battling, S
Script* script2 = new TestScript("test2");
Script* script3 = new TestScript("test3");
auto ran = 0;
auto vec = Arbutils::Collections::List<ScriptWrapper>{
ScriptWrapper::FromScript(&script), ScriptWrapper::FromScript(&script2), ScriptWrapper::FromScript(&script3)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromScript(&script), ScriptWrapper::FromScript(&script2),
ScriptWrapper::FromScript(&script3)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNext();
@ -60,7 +60,7 @@ TEST_CASE("Script Aggregator properly iterates Script Set.", "[Battling, Scripti
set.Add(script);
set.Add(script2);
set.Add(script3);
auto vec = Arbutils::Collections::List<ScriptWrapper>{ScriptWrapper::FromSet(&set)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromSet(&set)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNextNotNull();
@ -78,8 +78,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script Set and Script.",
auto set = ScriptSet();
set.Add(script2);
set.Add(script3);
auto vec =
Arbutils::Collections::List<ScriptWrapper>{ScriptWrapper::FromSet(&set), ScriptWrapper::FromScript(&script)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromSet(&set), ScriptWrapper::FromScript(&script)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNextNotNull();
@ -98,8 +97,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script and Script Set.",
auto set = ScriptSet();
set.Add(script2);
set.Add(script3);
auto vec =
Arbutils::Collections::List<ScriptWrapper>{ScriptWrapper::FromScript(&script), ScriptWrapper::FromSet(&set)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromScript(&script), ScriptWrapper::FromSet(&set)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNextNotNull();
@ -119,8 +117,8 @@ TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Sc
auto set = ScriptSet();
set.Add(script2);
set.Add(script3);
auto vec = Arbutils::Collections::List<ScriptWrapper>{
ScriptWrapper::FromScript(&script), ScriptWrapper::FromSet(&set), ScriptWrapper::FromScript(&script4)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromScript(&script), ScriptWrapper::FromSet(&set),
ScriptWrapper::FromScript(&script4)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNextNotNull();
@ -134,7 +132,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Sc
TEST_CASE("Script Aggregator properly iterates when empty.", "[Battling, Scripting]") {
auto ran = 0;
auto vec = Arbutils::Collections::List<ScriptWrapper>{};
auto vec = ArbUt::List<ScriptWrapper>{};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
throw CreatureException("Aggregator returned a script, but should have been empty.");
@ -145,7 +143,7 @@ TEST_CASE("Script Aggregator properly iterates when empty.", "[Battling, Scripti
TEST_CASE("Script Aggregator properly iterates empty Script Set.", "[Battling, Scripting]") {
auto ran = 0;
auto set = ScriptSet();
auto vec = Arbutils::Collections::List<ScriptWrapper>{ScriptWrapper::FromSet(&set)};
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromSet(&set)};
auto aggr = ScriptAggregator(vec);
while (aggr.HasNext()) {
auto next = aggr.GetNext();

View File

@ -9,11 +9,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
ConstString _name;
ArbUt::CaseInsensitiveConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const ConstString& GetName() const noexcept override { return _name; }
const ArbUt::CaseInsensitiveConstString& GetName() const noexcept override { return _name; }
};
TEST_CASE("Empty script set count == 0", "[Battling, Scripting]") {

View File

@ -10,11 +10,11 @@ using namespace CreatureLib::Battling;
class TestScript : public Script {
private:
ConstString _name;
ArbUt::CaseInsensitiveConstString _name;
public:
explicit TestScript(std::string name) : _name(std::move(name)){};
const ConstString& GetName() const noexcept override { return _name; }
const ArbUt::CaseInsensitiveConstString& GetName() const noexcept override { return _name; }
void TestMethod(int& runCount) { runCount++; }
};
@ -25,7 +25,7 @@ public:
protected:
size_t ScriptCount() const override { return 1; }
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {
scripts.Append(ScriptWrapper::FromScript(&ScriptPtr));
}
};
@ -36,7 +36,7 @@ public:
protected:
size_t ScriptCount() const override { return 1; }
void GetActiveScripts(Arbutils::Collections::List<ScriptWrapper>& scripts) override {
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {
scripts.Append(ScriptWrapper::FromSet(&Set));
}
};

View File

@ -16,7 +16,7 @@ TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
auto choice1 = new PassTurnChoice(nullptr);
auto choice2 = new AttackTurnChoice(nullptr, &learnedAttack, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
TurnOrdering::OrderChoices(vec, rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
@ -36,7 +36,7 @@ TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]")
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
TurnOrdering::OrderChoices(vec, rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
@ -58,7 +58,7 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
TurnOrdering::OrderChoices(vec, rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
@ -80,7 +80,7 @@ TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]")
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
TurnOrdering::OrderChoices(vec, rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
@ -102,7 +102,7 @@ TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") {
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
auto rand = Arbutils::Random();
auto rand = ArbUt::Random();
TurnOrdering::OrderChoices(vec, rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);

View File

@ -17,7 +17,7 @@ TEST_CASE("Int EffectParameter", "[Library]") {
}
TEST_CASE("String EffectParameter", "[Library]") {
auto p = EffectParameter((Arbutils::CaseInsensitiveConstString) "foobar"_cnc);
auto p = EffectParameter((ArbUt::CaseInsensitiveConstString) "foobar"_cnc);
REQUIRE(p.AsString() == "foobar");
}