Support learning moves with CreateCreature class
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -65,7 +65,18 @@ CreateCreature *CreateCreature::WithGender(Library::Gender gender) {
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *CreateCreature::WithAttack(const std::string& attackName, AttackLearnMethod learnMethod) {
|
||||
if (_attacks.size() >= _library->GetSettings().GetMaximalMoves())
|
||||
//TODO: Better exception
|
||||
throw "";
|
||||
|
||||
auto attackData = _library->GetAttackLibrary()->GetAttack(attackName);
|
||||
_attacks.emplace_back(attackData, learnMethod);
|
||||
return this;
|
||||
}
|
||||
|
||||
Creature *CreateCreature::Create() {
|
||||
_hasCreated = true;
|
||||
auto rand = Core::Random();
|
||||
auto species = this->_library->GetSpeciesLibrary()->GetSpecies(this->_species);
|
||||
auto variant = species->GetVariant(this->_variant);
|
||||
@@ -96,6 +107,12 @@ Creature *CreateCreature::Create() {
|
||||
auto statPotential = Core::StatisticSet(_healthPotential, _physAttackPotential,_physDefensePotential, _magAttackPotential,
|
||||
_magDefensePotential, _speedPotential);
|
||||
|
||||
auto attacks = std::vector<LearnedAttack*>(_attacks.size());
|
||||
for (auto kv: _attacks){
|
||||
attacks.push_back(new LearnedAttack(std::get<0>(kv), std::get<1>(kv)));
|
||||
}
|
||||
|
||||
return new Creature(species, variant, _level, experience, statExperience,statPotential, identifier,gender, _coloring,
|
||||
heldItem, _nickname, talent, {});
|
||||
heldItem, _nickname, talent, attacks);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user