#ifndef PKMNLIB_DOWNLOAD_NAIVEAI_HPP #define PKMNLIB_DOWNLOAD_NAIVEAI_HPP #include "PokemonAI.hpp" namespace PkmnLibAI { class NaiveAI : public PokemonAI { public: std::string GetName() const noexcept override { return "naive"; } CreatureLib::Battling::BaseTurnChoice* GetChoice(PkmnLib::Battling::Battle* battle, PkmnLib::Battling::Pokemon* user) override { auto target = GetOppositeIndex(user); auto c = battle->GetCreature(target).GetValue(); auto highestScore = -1; PkmnLib::Battling::LearnedMove* bestMove = nullptr; for (auto move : user->GetMoves()) { if (!move.HasValue()) { continue; } auto t = GetTargetIndex(battle, user, move); if (!t.has_value() || t.value() != target) { continue; } if (move.GetValue()->GetRemainingUses() <= 0) continue; auto naiveDamage = move.GetValue()->GetMoveData()->GetBasePower() * battle->GetLibrary()->GetTypeLibrary()->GetEffectiveness( move.GetValue()->GetMoveData()->GetType(), c->GetTypes()); if (naiveDamage > highestScore) { highestScore = naiveDamage; bestMove = move; } } if (highestScore == -1) { return battle->GetLibrary()->GetMiscLibrary()->ReplacementAttack(user, target); } return new CreatureLib::Battling::AttackTurnChoice(user, bestMove, target); } }; } #endif // PKMNLIB_DOWNLOAD_NAIVEAI_HPP