Update to new version of Arbutils.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-04-09 18:19:21 +02:00
parent 70fc8d2d5f
commit 88eda6ef94
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
6 changed files with 32 additions and 27 deletions

View File

@ -1,11 +1,13 @@
#ifndef CREATURELIB_SCRIPT_HPP
#define CREATURELIB_SCRIPT_HPP
#include <Arbutils/ConstString.hpp>
#include <any>
#include <string>
#include <utility>
#include <vector>
#include "../../Library/CreatureData/CreatureSpecies.hpp"
using ConstString = Arbutils::CaseInsensitiveConstString;
namespace CreatureLib::Battling {
class BaseTurnChoice;

View File

@ -1,8 +1,9 @@
#ifndef CREATURELIB_SCRIPTSET_HPP
#define CREATURELIB_SCRIPTSET_HPP
#include <Arbutils/Collections/Dictionary.hpp>
#include <Arbutils/Collections/List.hpp>
#include <any>
#include <unordered_map>
#include "Script.hpp"
namespace CreatureLib::Battling {

View File

@ -10,7 +10,7 @@ namespace CreatureLib::Library {
public:
constexpr SecondaryEffect() noexcept : _chance(0), _effectName(""_cnc) {}
constexpr SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept
SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept
: _chance(chance), _effectName(effectName) {}
constexpr float GetChance() const noexcept { return _chance; }

View File

@ -64,7 +64,7 @@ TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") {
auto s = new TestScript("foobar");
set.Add(s);
REQUIRE(set.Count() == 1);
set.Remove("foobar"_cnc);
set.Remove("foobar"_cnc.GetHash());
REQUIRE(set.Count() == 0);
auto it = set.GetIterator();
REQUIRE(it->Count() == 0);
@ -77,7 +77,7 @@ TEST_CASE("Add two scripts to script set, then remove them", "[Battling, Scripti
set.Add(s);
set.Add(s2);
REQUIRE(set.Count() == 2);
set.Remove("foobar"_cnc);
set.Remove("foobar"_cnc.GetHash());
REQUIRE(set.Count() == 1);
auto it = set.GetIterator();
REQUIRE(it->At(0)->GetName() == "foobar2");

View File

@ -11,7 +11,8 @@ using namespace CreatureLib::Battling;
TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
auto lib = TestLibrary::Get();
auto learnedAttack = LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc), AttackLearnMethod::Unknown);
auto learnedAttack =
LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto choice1 = new PassTurnChoice(nullptr);
auto choice2 = new AttackTurnChoice(nullptr, &learnedAttack, CreatureIndex(0, 0));
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
@ -30,8 +31,8 @@ TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") {
auto l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown);
auto a1 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
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};
@ -52,8 +53,8 @@ TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]")
TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling]") {
auto l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown);
auto a1 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
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};
@ -74,8 +75,8 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling
TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") {
auto l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown);
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
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};
@ -96,8 +97,8 @@ TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]")
TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") {
auto l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown);
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
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};

View File

@ -21,7 +21,7 @@ BattleLibrary* TestLibrary::Get() {
SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
auto l = new SpeciesLibrary();
l->Insert("testSpecies1"_cnc,
l->Insert("testSpecies1"_cnc.GetHash(),
new CreatureSpecies(0, "testSpecies1"_cnc,
new SpeciesVariant("default"_cnc, 1, 1, 10, {0, 1},
StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10), {"testTalent"_cnc},
@ -32,13 +32,14 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
AttackLibrary* TestLibrary::BuildAttackLibrary() {
auto l = new AttackLibrary();
l->Insert("standard"_cnc, new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
l->Insert("standard"_cnc.GetHash(), new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 0, SecondaryEffect(), {}));
l->Insert("highPriority"_cnc, new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
l->Insert("highPriority"_cnc.GetHash(), new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 1, SecondaryEffect(), {}));
l->Insert("higherPriority"_cnc, new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
l->Insert("higherPriority"_cnc.GetHash(),
new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 2, SecondaryEffect(), {}));
l->Insert("lowPriority"_cnc, new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
l->Insert("lowPriority"_cnc.GetHash(), new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, -1, SecondaryEffect(), {}));
return l;
}
@ -51,7 +52,7 @@ ItemLibrary* TestLibrary::BuildItemLibrary() {
GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() {
auto l = new GrowthRateLibrary();
l->AddGrowthRate(
"testGrowthRate"_cnc,
"testGrowthRate"_cnc.GetHash(),
new LookupGrowthRate(
{0, 15, 52, 122, 237, 406, 637, 942, 1326, 1800, 2369, 3041, 3822,
4719, 5737, 6881, 8155, 9564, 11111, 12800, 14632, 16610, 18737, 21012, 23437, 26012,
@ -66,9 +67,9 @@ GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() {
TypeLibrary* TestLibrary::BuildTypeLibrary() {
auto l = new TypeLibrary();
l->RegisterType("testType1"_cnc);
l->RegisterType("testType2"_cnc);
l->RegisterType("testType3"_cnc);
l->RegisterType("testType1"_cnc.GetHash());
l->RegisterType("testType2"_cnc.GetHash());
l->RegisterType("testType3"_cnc.GetHash());
return l;
}