More tests for Pokemon class in AngelScript.
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:
@@ -40,7 +40,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa
|
||||
PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
auto rand = CreatureLib::Core::Random();
|
||||
const PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)){
|
||||
if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)) {
|
||||
throw CreatureException("Invalid species: " + _species);
|
||||
}
|
||||
auto forme = species->GetForme(this->_forme);
|
||||
@@ -60,7 +60,7 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
}
|
||||
const Library::Item* heldItem = nullptr;
|
||||
if (!this->_heldItem.empty()) {
|
||||
if (!_library->GetItemLibrary()->TryGetItem(this->_heldItem, heldItem)){
|
||||
if (!_library->GetItemLibrary()->TryGetItem(this->_heldItem, heldItem)) {
|
||||
throw CreatureException("Unknown Item: " + this->_heldItem);
|
||||
}
|
||||
}
|
||||
@@ -79,10 +79,9 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
}
|
||||
|
||||
auto shiny = false;
|
||||
if (_shininessSet){
|
||||
if (_shininessSet) {
|
||||
shiny = _isShiny;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
shiny = rand.Get(_library->GetSettings()->GetShinyRate()) == 0;
|
||||
}
|
||||
|
||||
@@ -134,3 +133,15 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem
|
||||
_heldItem = item;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::LearnMove(const std::string& moveName, CreatureLib::Battling::AttackLearnMethod method) {
|
||||
const PkmnLib::Library::MoveData* move;
|
||||
if (!_library->GetMoveLibrary()->TryGetMove(moveName, move)){
|
||||
throw CreatureException("Invalid Move given: " + moveName);
|
||||
}
|
||||
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()){
|
||||
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
||||
}
|
||||
_attacks.emplace_back(move, method);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace PkmnLib::Battling {
|
||||
CreatePokemon* WithGender(CreatureLib::Library::Gender gender);
|
||||
CreatePokemon* IsShiny(bool value);
|
||||
CreatePokemon* WithHeldItem(const std::string& item);
|
||||
CreatePokemon* LearnMove(const std::string& move, CreatureLib::Battling::AttackLearnMethod method);
|
||||
|
||||
CreatePokemon* WithRandomIndividualValues(CreatureLib::Core::Random rand = CreatureLib::Core::Random());
|
||||
CreatePokemon* WithIndividualValue(CreatureLib::Core::Statistic stat, uint8_t value);
|
||||
|
||||
@@ -33,8 +33,10 @@ namespace PkmnLib::Battling {
|
||||
return dynamic_cast<const Library::PokemonForme*>(GetVariant());
|
||||
}
|
||||
|
||||
const bool IsShiny() const{
|
||||
return _coloring == 1;
|
||||
const bool IsShiny() const { return _coloring == 1; }
|
||||
|
||||
const std::vector<const LearnedMove*>& GetMoves() const {
|
||||
return (const std::vector<const LearnedMove*>&)_attacks;
|
||||
}
|
||||
|
||||
const Library::Nature& GetNature() const;
|
||||
|
||||
Reference in New Issue
Block a user