Initial work on battling
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-10-17 14:33:25 +02:00
parent 212a7d1ad6
commit d580d81163
21 changed files with 302 additions and 53 deletions

View File

@@ -0,0 +1,5 @@
#include "Battle.hpp"
const CreatureLib::Battling::BattleLibrary *CreatureLib::Battling::Battle::GetLibrary() const {
return _library;
}

View File

@@ -0,0 +1,18 @@
#ifndef CREATURELIB_BATTLE_HPP
#define CREATURELIB_BATTLE_HPP
#include <vector>
#include "BattleSide.hpp"
#include "../Library/BattleLibrary.hpp"
namespace CreatureLib::Battling {
class Battle {
const BattleLibrary* _library;
std::vector<BattleSide*> _sides;
public:
const BattleLibrary* GetLibrary() const;
};
}
#endif //CREATURELIB_BATTLE_HPP

View File

@@ -0,0 +1,37 @@
#include "BattleCreature.hpp"
#include "../Models/Battle.hpp"
using namespace CreatureLib;
Battling::BattleCreature::BattleCreature(Battling::Battle *battle,
Library::Creature *creature)
:__Battle(battle),
__Level(creature->GetLevel()),
_creature(creature),
_statBoost(Core::StatisticSet<int8_t >())
{
}
const Library::Creature* Battling::BattleCreature::GetBackingCreature() {
return _creature;
}
void Battling::BattleCreature::ApplyPostBattleEffects() {
}
uint32_t Battling::BattleCreature::GetStat(Core::Statistic stat) {
return _fullStats.GetStat(stat);
}
void Battling::BattleCreature::RecalculateStats() {
this->_fullStats = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateStats(this);
}
void Battling::BattleCreature::RecalculateStat(Core::Statistic stat) {
auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateStat(this, stat);
this->_fullStats.SetStat(stat, s);
}

View File

@@ -0,0 +1,34 @@
#ifndef CREATURELIB_BATTLECREATURE_HPP
#define CREATURELIB_BATTLECREATURE_HPP
#include "../../GenericTemplates.cpp"
#include "../../Library/Creature.hpp"
namespace CreatureLib::Battling{
// Forward declare battle class
class Battle;
class BattleCreature {
GetProperty(Battle*, Battle);
GetProperty(uint8_t, Level);
private:
Library::Creature* _creature;
Core::StatisticSet<int8_t > _statBoost;
Core::StatisticSet<uint32_t > _fullStats;
public:
BattleCreature(Battle* battle, Library::Creature* creature);
const Library::Creature* GetBackingCreature();
void ApplyPostBattleEffects();
uint32_t GetStat(Core::Statistic stat);
void RecalculateStats();
void RecalculateStat(Core::Statistic);
};
}
#endif //CREATURELIB_BATTLECREATURE_HPP

View File

@@ -0,0 +1 @@
#include "BattleSide.hpp"

View File

@@ -0,0 +1,14 @@
#ifndef CREATURELIB_BATTLESIDE_HPP
#define CREATURELIB_BATTLESIDE_HPP
#include <vector>
#include "BattleCreature.hpp"
namespace CreatureLib::Battling{
class BattleSide {
std::vector<BattleCreature*> _creatures;
};
}
#endif //CREATURELIB_BATTLESIDE_HPP

View File

@@ -0,0 +1 @@
#include "BattleTeam.hpp"

View File

@@ -0,0 +1,10 @@
#ifndef CREATURELIB_BATTLETEAM_HPP
#define CREATURELIB_BATTLETEAM_HPP
class BattleTeam {
};
#endif //CREATURELIB_BATTLETEAM_HPP