PkmnLib/src/Library/Evolutions/EvolutionData.hpp

102 lines
5.9 KiB
C++
Raw Normal View History

#ifndef PKMNLIB_EVOLUTIONDATA_HPP
#define PKMNLIB_EVOLUTIONDATA_HPP
#include <Arbutils/Memory/Memory.hpp>
#include <CreatureLib/Library/EffectParameter.hpp>
#include <CreatureLib/Library/Gender.hpp>
#include "../TimeOfDay.hpp"
#include "EvolutionMethod.hpp"
namespace PkmnLib::Library {
class PokemonSpecies;
class MoveData;
class Item;
class EvolutionData {
private:
ArbUt::BorrowedPtr<const PokemonSpecies> _evolvesInto;
EvolutionMethod _method;
ArbUt::UniquePtrList<const CreatureLib::Library::EffectParameter> _evolutionData;
EvolutionData(EvolutionMethod method, std::vector<const CreatureLib::Library::EffectParameter*> data,
const PokemonSpecies* next)
: _evolvesInto(next), _method(method), _evolutionData(std::move(data)) {}
public:
~EvolutionData() = default;
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);
}
2021-06-26 14:20:25 +00:00
static inline const EvolutionData* CreateFriendshipTimeEvolution(uint8_t friendship, TimeOfDay startTime,
TimeOfDay endTime,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::HighFriendshipTime,
{new CreatureLib::Library::EffectParameter((int64_t)friendship),
new CreatureLib::Library::EffectParameter((int64_t)startTime),
new CreatureLib::Library::EffectParameter((int64_t)endTime)},
into);
}
static const EvolutionData* CreateKnownMoveEvolution(const MoveData* move, const PokemonSpecies* into);
2020-07-04 13:50:30 +00:00
static inline const EvolutionData* CreateLocationEvolution(const ArbUt::StringView& location,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::LocationBased,
{new CreatureLib::Library::EffectParameter(location)}, into);
}
2021-06-26 14:20:25 +00:00
static inline const EvolutionData* CreateTimeEvolution(TimeOfDay startTime, TimeOfDay endTime,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::TimeBased,
2021-06-26 14:20:25 +00:00
{
new CreatureLib::Library::EffectParameter((int64_t)startTime),
new CreatureLib::Library::EffectParameter((int64_t)endTime),
},
into);
}
2020-04-16 14:18:09 +00:00
static const EvolutionData* CreateHeldItemEvolution(const Item* item, const PokemonSpecies* into);
2021-06-26 14:20:25 +00:00
static const EvolutionData* CreateHeldItemTimeEvolution(const Item* item, TimeOfDay startTime,
TimeOfDay endTime, 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);
}
2020-04-16 14:18:09 +00:00
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);
}
2020-04-16 14:18:09 +00:00
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 std::vector<const CreatureLib::Library::EffectParameter*>& data,
const PokemonSpecies* into) {
return new EvolutionData(EvolutionMethod::Custom, data, into);
}
[[nodiscard]] inline ArbUt::BorrowedPtr<const PokemonSpecies> GetNewSpecies() const noexcept {
return _evolvesInto;
}
2020-04-16 14:18:09 +00:00
[[nodiscard]] inline EvolutionMethod GetMethod() const noexcept { return _method; }
[[nodiscard]] inline size_t GetDataCount() const noexcept { return _evolutionData.Count(); }
[[nodiscard]] inline const ArbUt::UniquePtrList<const CreatureLib::Library::EffectParameter>& GetData() const {
return _evolutionData;
}
[[nodiscard]] inline ArbUt::BorrowedPtr<const CreatureLib::Library::EffectParameter>
GetDataAt(size_t index) const {
return _evolutionData.At(index);
}
};
}
#endif // PKMNLIB_EVOLUTIONDATA_HPP