prompt description
This commit is contained in:
2
Prompts/6-pokemonTable
Normal file
2
Prompts/6-pokemonTable
Normal file
@@ -0,0 +1,2 @@
|
||||
This repo is the start of a highly performant pokemon battle simulator.
|
||||
I want you to implement a pokemon data table that contains all PokemonSpecies. So we can easily access any pokemon using it's ID during runtime.
|
||||
@@ -5,22 +5,17 @@
|
||||
#include "stats.h"
|
||||
#include "types.h"
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <array>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace PokEng {
|
||||
|
||||
// Pokemon species data structure
|
||||
struct PokemonSpecies {
|
||||
std::string_view name;
|
||||
PokemonSpecies() = default;
|
||||
|
||||
std::string name;
|
||||
uint16_t id;
|
||||
BaseStats base_stats;
|
||||
PokemonTypes types;
|
||||
|
||||
constexpr PokemonSpecies(uint16_t id_, std::string_view name_,
|
||||
const BaseStats& stats, const PokemonTypes& types_)
|
||||
: name(name_), id(id_), base_stats(stats), types(types_) {}
|
||||
};
|
||||
|
||||
// Pokemon Archetype - contains information on how a pokemon will be instantiated
|
||||
@@ -114,32 +109,6 @@ private:
|
||||
uint8_t m_friendship = 0;
|
||||
};
|
||||
|
||||
// Pokemon lookup tables for each generation
|
||||
template<Generation Gen>
|
||||
class PokemonDataTable {
|
||||
public:
|
||||
// Get Pokemon species data by ID
|
||||
static const PokemonSpecies* getSpecies(uint16_t id);
|
||||
|
||||
// Get Pokemon species data by name
|
||||
static const PokemonSpecies* getSpecies(std::string_view name);
|
||||
|
||||
// Check if Pokemon exists in this generation
|
||||
static bool exists(uint16_t id);
|
||||
|
||||
// Get total number of Pokemon in this generation
|
||||
static size_t getCount();
|
||||
|
||||
private:
|
||||
static const std::unordered_map<uint16_t, PokemonSpecies>& getTable();
|
||||
static const std::unordered_map<std::string_view, uint16_t>& getNameTable();
|
||||
};
|
||||
|
||||
// Convenience typedefs for different generations
|
||||
using Gen1PokemonData = PokemonDataTable<Generation::I>;
|
||||
using Gen2PokemonData = PokemonDataTable<Generation::II>;
|
||||
using Gen3PokemonData = PokemonDataTable<Generation::III>;
|
||||
|
||||
} // namespace PokEng
|
||||
|
||||
#endif // POKEMON_H
|
||||
|
||||
Reference in New Issue
Block a user