diff --git a/src/Battling/Library/BattleStatCalculator.cpp b/src/Battling/Library/BattleStatCalculator.cpp index 175384c..fa417b3 100644 --- a/src/Battling/Library/BattleStatCalculator.cpp +++ b/src/Battling/Library/BattleStatCalculator.cpp @@ -27,15 +27,15 @@ Battling::BattleStatCalculator::CalculateBoostedStats(Battling::Creature* creatu uint32_t CalculateHealthStat(Battling::Creature* creature) { AssertNotNull(creature) auto level = creature->GetLevel(); - auto a = (creature->GetBaseStat(Library::Statistic::Health)) * 2 * level; - return floor(a / 100) + level + 10; + float a = (creature->GetBaseStat(Library::Statistic::Health)) * 2.0 * level; + return static_cast(floor(a / 100.0) + level + 10); } uint32_t CalculateOtherStat(Battling::Creature* creature, Library::Statistic stat) { AssertNotNull(creature) auto level = creature->GetLevel(); - auto a = (creature->GetBaseStat(stat)) * 2 * level; - return floor(a / 100) + 10; + float a = (creature->GetBaseStat(stat)) * 2.0 * level; + return static_cast(floor(a / 100.0) + 5); } uint32_t Battling::BattleStatCalculator::CalculateFlatStat(Battling::Creature* creature, diff --git a/src/Battling/Library/DamageLibrary.cpp b/src/Battling/Library/DamageLibrary.cpp index 7a01c5b..9bc4250 100644 --- a/src/Battling/Library/DamageLibrary.cpp +++ b/src/Battling/Library/DamageLibrary.cpp @@ -6,7 +6,7 @@ using namespace CreatureLib::Battling; uint32_t DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const { AssertNotNull(attack) AssertNotNull(target) - auto levelMod = static_cast(2 * attack->GetUser()->GetLevel()); + auto levelMod = static_cast(2 * attack->GetUser()->GetLevel()) / 5 + 2; auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex); auto bp = hit->GetBasePower(); auto statMod = GetStatModifier(attack, target, hitIndex); diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index ed006d1..cfff52c 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -59,6 +59,7 @@ void Battle::CheckChoicesSetAndRun() { } side->ResetChoices(); } + _currentTurn++; TurnOrdering::OrderChoices(choices, _random.GetRNG()); this->_currentTurnQueue = new ChoiceQueue(choices); TurnHandler::RunTurn(this->_currentTurnQueue); diff --git a/src/Battling/Models/Battle.hpp b/src/Battling/Models/Battle.hpp index 20092c6..803e9d8 100644 --- a/src/Battling/Models/Battle.hpp +++ b/src/Battling/Models/Battle.hpp @@ -26,6 +26,7 @@ namespace CreatureLib::Battling { bool _hasEnded = false; BattleResult _battleResult = BattleResult::Empty(); EventHook _eventHook = EventHook(); + uint32_t _currentTurn = 0; ScriptSet _volatile; @@ -55,6 +56,7 @@ namespace CreatureLib::Battling { } [[nodiscard]] const BattleLibrary* GetLibrary() const; + [[nodiscard]] uint32_t GetCurrentTurn() const noexcept { return _currentTurn; } virtual bool CanUse(const BaseTurnChoice* choice); virtual bool TrySetChoice(BaseTurnChoice* choice); diff --git a/src/Library/CreatureData/SpeciesVariant.cpp b/src/Library/CreatureData/SpeciesVariant.cpp index 24bd6d9..9abe62a 100644 --- a/src/Library/CreatureData/SpeciesVariant.cpp +++ b/src/Library/CreatureData/SpeciesVariant.cpp @@ -37,7 +37,7 @@ const CreatureLib::Library::LearnableAttacks* CreatureLib::Library::SpeciesVaria CreatureLib::Library::SpeciesVariant::SpeciesVariant(ConstString name, float height, float weight, uint32_t baseExperience, std::vector types, - const CreatureLib::Library::StatisticSet& baseStats, + CreatureLib::Library::StatisticSet baseStats, std::vector talents, std::vector secretTalents, const LearnableAttacks* attacks) diff --git a/src/Library/CreatureData/SpeciesVariant.hpp b/src/Library/CreatureData/SpeciesVariant.hpp index 71c421b..e708c08 100644 --- a/src/Library/CreatureData/SpeciesVariant.hpp +++ b/src/Library/CreatureData/SpeciesVariant.hpp @@ -23,14 +23,14 @@ namespace CreatureLib::Library { private: std::vector _types; - const Library::StatisticSet& _baseStatistics; + Library::StatisticSet _baseStatistics; std::vector _talents; std::vector _secretTalents; const LearnableAttacks* _attacks; public: SpeciesVariant(ConstString name, float height, float weight, uint32_t baseExperience, - std::vector types, const Library::StatisticSet& baseStats, + std::vector types, Library::StatisticSet baseStats, std::vector talents, std::vector secretTalents, const LearnableAttacks* attacks); diff --git a/src/Library/StatisticSet.hpp b/src/Library/StatisticSet.hpp index b160cfd..74e048f 100644 --- a/src/Library/StatisticSet.hpp +++ b/src/Library/StatisticSet.hpp @@ -15,9 +15,6 @@ namespace CreatureLib::Library { T _magicalDefense; T _speed; - private: - StatisticSet(const StatisticSet& v) = delete; - public: StatisticSet(T health, T physicalAttack, T physicalDefense, T magicalAttack, T magicalDefense, T speed) : _health(health), _physicalAttack(physicalAttack), _physicalDefense(physicalDefense), diff --git a/tests/Integration/BattleIntegrations.cpp b/tests/Integration/BattleIntegrations.cpp index 79d49c2..0c87edf 100644 --- a/tests/Integration/BattleIntegrations.cpp +++ b/tests/Integration/BattleIntegrations.cpp @@ -76,8 +76,8 @@ TEST_CASE("Finish battle when all battle of one side have fainted", "[Integratio REQUIRE_FALSE(battle.HasEnded()); - battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0))); - battle.TrySetChoice(new PassTurnChoice(c2)); + REQUIRE(battle.TrySetChoice(new AttackTurnChoice(c1, c1->GetAttacks()[0], CreatureIndex(1, 0)))); + REQUIRE(battle.TrySetChoice(new PassTurnChoice(c2))); REQUIRE_FALSE(battle.HasEnded());