Many tweaks and fixes relating to AngelScript, implements shininess.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -17,6 +17,10 @@ namespace PkmnLib::Battling {
|
||||
: CreatureLib::Battling::BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary,
|
||||
scriptResolver, miscLibrary) {}
|
||||
|
||||
const Library::LibrarySettings* GetSettings() const{
|
||||
return static_cast<const Library::LibrarySettings*>(_staticLib->GetSettings());
|
||||
}
|
||||
|
||||
const Library::PokemonLibrary* GetStaticLib() const{
|
||||
return dynamic_cast<const Library::PokemonLibrary*>(CreatureLib::Battling::BattleLibrary::_staticLib);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CreatePokemon.hpp"
|
||||
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(CreatureLib::Core::Random rand) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithRandomIndividualValues(CreatureLib::Core::Random rand) {
|
||||
_ivHp = rand.Get(0, 32);
|
||||
_ivAttack = rand.Get(0, 32);
|
||||
_ivDefense = rand.Get(0, 32);
|
||||
@@ -10,7 +11,8 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithRandomIn
|
||||
return this;
|
||||
}
|
||||
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value) {
|
||||
switch (stat) {
|
||||
case PkmnLib::Library::Statistic::HealthPoints: _ivHp = value; break;
|
||||
case PkmnLib::Library::Statistic::PhysicalAttack: _ivAttack = value; break;
|
||||
@@ -22,7 +24,8 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithIndividu
|
||||
return this;
|
||||
}
|
||||
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Core::Statistic stat, uint8_t value) {
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Core::Statistic stat,
|
||||
uint8_t value) {
|
||||
switch (stat) {
|
||||
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
||||
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
||||
@@ -36,8 +39,11 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
|
||||
|
||||
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto rand = CreatureLib::Core::Random();
|
||||
auto species = this->_library->GetSpeciesLibrary()->GetPkmnSpecies(this->_species);
|
||||
auto forme = species->GetForme(this->_variant);
|
||||
const PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)){
|
||||
throw CreatureException("Invalid species: " + _species);
|
||||
}
|
||||
auto forme = species->GetForme(this->_forme);
|
||||
int8_t ability;
|
||||
if (this->_ability.empty()) {
|
||||
ability = forme->GetRandomTalent(&rand);
|
||||
@@ -54,7 +60,9 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
}
|
||||
const Library::Item* heldItem = nullptr;
|
||||
if (!this->_heldItem.empty()) {
|
||||
heldItem = _library->GetItemLibrary()->GetItem(this->_heldItem);
|
||||
if (!_library->GetItemLibrary()->TryGetItem(this->_heldItem, heldItem)){
|
||||
throw CreatureException("Unknown Item: " + this->_heldItem);
|
||||
}
|
||||
}
|
||||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
|
||||
@@ -66,12 +74,20 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto ivs = CreatureLib::Core::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed);
|
||||
auto evs = CreatureLib::Core::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed);
|
||||
|
||||
if (_nature == 255){
|
||||
if (_nature == 255) {
|
||||
_nature = _library->GetNatureLibrary()->GetRandomNature(rand);
|
||||
}
|
||||
|
||||
auto pkmn = new Pokemon(_library, species, forme, _level, experience, identifier, gender, _coloring, heldItem, _nickname,
|
||||
ability, attacks, ivs, evs,_nature);
|
||||
auto shiny = false;
|
||||
if (_shininessSet){
|
||||
shiny = _isShiny;
|
||||
}
|
||||
else{
|
||||
shiny = rand.Get(_library->GetSettings()->GetShinyRate()) == 0;
|
||||
}
|
||||
|
||||
auto pkmn = new Pokemon(_library, species, forme, _level, experience, identifier, gender, shiny, heldItem,
|
||||
_nickname, ability, attacks, ivs, evs, _nature);
|
||||
pkmn->Initialize();
|
||||
return pkmn;
|
||||
}
|
||||
@@ -85,7 +101,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithIndividu
|
||||
_ivHp = hp;
|
||||
_ivAttack = att;
|
||||
_ivDefense = def;
|
||||
_ivSpAtt = spAtt;
|
||||
_ivSpAtt = spAtt;
|
||||
_ivSpDef = spDef;
|
||||
_ivSpeed = speed;
|
||||
return this;
|
||||
@@ -96,8 +112,25 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
|
||||
_evHp = hp;
|
||||
_evAttack = att;
|
||||
_evDefense = def;
|
||||
_evSpAtt = spAtt;
|
||||
_evSpAtt = spAtt;
|
||||
_evSpDef = spDef;
|
||||
_evSpeed = speed;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithForme(const std::string& forme) {
|
||||
_forme = forme;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithGender(CreatureLib::Library::Gender gender) {
|
||||
_gender = gender;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::IsShiny(bool value) {
|
||||
_shininessSet = true;
|
||||
_isShiny = value;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem(const std::string& item) {
|
||||
_heldItem = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -8,14 +8,13 @@ namespace PkmnLib::Battling {
|
||||
private:
|
||||
const BattleLibrary* _library;
|
||||
std::string _species;
|
||||
std::string _variant = "default";
|
||||
std::string _forme = "default";
|
||||
uint8_t _level;
|
||||
std::string _nickname = "";
|
||||
|
||||
std::string _ability = "";
|
||||
uint8_t _nature = 255;
|
||||
CreatureLib::Library::Gender _gender = static_cast<CreatureLib::Library::Gender>(-1);
|
||||
uint8_t _coloring = 0;
|
||||
std::string _heldItem = "";
|
||||
uint32_t _identifier = 0;
|
||||
std::vector<std::tuple<const Library::MoveData*, CreatureLib::Battling::AttackLearnMethod>> _attacks = {};
|
||||
@@ -34,10 +33,18 @@ namespace PkmnLib::Battling {
|
||||
uint8_t _evSpDef = 0;
|
||||
uint8_t _evSpeed = 0;
|
||||
|
||||
bool _shininessSet = false;
|
||||
bool _isShiny = false;
|
||||
|
||||
public:
|
||||
CreatePokemon(const BattleLibrary* library, std::string species, uint8_t level)
|
||||
: _library(library), _species(std::move(species)), _level(level) {}
|
||||
|
||||
CreatePokemon* WithForme(const std::string& forme);
|
||||
CreatePokemon* WithGender(CreatureLib::Library::Gender gender);
|
||||
CreatePokemon* IsShiny(bool value);
|
||||
CreatePokemon* WithHeldItem(const std::string& item);
|
||||
|
||||
CreatePokemon* WithRandomIndividualValues(CreatureLib::Core::Random rand = CreatureLib::Core::Random());
|
||||
CreatePokemon* WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value);
|
||||
CreatePokemon* WithIndividualValues(uint8_t hp, uint8_t att, uint8_t def, uint8_t spAtt, uint8_t spDef,
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace PkmnLib::Battling {
|
||||
return dynamic_cast<const Library::PokemonForme*>(GetVariant());
|
||||
}
|
||||
|
||||
const bool IsShiny() const{
|
||||
return _coloring == 1;
|
||||
}
|
||||
|
||||
const Library::Nature& GetNature() const;
|
||||
uint8_t GetIndividualValue(CreatureLib::Core::Statistic stat) const { return _individualValues.GetStat(stat); }
|
||||
uint8_t GetEffortValue(CreatureLib::Core::Statistic stat) const { return _effortValues.GetStat(stat); }
|
||||
|
||||
Reference in New Issue
Block a user