PkmnLib/src/Library/Evolutions/EvolutionData.hpp

75 lines
3.9 KiB
C++
Raw Normal View History

#ifndef PKMNLIB_EVOLUTIONDATA_HPP
#define PKMNLIB_EVOLUTIONDATA_HPP
#include <CreatureLib/Library/Gender.hpp>
#include <any>
#include <string>
#include <utility>
#include <vector>
#include "../TimeOfDay.hpp"
#include "EvolutionMethod.hpp"
namespace PkmnLib::Library {
class PokemonSpecies;
class Move;
class Item;
class EvolutionData {
private:
const PokemonSpecies* _evolvesInto;
EvolutionMethod _method;
std::vector<std::any> _evolutionData; // This can probably be done in a better way, can't think of it now.
EvolutionData(EvolutionMethod method, std::vector<std::any> data, const PokemonSpecies* next)
: _evolvesInto(next), _method(method), _evolutionData(std::move(data)) {}
public:
static EvolutionData CreateLevelEvolution(uint8_t level, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::Level, {std::any(level)}, into);
}
static EvolutionData CreateFriendshipEvolution(uint8_t friendship, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::HighFriendship, {std::any(friendship)}, into);
}
static EvolutionData CreateKnownMoveEvolution(const Move* move, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::KnownMove, {std::any(move)}, into);
}
static EvolutionData CreateLocationEvolution(const std::string& location, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::LocationBased, {std::any(location)}, into);
}
static EvolutionData CreateTimeEvolution(TimeOfDay time, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::TimeBased, {std::any(time)}, into);
}
static EvolutionData CreateHeldItemEvolution(const Item* item, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::HoldsItem, {std::any(item)}, into);
}
static EvolutionData CreateGenderBasedEvolution(CreatureLib::Library::Gender gender, uint8_t level,
const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::IsGenderAndLevel, {std::any(gender), std::any(level)}, into);
}
static EvolutionData CreateItemUseEvolution(const Item* item, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::EvolutionItemUse, {std::any(item)}, into);
}
static EvolutionData CreateItemUseWithGenderEvolution(const Item* item, CreatureLib::Library::Gender gender,
const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::EvolutionItemUseWithGender, {std::any(item), std::any(gender)}, into);
}
static EvolutionData CreateTradeEvolution(const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::Trade, {}, into);
}
static EvolutionData CreateTradeWithItemEvolution(const Item* item, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::TradeWithHeldItem, {std::any(item)}, into);
}
static EvolutionData CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::TradeWithSpecificPokemon, {std::any(traded)}, into);
}
static EvolutionData CreateCustomEvolution(std::vector<std::any> data, const PokemonSpecies* into) {
return EvolutionData(EvolutionMethod::Custom, std::move(data), into);
}
[[nodiscard]] inline const PokemonSpecies* GetNewSpecies() const { return _evolvesInto; }
[[nodiscard]] inline EvolutionMethod GetMethod() const { return _method; }
[[nodiscard]] inline const std::any& GetData(size_t index) const { return _evolutionData.at(index); }
};
}
#endif // PKMNLIB_EVOLUTIONDATA_HPP