Make learned attacks on Creature be optional.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
29d6632472
commit
2055837980
|
@ -51,7 +51,7 @@ namespace CreatureLib::Battling {
|
||||||
ArbUt::StringView _overridenTalentName;
|
ArbUt::StringView _overridenTalentName;
|
||||||
std::unordered_set<ArbUt::BorrowedPtr<Creature>> _seenOpponents;
|
std::unordered_set<ArbUt::BorrowedPtr<Creature>> _seenOpponents;
|
||||||
|
|
||||||
ArbUt::UniquePtrList<LearnedAttack> _attacks;
|
ArbUt::OptionalUniquePtrList<LearnedAttack> _attacks;
|
||||||
bool _allowedExperienceGain;
|
bool _allowedExperienceGain;
|
||||||
|
|
||||||
std::unique_ptr<Script> _status = nullptr;
|
std::unique_ptr<Script> _status = nullptr;
|
||||||
|
@ -138,7 +138,7 @@ namespace CreatureLib::Battling {
|
||||||
void RemoveVolatileScript(Script* script);
|
void RemoveVolatileScript(Script* script);
|
||||||
bool HasVolatileScript(const ArbUt::BasicStringView& name) const;
|
bool HasVolatileScript(const ArbUt::BasicStringView& name) const;
|
||||||
|
|
||||||
const ArbUt::UniquePtrList<LearnedAttack>& GetAttacks() noexcept { return _attacks; }
|
const ArbUt::OptionalUniquePtrList<LearnedAttack>& GetAttacks() noexcept { return _attacks; }
|
||||||
bool HasAttack(const ArbUt::StringView& name) {
|
bool HasAttack(const ArbUt::StringView& name) {
|
||||||
for (auto& a : _attacks) {
|
for (auto& a : _attacks) {
|
||||||
if (a == nullptr)
|
if (a == nullptr)
|
||||||
|
|
|
@ -50,7 +50,7 @@ TEST_CASE("Use damaging move") {
|
||||||
battle.SwitchCreature(0, 0, c1);
|
battle.SwitchCreature(0, 0, c1);
|
||||||
battle.SwitchCreature(1, 0, c2);
|
battle.SwitchCreature(1, 0, c2);
|
||||||
|
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||||
|
|
||||||
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Statistic::Health));
|
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Statistic::Health));
|
||||||
|
@ -74,12 +74,12 @@ TEST_CASE("Run more turns") {
|
||||||
battle.SwitchCreature(0, 0, c1);
|
battle.SwitchCreature(0, 0, c1);
|
||||||
battle.SwitchCreature(1, 0, c2);
|
battle.SwitchCreature(1, 0, c2);
|
||||||
|
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||||
|
|
||||||
REQUIRE(c2->IsFainted());
|
REQUIRE(c2->IsFainted());
|
||||||
battle.SwitchCreature(1, 0, c3);
|
battle.SwitchCreature(1, 0, c3);
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c3));
|
battle.TrySetChoice(new PassTurnChoice(c3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ TEST_CASE("Finish battle when all battle of one side have fainted") {
|
||||||
battle.SwitchCreature(1, 0, c2);
|
battle.SwitchCreature(1, 0, c2);
|
||||||
|
|
||||||
REQUIRE_FALSE(battle.HasEnded());
|
REQUIRE_FALSE(battle.HasEnded());
|
||||||
REQUIRE(battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0))));
|
REQUIRE(battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0))));
|
||||||
REQUIRE(battle.TrySetChoice(new PassTurnChoice(c2)));
|
REQUIRE(battle.TrySetChoice(new PassTurnChoice(c2)));
|
||||||
|
|
||||||
REQUIRE_FALSE(battle.HasEnded());
|
REQUIRE_FALSE(battle.HasEnded());
|
||||||
|
@ -138,7 +138,7 @@ TEST_CASE("When creature is dealt enough damage, faint it and mark battle as end
|
||||||
|
|
||||||
REQUIRE_FALSE(battle.HasEnded());
|
REQUIRE_FALSE(battle.HasEnded());
|
||||||
|
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||||
|
|
||||||
REQUIRE(battle.HasEnded());
|
REQUIRE(battle.HasEnded());
|
||||||
|
@ -170,14 +170,14 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
|
||||||
|
|
||||||
REQUIRE_FALSE(battle.HasEnded());
|
REQUIRE_FALSE(battle.HasEnded());
|
||||||
|
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||||
|
|
||||||
REQUIRE_FALSE(battle.HasEnded());
|
REQUIRE_FALSE(battle.HasEnded());
|
||||||
|
|
||||||
battle.SwitchCreature(1, 0, c3);
|
battle.SwitchCreature(1, 0, c3);
|
||||||
|
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0].GetValue(), CreatureIndex(1, 0)));
|
||||||
battle.TrySetChoice(new PassTurnChoice(c3));
|
battle.TrySetChoice(new PassTurnChoice(c3));
|
||||||
|
|
||||||
REQUIRE(battle.HasEnded());
|
REQUIRE(battle.HasEnded());
|
||||||
|
@ -263,7 +263,7 @@ TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit ne
|
||||||
battle.SwitchCreature(1, 0, c3);
|
battle.SwitchCreature(1, 0, c3);
|
||||||
|
|
||||||
battle.TrySetChoice(new SwitchTurnChoice(c1, c2));
|
battle.TrySetChoice(new SwitchTurnChoice(c1, c2));
|
||||||
battle.TrySetChoice(new AttackTurnChoice(c3, c3->GetAttacks()[0], CreatureIndex(0, 0)));
|
battle.TrySetChoice(new AttackTurnChoice(c3, c3->GetAttacks()[0].GetValue(), CreatureIndex(0, 0)));
|
||||||
|
|
||||||
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Library::Statistic::Health));
|
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Library::Statistic::Health));
|
||||||
REQUIRE(c1->GetCurrentHealth() == c1->GetBoostedStat(Library::Statistic::Health));
|
REQUIRE(c1->GetCurrentHealth() == c1->GetBoostedStat(Library::Statistic::Health));
|
||||||
|
|
Loading…
Reference in New Issue