Support learning moves with CreateCreature class
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9588236183
commit
7d6de3557c
|
@ -10,6 +10,10 @@ CreatureLib::Battling::BattleLibrary::~BattleLibrary() {
|
||||||
delete _statCalculator;
|
delete _statCalculator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CreatureLib::Library::LibrarySettings CreatureLib::Battling::BattleLibrary::GetSettings() const {
|
||||||
|
return _staticLib->GetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
const CreatureLib::Battling::BattleStatCalculator *CreatureLib::Battling::BattleLibrary::GetStatCalculator() const {
|
const CreatureLib::Battling::BattleStatCalculator *CreatureLib::Battling::BattleLibrary::GetStatCalculator() const {
|
||||||
return _statCalculator;
|
return _statCalculator;
|
||||||
}
|
}
|
||||||
|
@ -22,4 +26,6 @@ const CreatureLib::Library::ItemLibrary* CreatureLib::Battling::BattleLibrary::G
|
||||||
return _staticLib->GetItemLibrary();
|
return _staticLib->GetItemLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CreatureLib::Library::AttackLibrary *CreatureLib::Battling::BattleLibrary::GetAttackLibrary() const {
|
||||||
|
return _staticLib->GetAttackLibrary();
|
||||||
|
}
|
||||||
|
|
|
@ -12,8 +12,11 @@ namespace CreatureLib::Battling {
|
||||||
BattleLibrary(Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator);
|
BattleLibrary(Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator);
|
||||||
~BattleLibrary();
|
~BattleLibrary();
|
||||||
|
|
||||||
|
const Library::LibrarySettings GetSettings() const;
|
||||||
const Library::SpeciesLibrary* GetSpeciesLibrary() const;
|
const Library::SpeciesLibrary* GetSpeciesLibrary() const;
|
||||||
const Library::ItemLibrary* GetItemLibrary() const;
|
const Library::ItemLibrary* GetItemLibrary() const;
|
||||||
|
const Library::AttackLibrary* GetAttackLibrary() const;
|
||||||
|
|
||||||
const BattleStatCalculator* GetStatCalculator() const;
|
const BattleStatCalculator* GetStatCalculator() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,18 @@ CreateCreature *CreateCreature::WithGender(Library::Gender gender) {
|
||||||
return this;
|
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() {
|
Creature *CreateCreature::Create() {
|
||||||
|
_hasCreated = true;
|
||||||
auto rand = Core::Random();
|
auto rand = Core::Random();
|
||||||
auto species = this->_library->GetSpeciesLibrary()->GetSpecies(this->_species);
|
auto species = this->_library->GetSpeciesLibrary()->GetSpecies(this->_species);
|
||||||
auto variant = species->GetVariant(this->_variant);
|
auto variant = species->GetVariant(this->_variant);
|
||||||
|
@ -96,6 +107,12 @@ Creature *CreateCreature::Create() {
|
||||||
auto statPotential = Core::StatisticSet(_healthPotential, _physAttackPotential,_physDefensePotential, _magAttackPotential,
|
auto statPotential = Core::StatisticSet(_healthPotential, _physAttackPotential,_physDefensePotential, _magAttackPotential,
|
||||||
_magDefensePotential, _speedPotential);
|
_magDefensePotential, _speedPotential);
|
||||||
|
|
||||||
return new Creature(species, variant, _level, experience, statExperience,statPotential, identifier,gender, _coloring,
|
auto attacks = std::vector<LearnedAttack*>(_attacks.size());
|
||||||
heldItem, _nickname, talent, {});
|
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, attacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ namespace CreatureLib::Battling {
|
||||||
uint8_t _coloring = 0;
|
uint8_t _coloring = 0;
|
||||||
std::string _heldItem = "";
|
std::string _heldItem = "";
|
||||||
uint32_t _identifier = 0;
|
uint32_t _identifier = 0;
|
||||||
|
std::vector<std::tuple<const Library::AttackData*, AttackLearnMethod>> _attacks = {};
|
||||||
|
|
||||||
|
bool _hasCreated;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateCreature(const BattleLibrary *library, std::string species, uint8_t level)
|
CreateCreature(const BattleLibrary *library, std::string species, uint8_t level)
|
||||||
|
@ -48,6 +51,7 @@ namespace CreatureLib::Battling {
|
||||||
CreateCreature* WithStatExperiences(uint32_t health, uint32_t physAttack, uint32_t physDefense, uint32_t magAttack,
|
CreateCreature* WithStatExperiences(uint32_t health, uint32_t physAttack, uint32_t physDefense, uint32_t magAttack,
|
||||||
uint32_t magDefense,uint32_t speed);
|
uint32_t magDefense,uint32_t speed);
|
||||||
CreateCreature* WithGender(Library::Gender gender);
|
CreateCreature* WithGender(Library::Gender gender);
|
||||||
|
CreateCreature* WithAttack(const std::string& attackName, AttackLearnMethod learnMethod);
|
||||||
|
|
||||||
|
|
||||||
Creature* Create();
|
Creature* Create();
|
||||||
|
|
|
@ -6,6 +6,11 @@ CreatureLib::Battling::LearnedAttack::LearnedAttack(CreatureLib::Library::Attack
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreatureLib::Battling::LearnedAttack::LearnedAttack(const CreatureLib::Library::AttackData *attack, AttackLearnMethod learnMethod)
|
||||||
|
: _attack(attack), _maxUses(attack->GetBaseUsages()), _remainingUses(_maxUses), _learnMethod(learnMethod)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
const CreatureLib::Library::AttackData *CreatureLib::Battling::LearnedAttack::GetAttack() const {
|
const CreatureLib::Library::AttackData *CreatureLib::Battling::LearnedAttack::GetAttack() const {
|
||||||
return _attack;
|
return _attack;
|
||||||
}
|
}
|
||||||
|
@ -41,4 +46,3 @@ void CreatureLib::Battling::LearnedAttack::RestoreUses() {
|
||||||
_remainingUses = _maxUses;
|
_remainingUses = _maxUses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace CreatureLib::Battling{
|
||||||
AttackLearnMethod _learnMethod;
|
AttackLearnMethod _learnMethod;
|
||||||
public:
|
public:
|
||||||
LearnedAttack(Library::AttackData* attack, uint8_t maxUses, AttackLearnMethod learnMethod);
|
LearnedAttack(Library::AttackData* attack, uint8_t maxUses, AttackLearnMethod learnMethod);
|
||||||
|
LearnedAttack(const Library::AttackData* attack, AttackLearnMethod learnMethod);
|
||||||
|
|
||||||
const Library::AttackData* GetAttack() const;
|
const Library::AttackData* GetAttack() const;
|
||||||
uint8_t GetMaxUses() const;
|
uint8_t GetMaxUses() const;
|
||||||
|
|
Loading…
Reference in New Issue