More tests for Pokemon class in AngelScript.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-02-02 13:57:41 +01:00
parent aae96333b1
commit 419e573bbe
7 changed files with 112 additions and 16 deletions

View File

@@ -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;
}