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;
|
||||
}
|
||||
|
||||
const CreatureLib::Library::LibrarySettings CreatureLib::Battling::BattleLibrary::GetSettings() const {
|
||||
return _staticLib->GetSettings();
|
||||
}
|
||||
|
||||
const CreatureLib::Battling::BattleStatCalculator *CreatureLib::Battling::BattleLibrary::GetStatCalculator() const {
|
||||
return _statCalculator;
|
||||
}
|
||||
|
@ -22,4 +26,6 @@ const CreatureLib::Library::ItemLibrary* CreatureLib::Battling::BattleLibrary::G
|
|||
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();
|
||||
|
||||
const Library::LibrarySettings GetSettings() const;
|
||||
const Library::SpeciesLibrary* GetSpeciesLibrary() const;
|
||||
const Library::ItemLibrary* GetItemLibrary() const;
|
||||
const Library::AttackLibrary* GetAttackLibrary() const;
|
||||
|
||||
const BattleStatCalculator* GetStatCalculator() const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
return new Creature(species, variant, _level, experience, statExperience,statPotential, identifier,gender, _coloring,
|
||||
heldItem, _nickname, talent, {});
|
||||
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, attacks);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ namespace CreatureLib::Battling {
|
|||
uint8_t _coloring = 0;
|
||||
std::string _heldItem = "";
|
||||
uint32_t _identifier = 0;
|
||||
std::vector<std::tuple<const Library::AttackData*, AttackLearnMethod>> _attacks = {};
|
||||
|
||||
bool _hasCreated;
|
||||
|
||||
public:
|
||||
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,
|
||||
uint32_t magDefense,uint32_t speed);
|
||||
CreateCreature* WithGender(Library::Gender gender);
|
||||
CreateCreature* WithAttack(const std::string& attackName, AttackLearnMethod learnMethod);
|
||||
|
||||
|
||||
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 {
|
||||
return _attack;
|
||||
}
|
||||
|
@ -41,4 +46,3 @@ void CreatureLib::Battling::LearnedAttack::RestoreUses() {
|
|||
_remainingUses = _maxUses;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace CreatureLib::Battling{
|
|||
AttackLearnMethod _learnMethod;
|
||||
public:
|
||||
LearnedAttack(Library::AttackData* attack, uint8_t maxUses, AttackLearnMethod learnMethod);
|
||||
LearnedAttack(const Library::AttackData* attack, AttackLearnMethod learnMethod);
|
||||
|
||||
const Library::AttackData* GetAttack() const;
|
||||
uint8_t GetMaxUses() const;
|
||||
|
|
Loading…
Reference in New Issue