|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
#include "types.h"
|
|
|
|
|
#include "pokemon_battle_sim.h"
|
|
|
|
|
#include "../thirdParty/rapidjson/document.h"
|
|
|
|
|
#include "../thirdParty/rapidjson/filereadstream.h"
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
@@ -6,18 +6,18 @@
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cctype>
|
|
|
|
|
|
|
|
|
|
namespace PokemonSim {
|
|
|
|
|
namespace PokEng {
|
|
|
|
|
|
|
|
|
|
// Static type chart storage initialization
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_1>::CHART_SIZE> TypeUtils::s_gen1Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_2>::CHART_SIZE> TypeUtils::s_gen2Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_3>::CHART_SIZE> TypeUtils::s_gen3Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_4>::CHART_SIZE> TypeUtils::s_gen4Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_5>::CHART_SIZE> TypeUtils::s_gen5Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_6>::CHART_SIZE> TypeUtils::s_gen6Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_7>::CHART_SIZE> TypeUtils::s_gen7Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_8>::CHART_SIZE> TypeUtils::s_gen8Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::GENERATION_9>::CHART_SIZE> TypeUtils::s_gen9Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::I>::CHART_SIZE> TypeUtils::s_gen1Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::II>::CHART_SIZE> TypeUtils::s_gen2Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::III>::CHART_SIZE> TypeUtils::s_gen3Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::IV>::CHART_SIZE> TypeUtils::s_gen4Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::V>::CHART_SIZE> TypeUtils::s_gen5Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::VI>::CHART_SIZE> TypeUtils::s_gen6Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::VII>::CHART_SIZE> TypeUtils::s_gen7Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::VIII>::CHART_SIZE> TypeUtils::s_gen8Chart;
|
|
|
|
|
std::array<TypeMultiplier, TypeChartTraits<Generation::IX>::CHART_SIZE> TypeUtils::s_gen9Chart;
|
|
|
|
|
|
|
|
|
|
// String to type mapping
|
|
|
|
|
static const std::unordered_map<std::string_view, Type> s_stringToTypeMap = {
|
|
|
|
|
@@ -148,25 +148,25 @@ uint32_t TypeUtils::calculateDamageMultiplier(Type attackType, const PokemonType
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Explicit template instantiations for all generations
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_1>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_2>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_3>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_4>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_5>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_6>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_7>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_8>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::GENERATION_9>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::I>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::II>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::III>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::IV>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::V>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::VI>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::VII>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::VIII>(Type, Type);
|
|
|
|
|
template TypeMultiplier TypeUtils::getTypeEffectiveness<Generation::IX>(Type, Type);
|
|
|
|
|
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_1>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_2>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_3>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_4>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_5>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_6>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_7>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_8>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::GENERATION_9>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::I>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::II>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::III>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::IV>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::V>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::VI>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::VII>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::VIII>(Type, const PokemonTypes&);
|
|
|
|
|
template uint32_t TypeUtils::calculateDamageMultiplier<Generation::IX>(Type, const PokemonTypes&);
|
|
|
|
|
|
|
|
|
|
// Convert float damage factor to TypeMultiplier
|
|
|
|
|
static TypeMultiplier floatToTypeMultiplier(double factor) {
|
|
|
|
|
@@ -199,23 +199,23 @@ bool TypeUtils::loadTypeChartFromFile(const std::string& filename) {
|
|
|
|
|
|
|
|
|
|
// Initialize the chart with neutral values
|
|
|
|
|
// Note: We access the static members directly since getTypeChart() returns const reference
|
|
|
|
|
if constexpr (Gen == Generation::GENERATION_1) {
|
|
|
|
|
if constexpr (Gen == Generation::I) {
|
|
|
|
|
std::fill(TypeUtils::s_gen1Chart.begin(), TypeUtils::s_gen1Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_2) {
|
|
|
|
|
} else if constexpr (Gen == Generation::II) {
|
|
|
|
|
std::fill(TypeUtils::s_gen2Chart.begin(), TypeUtils::s_gen2Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_3) {
|
|
|
|
|
} else if constexpr (Gen == Generation::III) {
|
|
|
|
|
std::fill(TypeUtils::s_gen3Chart.begin(), TypeUtils::s_gen3Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_4) {
|
|
|
|
|
} else if constexpr (Gen == Generation::IV) {
|
|
|
|
|
std::fill(TypeUtils::s_gen4Chart.begin(), TypeUtils::s_gen4Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_5) {
|
|
|
|
|
} else if constexpr (Gen == Generation::V) {
|
|
|
|
|
std::fill(TypeUtils::s_gen5Chart.begin(), TypeUtils::s_gen5Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_6) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VI) {
|
|
|
|
|
std::fill(TypeUtils::s_gen6Chart.begin(), TypeUtils::s_gen6Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_7) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VII) {
|
|
|
|
|
std::fill(TypeUtils::s_gen7Chart.begin(), TypeUtils::s_gen7Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_8) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VIII) {
|
|
|
|
|
std::fill(TypeUtils::s_gen8Chart.begin(), TypeUtils::s_gen8Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_9) {
|
|
|
|
|
} else if constexpr (Gen == Generation::IX) {
|
|
|
|
|
std::fill(TypeUtils::s_gen9Chart.begin(), TypeUtils::s_gen9Chart.end(), TypeMultiplier::NEUTRAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -250,23 +250,23 @@ bool TypeUtils::loadTypeChartFromFile(const std::string& filename) {
|
|
|
|
|
|
|
|
|
|
if (index < chartSize) {
|
|
|
|
|
// Direct assignment to static members
|
|
|
|
|
if constexpr (Gen == Generation::GENERATION_1) {
|
|
|
|
|
if constexpr (Gen == Generation::I) {
|
|
|
|
|
TypeUtils::s_gen1Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_2) {
|
|
|
|
|
} else if constexpr (Gen == Generation::II) {
|
|
|
|
|
TypeUtils::s_gen2Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_3) {
|
|
|
|
|
} else if constexpr (Gen == Generation::III) {
|
|
|
|
|
TypeUtils::s_gen3Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_4) {
|
|
|
|
|
} else if constexpr (Gen == Generation::IV) {
|
|
|
|
|
TypeUtils::s_gen4Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_5) {
|
|
|
|
|
} else if constexpr (Gen == Generation::V) {
|
|
|
|
|
TypeUtils::s_gen5Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_6) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VI) {
|
|
|
|
|
TypeUtils::s_gen6Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_7) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VII) {
|
|
|
|
|
TypeUtils::s_gen7Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_8) {
|
|
|
|
|
} else if constexpr (Gen == Generation::VIII) {
|
|
|
|
|
TypeUtils::s_gen8Chart[index] = multiplier;
|
|
|
|
|
} else if constexpr (Gen == Generation::GENERATION_9) {
|
|
|
|
|
} else if constexpr (Gen == Generation::IX) {
|
|
|
|
|
TypeUtils::s_gen9Chart[index] = multiplier;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -276,33 +276,33 @@ bool TypeUtils::loadTypeChartFromFile(const std::string& filename) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Explicit template instantiations for loading
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_1>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_2>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_3>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_4>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_5>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_6>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_7>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_8>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::GENERATION_9>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::I>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::II>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::III>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::IV>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::V>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::VI>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::VII>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::VIII>(const std::string&);
|
|
|
|
|
template bool TypeUtils::loadTypeChartFromFile<Generation::IX>(const std::string&);
|
|
|
|
|
|
|
|
|
|
// Initialize type charts on startup
|
|
|
|
|
struct TypeChartInitializer {
|
|
|
|
|
TypeChartInitializer() {
|
|
|
|
|
// Load type charts for each generation
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_1>("data/type_effectiveness_generation-i.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_2>("data/type_effectiveness_generation-ii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_3>("data/type_effectiveness_generation-iii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_4>("data/type_effectiveness_generation-iv.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_5>("data/type_effectiveness_generation-v.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_6>("data/type_effectiveness_generation-vi.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_7>("data/type_effectiveness_generation-vii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_8>("data/type_effectiveness_generation-viii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::GENERATION_9>("data/type_effectiveness_generation-ix.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::I>("../data/type_effectiveness_generation-i.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::II>("../data/type_effectiveness_generation-ii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::III>("../data/type_effectiveness_generation-iii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::IV>("../data/type_effectiveness_generation-iv.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::V>("../data/type_effectiveness_generation-v.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::VI>("../data/type_effectiveness_generation-vi.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::VII>("../data/type_effectiveness_generation-vii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::VIII>("../data/type_effectiveness_generation-viii.json");
|
|
|
|
|
TypeUtils::loadTypeChartFromFile<Generation::IX>("../data/type_effectiveness_generation-ix.json");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Static initializer to load type charts at program startup
|
|
|
|
|
static TypeChartInitializer s_initializer;
|
|
|
|
|
|
|
|
|
|
} // namespace PokemonSim
|
|
|
|
|
} // namespace PokEng
|