PkmnLib/src/Library/Evolutions/EvolutionData.hpp

85 lines
4.6 KiB
C++

#ifndef PKMNLIB_EVOLUTIONDATA_HPP
#define PKMNLIB_EVOLUTIONDATA_HPP
#include <Arbutils/Collections/List.hpp>
#include <CreatureLib/Library/EffectParameter.hpp>
#include <CreatureLib/Library/Gender.hpp>
#include <string>
#include <utility>
#include "../TimeOfDay.hpp"
#include "EvolutionMethod.hpp"
namespace PkmnLib::Library {
class PokemonSpecies;
class MoveData;
class Item;
class EvolutionData {
private:
const PokemonSpecies* _evolvesInto;
EvolutionMethod _method;
ArbUt::List<const CreatureLib::Library::EffectParameter*> _evolutionData;
EvolutionData(EvolutionMethod method, ArbUt::List<const CreatureLib::Library::EffectParameter*> data,
const PokemonSpecies* next)
: _evolvesInto(next), _method(method), _evolutionData(std::move(data)) {}
public:
~EvolutionData() {
for (auto v : _evolutionData) {
delete v;
}
}
static inline const EvolutionData* CreateLevelEvolution(uint8_t level, const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::Level,
{new CreatureLib::Library::EffectParameter((int64_t)level)}, into);
}
static inline const EvolutionData* CreateFriendshipEvolution(uint8_t friendship, const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::HighFriendship,
{new CreatureLib::Library::EffectParameter((int64_t)friendship)}, into);
}
static const EvolutionData* CreateKnownMoveEvolution(const MoveData* move, const PokemonSpecies* into);
static inline const EvolutionData* CreateLocationEvolution(const ArbUt::CaseInsensitiveConstString& location,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::LocationBased,
{new CreatureLib::Library::EffectParameter(location)}, into);
}
static inline const EvolutionData* CreateTimeEvolution(TimeOfDay time, const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::TimeBased,
{new CreatureLib::Library::EffectParameter((int64_t)time)}, into);
}
static const EvolutionData* CreateHeldItemEvolution(const Item* item, const PokemonSpecies* into);
static inline const EvolutionData* CreateGenderBasedEvolution(CreatureLib::Library::Gender gender,
uint8_t level, const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::IsGenderAndLevel,
{new CreatureLib::Library::EffectParameter((int64_t)gender),
new CreatureLib::Library::EffectParameter((int64_t)level)},
into);
}
static const EvolutionData* CreateItemUseEvolution(const Item* item, const PokemonSpecies* into);
static const EvolutionData* CreateItemUseWithGenderEvolution(const Item* item,
CreatureLib::Library::Gender gender,
const PokemonSpecies* into);
static inline const EvolutionData* CreateTradeEvolution(const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::Trade, {}, into);
}
static const EvolutionData* CreateTradeWithItemEvolution(const Item* item, const PokemonSpecies* into);
static const EvolutionData* CreateTradeWithSpeciesEvolution(const PokemonSpecies* traded,
const PokemonSpecies* into);
static inline const EvolutionData*
CreateCustomEvolution(const ArbUt::List<const CreatureLib::Library::EffectParameter*>& data,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::Custom, data, into);
}
[[nodiscard]] inline const PokemonSpecies* GetNewSpecies() const noexcept { return _evolvesInto; }
[[nodiscard]] inline EvolutionMethod GetMethod() const noexcept { return _method; }
[[nodiscard]] inline size_t GetDataCount() const noexcept { return _evolutionData.Count(); }
[[nodiscard]] inline const CreatureLib::Library::EffectParameter* GetData(size_t index) const {
return _evolutionData.At(index);
}
};
}
#endif // PKMNLIB_EVOLUTIONDATA_HPP