Used ClangFormat style guide I'm happy with.
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:
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "CreateCreature.hpp"
|
||||
#include "../../Core/Exceptions/CreatureException.hpp"
|
||||
#include "../Library/BattleLibrary.hpp"
|
||||
#include <utility>
|
||||
#include "../Library/BattleLibrary.hpp"
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
@@ -10,25 +10,25 @@ CreateCreature* CreateCreature::WithVariant(std::string variant) {
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *CreateCreature::WithNickname(std::string nickname) {
|
||||
CreateCreature* CreateCreature::WithNickname(std::string nickname) {
|
||||
this->_nickname = std::move(nickname);
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *CreateCreature::WithStatPotential(CreatureLib::Core::Statistic stat, uint32_t value) {
|
||||
switch (stat){
|
||||
case Core::Health:_healthPotential = value;
|
||||
CreateCreature* CreateCreature::WithStatPotential(CreatureLib::Core::Statistic stat, uint32_t value) {
|
||||
switch (stat) {
|
||||
case Core::Health: _healthPotential = value;
|
||||
case Core::PhysicalAttack: _physAttackPotential = value;
|
||||
case Core::PhysicalDefense: _physDefensePotential = value;
|
||||
case Core::MagicalAttack: _magAttackPotential = value;
|
||||
case Core::MagicalDefense:_magDefensePotential = value;
|
||||
case Core::MagicalDefense: _magDefensePotential = value;
|
||||
case Core::Speed: _speedPotential = value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature * CreateCreature::WithStatPotentials(uint32_t health, uint32_t physAttack, uint32_t physDefense,
|
||||
uint32_t magAttack, uint32_t magDefense, uint32_t speed) {
|
||||
CreateCreature* CreateCreature::WithStatPotentials(uint32_t health, uint32_t physAttack, uint32_t physDefense,
|
||||
uint32_t magAttack, uint32_t magDefense, uint32_t speed) {
|
||||
_healthPotential = health;
|
||||
_physAttackPotential = physAttack;
|
||||
_physDefensePotential = physDefense;
|
||||
@@ -39,20 +39,19 @@ CreateCreature * CreateCreature::WithStatPotentials(uint32_t health, uint32_t ph
|
||||
}
|
||||
|
||||
CreateCreature* CreateCreature::WithStatExperience(Core::Statistic stat, uint32_t value) {
|
||||
switch (stat){
|
||||
case Core::Health:_healthExperience = value;
|
||||
switch (stat) {
|
||||
case Core::Health: _healthExperience = value;
|
||||
case Core::PhysicalAttack: _physAttackExperience = value;
|
||||
case Core::PhysicalDefense: _physDefenseExperience = value;
|
||||
case Core::MagicalAttack: _magAttackExperience = value;
|
||||
case Core::MagicalDefense:_magDefenseExperience = value;
|
||||
case Core::MagicalDefense: _magDefenseExperience = value;
|
||||
case Core::Speed: _speedExperience = value;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *
|
||||
CreateCreature::WithStatExperiences(uint32_t health, uint32_t physAttack, uint32_t physDefense, uint32_t magAttack,
|
||||
uint32_t magDefense, uint32_t speed) {
|
||||
CreateCreature* CreateCreature::WithStatExperiences(uint32_t health, uint32_t physAttack, uint32_t physDefense,
|
||||
uint32_t magAttack, uint32_t magDefense, uint32_t speed) {
|
||||
_healthExperience = health;
|
||||
_physAttackExperience = physAttack;
|
||||
_physDefenseExperience = physDefense;
|
||||
@@ -62,12 +61,12 @@ CreateCreature::WithStatExperiences(uint32_t health, uint32_t physAttack, uint32
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *CreateCreature::WithGender(Library::Gender gender) {
|
||||
CreateCreature* CreateCreature::WithGender(Library::Gender gender) {
|
||||
this->_gender = gender;
|
||||
return this;
|
||||
}
|
||||
|
||||
CreateCreature *CreateCreature::WithAttack(const std::string& attackName, AttackLearnMethod learnMethod) {
|
||||
CreateCreature* CreateCreature::WithAttack(const std::string& attackName, AttackLearnMethod learnMethod) {
|
||||
if (_attacks.size() >= _library->GetSettings().GetMaximalMoves())
|
||||
throw CreatureException("You have already set the maximum amount of allowed moves.");
|
||||
|
||||
@@ -76,44 +75,42 @@ CreateCreature *CreateCreature::WithAttack(const std::string& attackName, Attack
|
||||
return this;
|
||||
}
|
||||
|
||||
Creature *CreateCreature::Create() {
|
||||
Creature* CreateCreature::Create() {
|
||||
_hasCreated = true;
|
||||
auto rand = Core::Random();
|
||||
auto species = this->_library->GetSpeciesLibrary()->GetSpecies(this->_species);
|
||||
auto variant = species->GetVariant(this->_variant);
|
||||
int8_t talent;
|
||||
if (this->_talent.empty()){
|
||||
if (this->_talent.empty()) {
|
||||
talent = variant->GetRandomTalent(&rand);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
talent = variant->GetTalentIndex(this->_talent);
|
||||
}
|
||||
auto identifier = this->_identifier;
|
||||
if (identifier == 0){
|
||||
if (identifier == 0) {
|
||||
identifier = rand.Get();
|
||||
}
|
||||
auto gender = this->_gender;
|
||||
if (gender == static_cast<Library::Gender >(-1)){
|
||||
if (gender == static_cast<Library::Gender>(-1)) {
|
||||
gender = species->GetRandomGender(rand);
|
||||
}
|
||||
const Library::Item* heldItem = nullptr;
|
||||
if (!this->_heldItem.empty()){
|
||||
if (!this->_heldItem.empty()) {
|
||||
heldItem = _library->GetItemLibrary()->GetItem(this->_heldItem);
|
||||
}
|
||||
//FIXME: implement experience
|
||||
// FIXME: implement experience
|
||||
auto experience = 0;
|
||||
|
||||
auto statExperience = Core::StatisticSet(_healthExperience, _physAttackExperience,_physDefenseExperience, _magAttackExperience,
|
||||
_magDefenseExperience, _speedExperience);
|
||||
auto statPotential = Core::StatisticSet(_healthPotential, _physAttackPotential,_physDefensePotential, _magAttackPotential,
|
||||
_magDefensePotential, _speedPotential);
|
||||
auto statExperience = Core::StatisticSet(_healthExperience, _physAttackExperience, _physDefenseExperience,
|
||||
_magAttackExperience, _magDefenseExperience, _speedExperience);
|
||||
auto statPotential = Core::StatisticSet(_healthPotential, _physAttackPotential, _physDefensePotential,
|
||||
_magAttackPotential, _magDefensePotential, _speedPotential);
|
||||
|
||||
auto attacks = std::vector<LearnedAttack*>(_attacks.size());
|
||||
for (auto kv: _attacks){
|
||||
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);
|
||||
return new Creature(species, variant, _level, experience, statExperience, statPotential, identifier, gender,
|
||||
_coloring, heldItem, _nickname, talent, attacks);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user