Updated to latest Arbutils.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
df37558ec0
commit
1eb751538d
|
@ -38,12 +38,12 @@ namespace CreatureLib::Battling {
|
|||
uint8_t creaturesPerSide = 1)
|
||||
: _library(library), _parties(std::move(parties)), _canFlee(canFlee), _numberOfSides(numberOfSides),
|
||||
_creaturesPerSide(creaturesPerSide) {
|
||||
AssertNotNull(_library)
|
||||
AssertAllNotNull(parties)
|
||||
AssertNotNull(_library);
|
||||
AssertAllNotNull(parties);
|
||||
|
||||
_sides = List<BattleSide*>(numberOfSides);
|
||||
_sides = List<BattleSide*>(numberOfSides);
|
||||
for (size_t i = 0; i < numberOfSides; i++) {
|
||||
_sides[i] = new BattleSide(i, this, creaturesPerSide);
|
||||
_sides.Append(new BattleSide(i, this, creaturesPerSide));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ namespace CreatureLib::Battling {
|
|||
: _index(index), _creaturesPerSide(creaturesPerSide), _creatures(creaturesPerSide),
|
||||
_choices(creaturesPerSide), _fillableSlots(creaturesPerSide), _battle(battle) {
|
||||
for (size_t i = 0; i < creaturesPerSide; i++) {
|
||||
_creatures[i] = nullptr;
|
||||
_choices[i] = nullptr;
|
||||
_fillableSlots[i] = true;
|
||||
_creatures.Append(nullptr);
|
||||
_choices.Append(nullptr);
|
||||
_fillableSlots.Append(true);
|
||||
}
|
||||
ResetChoices();
|
||||
}
|
||||
|
|
|
@ -5,29 +5,29 @@
|
|||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
CreateCreature* CreateCreature::WithVariant(const Arbutils::CaseInsensitiveConstString& variant) {
|
||||
CreateCreature CreateCreature::WithVariant(const Arbutils::CaseInsensitiveConstString& variant) {
|
||||
this->_variant = variant;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CreateCreature* CreateCreature::WithNickname(std::string nickname) {
|
||||
CreateCreature CreateCreature::WithNickname(std::string nickname) {
|
||||
this->_nickname = std::move(nickname);
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CreateCreature* CreateCreature::WithGender(Library::Gender gender) {
|
||||
CreateCreature CreateCreature::WithGender(Library::Gender gender) {
|
||||
this->_gender = gender;
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CreateCreature* CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
|
||||
AttackLearnMethod learnMethod) {
|
||||
CreateCreature CreateCreature::WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
|
||||
AttackLearnMethod learnMethod) {
|
||||
if (_attacks.Count() >= _library->GetSettings()->GetMaximalMoves())
|
||||
throw CreatureException("You have already set the maximum amount of allowed moves.");
|
||||
|
||||
auto attackData = _library->GetAttackLibrary()->Get(attackName);
|
||||
_attacks.Append(std::tuple(attackData, learnMethod));
|
||||
return this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Creature* CreateCreature::Create() {
|
||||
|
@ -57,9 +57,9 @@ Creature* CreateCreature::Create() {
|
|||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
|
||||
auto attacks = List<LearnedAttack*>(_attacks.Count());
|
||||
for (size_t i = 0; i < attacks.Count(); i++) {
|
||||
for (size_t i = 0; i < _attacks.Count(); i++) {
|
||||
auto kv = _attacks[i];
|
||||
attacks[i] = new LearnedAttack(std::get<0>(kv), std::get<1>(kv));
|
||||
attacks.Append(new LearnedAttack(std::get<0>(kv), std::get<1>(kv)));
|
||||
}
|
||||
auto c = new Creature(_library, species, variant, _level, experience, identifier, gender, _coloring, heldItem,
|
||||
_nickname, talent, attacks);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <Arbutils/Collections/List.hpp>
|
||||
#include "../../Library/DataLibrary.hpp"
|
||||
#include "../Library/BattleLibrary.hpp"
|
||||
#include "Creature.hpp"
|
||||
|
||||
using namespace Arbutils::Collections;
|
||||
|
@ -20,17 +21,18 @@ namespace CreatureLib::Battling {
|
|||
uint8_t _coloring = 0;
|
||||
Arbutils::CaseInsensitiveConstString _heldItem = ""_cnc;
|
||||
uint32_t _identifier = 0;
|
||||
List<std::tuple<const Library::AttackData*, AttackLearnMethod>> _attacks = {};
|
||||
List<std::tuple<const Library::AttackData*, AttackLearnMethod>> _attacks;
|
||||
|
||||
public:
|
||||
CreateCreature(const BattleLibrary* library, const Arbutils::CaseInsensitiveConstString& species, uint8_t level)
|
||||
: _library(library), _species(species), _level(level) {}
|
||||
: _library(library), _species(species), _level(level), _attacks(library->GetSettings()->GetMaximalMoves()) {
|
||||
}
|
||||
|
||||
CreateCreature* WithVariant(const Arbutils::CaseInsensitiveConstString& variant);
|
||||
CreateCreature* WithNickname(std::string nickname);
|
||||
CreateCreature* WithGender(Library::Gender gender);
|
||||
CreateCreature* WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
|
||||
AttackLearnMethod learnMethod);
|
||||
CreateCreature WithVariant(const Arbutils::CaseInsensitiveConstString& variant);
|
||||
CreateCreature WithNickname(std::string nickname);
|
||||
CreateCreature WithGender(Library::Gender gender);
|
||||
CreateCreature WithAttack(const Arbutils::CaseInsensitiveConstString& attackName,
|
||||
AttackLearnMethod learnMethod);
|
||||
|
||||
Creature* Create();
|
||||
};
|
||||
|
|
|
@ -42,11 +42,7 @@ namespace CreatureLib::Battling {
|
|||
List<HitData> _hits;
|
||||
|
||||
public:
|
||||
explicit TargetData(uint8_t numberOfHits) : _hits(numberOfHits) {
|
||||
for (uint8_t i = 0; i < numberOfHits; i++) {
|
||||
_hits[i] = HitData();
|
||||
}
|
||||
}
|
||||
explicit TargetData(uint8_t numberOfHits) : _hits(numberOfHits) { _hits.Resize(numberOfHits, HitData()); }
|
||||
TargetData() = default;
|
||||
|
||||
HitData* GetHit(uint8_t index) { return &_hits[index]; }
|
||||
|
|
|
@ -16,7 +16,9 @@ namespace CreatureLib::Library {
|
|||
size_t _index;
|
||||
|
||||
public:
|
||||
BaseLibrary(size_t initialCapacity = 32) : _values(initialCapacity), _listValues(initialCapacity) {}
|
||||
BaseLibrary(size_t initialCapacity = 32) : _values(initialCapacity), _listValues(0) {
|
||||
_listValues.Resize(initialCapacity);
|
||||
}
|
||||
|
||||
virtual ~BaseLibrary() {
|
||||
for (const auto& v : _values) {
|
||||
|
@ -28,12 +30,12 @@ namespace CreatureLib::Library {
|
|||
inline void Insert(const Arbutils::CaseInsensitiveConstString& key, const T* value) {
|
||||
AssertNotNull(value)
|
||||
_values.Insert(key.GetHash(), value);
|
||||
_listValues[_index++] = key;
|
||||
_listValues.Append(key);
|
||||
}
|
||||
inline void Insert(uint32_t hashedKey, const T* value) {
|
||||
AssertNotNull(value)
|
||||
_values.Insert(hashedKey, value);
|
||||
_listValues[_index++] = hashedKey;
|
||||
_listValues.Append(hashedKey);
|
||||
}
|
||||
|
||||
inline void Delete(const Arbutils::CaseInsensitiveConstString& key) {
|
||||
|
|
|
@ -13,9 +13,8 @@ using namespace Battling;
|
|||
|
||||
TEST_CASE("Create Party", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
REQUIRE(battleParty.GetParty()->GetAtIndex(0) == c1);
|
||||
|
@ -23,14 +22,12 @@ TEST_CASE("Create Party", "[Integrations]") {
|
|||
|
||||
TEST_CASE("Create Battle", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -39,14 +36,12 @@ TEST_CASE("Create Battle", "[Integrations]") {
|
|||
|
||||
TEST_CASE("Use damaging move", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -63,14 +58,12 @@ TEST_CASE("Use damaging move", "[Integrations]") {
|
|||
|
||||
TEST_CASE("Finish battle when all battle of one side have fainted", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -82,7 +75,6 @@ TEST_CASE("Finish battle when all battle of one side have fainted", "[Integratio
|
|||
battle.SwitchCreature(1, 0, c2);
|
||||
|
||||
REQUIRE_FALSE(battle.HasEnded());
|
||||
|
||||
REQUIRE(battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0))));
|
||||
REQUIRE(battle.TrySetChoice(new PassTurnChoice(c2)));
|
||||
|
||||
|
@ -102,11 +94,11 @@ TEST_CASE("When creature is dealt enough damage, faint it and mark battle as end
|
|||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
.Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -132,13 +124,13 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
|
|||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
.Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2, c3};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -171,13 +163,13 @@ TEST_CASE("Switch Creature in", "[Integrations]") {
|
|||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
.Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -196,17 +188,14 @@ TEST_CASE("Switch Creature in", "[Integrations]") {
|
|||
|
||||
TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit new creature", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1"_cnc, 50)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -226,13 +215,13 @@ TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integratio
|
|||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
.Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
@ -266,11 +255,11 @@ TEST_CASE("Flee Battle", "[Integrations]") {
|
|||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
|
||||
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
|
||||
->Create();
|
||||
.Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = new BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreateCreature(library, "testSpecies1"_cnc, 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = new BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
|
Loading…
Reference in New Issue