PkmnLibAI/src/NaiveAI.hpp

39 lines
1.5 KiB
C++

#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;
for (auto move : user->GetMoves()) {
if (move->GetRemainingUses() <= 0)
continue;
auto naiveDamage =
move->GetMoveData()->GetBasePower() * battle->GetLibrary()->GetTypeLibrary()->GetEffectiveness(
move->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