Rework for LearnMove method on CreatePokemon.
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:
@@ -23,8 +23,8 @@ PkmnLib::Battling::CreatePokemon::WithIndividualValue(CreatureLib::Library::Stat
|
||||
return this;
|
||||
}
|
||||
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat,
|
||||
uint8_t value) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithEffortValue(CreatureLib::Library::Statistic stat, uint8_t value) {
|
||||
switch (stat) {
|
||||
case PkmnLib::Library::Statistic::HealthPoints: _evHp = value; break;
|
||||
case PkmnLib::Library::Statistic::PhysicalAttack: _evAttack = value; break;
|
||||
@@ -72,10 +72,14 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
}
|
||||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
|
||||
auto attacks = List<CreatureLib::Battling::LearnedAttack*>(_attacks.size());
|
||||
auto attacks = List<CreatureLib::Battling::LearnedAttack*>(_attacks.Count());
|
||||
for (size_t i = 0; i < attacks.Count(); i++) {
|
||||
auto kv = _attacks[i];
|
||||
attacks[i] = new LearnedMove(std::get<0>(kv), std::get<1>(kv));
|
||||
auto& kv = _attacks[i];
|
||||
auto move = kv.Move;
|
||||
if (move != nullptr)
|
||||
attacks[i] = new LearnedMove(move, kv.LearnMethod);
|
||||
else
|
||||
attacks[i] = nullptr;
|
||||
}
|
||||
auto ivs = CreatureLib::Library::StatisticSet(_ivHp, _ivAttack, _ivDefense, _ivSpAtt, _ivSpDef, _ivSpeed);
|
||||
auto evs = CreatureLib::Library::StatisticSet(_evHp, _evAttack, _evDefense, _evSpAtt, _evSpDef, _evSpeed);
|
||||
@@ -97,7 +101,8 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() {
|
||||
pkmn->Initialize();
|
||||
return pkmn;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithNature(const Arbutils::CaseInsensitiveConstString& nature) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithNature(const Arbutils::CaseInsensitiveConstString& nature) {
|
||||
_nature = nature;
|
||||
return this;
|
||||
}
|
||||
@@ -137,7 +142,8 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::IsShiny(bool
|
||||
_isShiny = value;
|
||||
return this;
|
||||
}
|
||||
PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem(const Arbutils::CaseInsensitiveConstString& item) {
|
||||
PkmnLib::Battling::CreatePokemon*
|
||||
PkmnLib::Battling::CreatePokemon::WithHeldItem(const Arbutils::CaseInsensitiveConstString& item) {
|
||||
_heldItem = item;
|
||||
return this;
|
||||
}
|
||||
@@ -148,10 +154,12 @@ PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConst
|
||||
if (!_library->GetMoveLibrary()->TryGet(moveName, move)) {
|
||||
throw CreatureException("Invalid Move given: " + moveName.std_str());
|
||||
}
|
||||
if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()) {
|
||||
if (_currentMove >= _library->GetSettings()->GetMaximalMoves() - 1) {
|
||||
throw CreatureException("This pokemon already has the maximal allowed moves.");
|
||||
}
|
||||
Assert(move != nullptr);
|
||||
_attacks.emplace_back(move, method);
|
||||
auto& c = _attacks[_currentMove++];
|
||||
c.Move = move;
|
||||
c.LearnMethod = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user