Initial work on battling
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
212a7d1ad6
commit
d580d81163
|
@ -1,15 +1,19 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
# If a defined C Compiler is not set
|
||||||
if (NOT CMAKE_C_COMPILER)
|
if (NOT CMAKE_C_COMPILER)
|
||||||
|
# If the GCC flag is set, use GCC
|
||||||
if (GCC)
|
if (GCC)
|
||||||
set(CMAKE_C_COMPILER "gcc")
|
set(CMAKE_C_COMPILER "gcc")
|
||||||
set(CMAKE_CXX_COMPILER "g++")
|
set(CMAKE_CXX_COMPILER "g++")
|
||||||
|
# Otherwise default to clang
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_COMPILER "clang")
|
set(CMAKE_C_COMPILER "clang")
|
||||||
set(CMAKE_CXX_COMPILER "clang++")
|
set(CMAKE_CXX_COMPILER "clang++")
|
||||||
endif(GCC)
|
endif(GCC)
|
||||||
endif(NOT CMAKE_C_COMPILER)
|
endif(NOT CMAKE_C_COMPILER)
|
||||||
|
|
||||||
|
# Make warnings trigger errors.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
project(CreatureLib)
|
project(CreatureLib)
|
||||||
|
@ -17,30 +21,42 @@ project(CreatureLib)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
ADD_DEFINITIONS(-D WINDOWS=1)
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||||
endif(WINDOWS)
|
endif(WINDOWS)
|
||||||
|
|
||||||
|
# Create Core library with files in src/Core
|
||||||
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp")
|
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp")
|
||||||
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
|
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
|
||||||
|
|
||||||
|
# Create main Library library with files in src/Library
|
||||||
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp")
|
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp")
|
||||||
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
|
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
|
||||||
|
|
||||||
|
# Create Battling library with files in src/Battling
|
||||||
|
file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp")
|
||||||
|
add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES})
|
||||||
|
|
||||||
|
# Create Test executable
|
||||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||||
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
|
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
|
||||||
|
|
||||||
target_link_libraries(CreatureLibLibrary -static-libgcc -static-libstdc++)
|
# Link the core library to the individual other libraries
|
||||||
target_link_libraries(CreatureLibTests -static-libgcc -static-libstdc++)
|
|
||||||
|
|
||||||
target_link_libraries(CreatureLibLibrary CreatureLibCore)
|
target_link_libraries(CreatureLibLibrary CreatureLibCore)
|
||||||
|
target_link_libraries(CreatureLibBattling CreatureLibCore)
|
||||||
|
|
||||||
|
# Link the library data to the Battling library
|
||||||
|
target_link_libraries(CreatureLibBattling CreatureLibLibrary)
|
||||||
|
|
||||||
target_link_libraries(CreatureLibTests CreatureLibLibrary)
|
target_link_libraries(CreatureLibTests CreatureLibLibrary)
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
|
# Statically link libraries we need in Windows.
|
||||||
target_link_libraries(CreatureLibCore -static -static-libgcc -static-libstdc++)
|
target_link_libraries(CreatureLibCore -static -static-libgcc -static-libstdc++)
|
||||||
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
|
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
|
||||||
|
target_link_libraries(CreatureLibBattling -static -static-libgcc -static-libstdc++)
|
||||||
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
|
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
|
||||||
endif(WINDOWS)
|
endif(WINDOWS)
|
||||||
|
|
||||||
|
# Add a definition for the test library
|
||||||
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "BattleLibrary.hpp"
|
||||||
|
|
||||||
|
const CreatureLib::Battling::BattleStatCalculator *CreatureLib::Battling::BattleLibrary::GetStatCalculator() const {
|
||||||
|
return _statCalculator;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef CREATURELIB_BATTLELIBRARY_HPP
|
||||||
|
#define CREATURELIB_BATTLELIBRARY_HPP
|
||||||
|
|
||||||
|
#include "BattleStatCalculator.hpp"
|
||||||
|
|
||||||
|
namespace CreatureLib::Battling {
|
||||||
|
class BattleLibrary {
|
||||||
|
BattleStatCalculator* _statCalculator;
|
||||||
|
public:
|
||||||
|
const BattleStatCalculator* GetStatCalculator() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //CREATURELIB_BATTLELIBRARY_HPP
|
|
@ -0,0 +1,39 @@
|
||||||
|
#include "BattleStatCalculator.hpp"
|
||||||
|
#include "../Models/BattleCreature.hpp"
|
||||||
|
|
||||||
|
using namespace CreatureLib;
|
||||||
|
|
||||||
|
Core::StatisticSet<uint32_t>
|
||||||
|
Battling::BattleStatCalculator::CalculateStats(Battling::BattleCreature *creature) const {
|
||||||
|
return Core::StatisticSet<uint32_t>(
|
||||||
|
CalculateStat(creature, Core::Statistic::Health),
|
||||||
|
CalculateStat(creature, Core::Statistic::PhysicalAttack),
|
||||||
|
CalculateStat(creature, Core::Statistic::PhysicalDefense),
|
||||||
|
CalculateStat(creature, Core::Statistic::MagicalAttack),
|
||||||
|
CalculateStat(creature, Core::Statistic::MagicalDefense),
|
||||||
|
CalculateStat(creature, Core::Statistic::Speed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CalculateHealthStat(Battling::BattleCreature *creature){
|
||||||
|
auto base = creature->GetBackingCreature();
|
||||||
|
auto level = creature->GetLevel();
|
||||||
|
auto a = (base->GetBaseStat(Core::Statistic::Health) + base->GetStatPotential(Core::Statistic::Health)) * 2 +
|
||||||
|
floor(sqrt(base->GetStatExperience(Core::Statistic::Health) / 4)) * level;
|
||||||
|
return floor(a / 100) + level + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CalculateOtherStat(Battling::BattleCreature *creature, Core::Statistic stat){
|
||||||
|
auto base = creature->GetBackingCreature();
|
||||||
|
auto level = creature->GetLevel();
|
||||||
|
auto a = (base->GetBaseStat(stat) + base->GetStatPotential(stat)) * 2 +
|
||||||
|
floor(sqrt(base->GetStatExperience(stat) / 4)) * level;
|
||||||
|
return floor(a / 100) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Battling::BattleStatCalculator::CalculateStat(Battling::BattleCreature *creature, Core::Statistic stat) const{
|
||||||
|
if (stat == Core::Statistic::Health)
|
||||||
|
return CalculateHealthStat(creature);
|
||||||
|
return CalculateOtherStat(creature, stat);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef CREATURELIB_BATTLESTATCALCULATOR_HPP
|
||||||
|
#define CREATURELIB_BATTLESTATCALCULATOR_HPP
|
||||||
|
|
||||||
|
#include "../../Core/StatisticSet.hpp"
|
||||||
|
|
||||||
|
namespace CreatureLib::Battling {
|
||||||
|
//predeclare BattleCreature class
|
||||||
|
class BattleCreature;
|
||||||
|
|
||||||
|
class BattleStatCalculator {
|
||||||
|
public:
|
||||||
|
virtual Core::StatisticSet<uint32_t > CalculateStats(BattleCreature* creature) const;
|
||||||
|
virtual uint32_t CalculateStat(BattleCreature* creature, Core::Statistic stat) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //CREATURELIB_BATTLESTATCALCULATOR_HPP
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "Battle.hpp"
|
||||||
|
|
||||||
|
const CreatureLib::Battling::BattleLibrary *CreatureLib::Battling::Battle::GetLibrary() const {
|
||||||
|
return _library;
|
||||||
|
}
|
|
@ -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
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
#include "BattleSide.hpp"
|
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
#include "BattleTeam.hpp"
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef CREATURELIB_BATTLETEAM_HPP
|
||||||
|
#define CREATURELIB_BATTLETEAM_HPP
|
||||||
|
|
||||||
|
|
||||||
|
class BattleTeam {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //CREATURELIB_BATTLETEAM_HPP
|
|
@ -1,13 +1,10 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include "StatisticSet.hpp"
|
#include "StatisticSet.hpp"
|
||||||
|
|
||||||
CreatureLib::Core::StatisticSet::StatisticSet(uint32_t health, uint32_t physicalAttack, uint32_t physicalDefense,
|
|
||||||
uint32_t magicalAttack, uint32_t magicalDefense, uint32_t speed)
|
template <class T>
|
||||||
:
|
CreatureLib::Core::StatisticSet<T>::StatisticSet()
|
||||||
__Health(health),
|
: _health(0), _physicalAttack(0), _physicalDefense(0), _magicalAttack(0), _magicalDefense(0), _speed(0)
|
||||||
__PhysicalAttack(physicalAttack),
|
{
|
||||||
__PhysicalDefense(physicalDefense),
|
|
||||||
__MagicalAttack(magicalAttack),
|
}
|
||||||
__MagicalDefense(magicalDefense),
|
|
||||||
__Speed(speed)
|
|
||||||
{}
|
|
|
@ -1,30 +1,55 @@
|
||||||
#ifndef CREATURELIB_STATISTICSET_HPP
|
#ifndef CREATURELIB_STATISTICSET_HPP
|
||||||
#define CREATURELIB_STATISTICSET_HPP
|
#define CREATURELIB_STATISTICSET_HPP
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <exception>
|
||||||
#include "Statistic.hpp"
|
#include "Statistic.hpp"
|
||||||
#include "../GenericTemplates.cpp"
|
#include "../GenericTemplates.cpp"
|
||||||
|
|
||||||
namespace CreatureLib::Core{
|
namespace CreatureLib::Core{
|
||||||
|
template <class T>
|
||||||
class StatisticSet {
|
class StatisticSet {
|
||||||
|
protected:
|
||||||
|
T _health;
|
||||||
|
T _physicalAttack;
|
||||||
|
T _physicalDefense;
|
||||||
|
T _magicalAttack;
|
||||||
|
T _magicalDefense;
|
||||||
|
T _speed;
|
||||||
public:
|
public:
|
||||||
StatisticSet(uint32_t health, uint32_t physicalAttack, uint32_t physicalDefense, uint32_t magicalAttack,
|
StatisticSet(T health, T physicalAttack, T physicalDefense, T magicalAttack, T magicalDefense, T speed)
|
||||||
uint32_t magicalDefense, uint32_t speed);
|
: _health(health), _physicalAttack(physicalAttack),
|
||||||
|
_physicalDefense(physicalDefense), _magicalAttack(magicalAttack),
|
||||||
|
_magicalDefense(magicalDefense), _speed(speed){}
|
||||||
|
StatisticSet();
|
||||||
|
|
||||||
GetSetProperty(uint32_t, Health)
|
inline T GetHealth() const{ return _health; }
|
||||||
GetSetProperty(uint32_t, PhysicalAttack)
|
inline T GetPhysicalAttack() const{ return _physicalAttack; }
|
||||||
GetSetProperty(uint32_t, PhysicalDefense)
|
inline T GetPhysicalDefense() const{ return _physicalDefense; }
|
||||||
GetSetProperty(uint32_t, MagicalAttack)
|
inline T GetMagicalAttack() const{ return _magicalAttack; }
|
||||||
GetSetProperty(uint32_t, MagicalDefense)
|
inline T GetMagicalDefense() const{ return _magicalDefense; }
|
||||||
GetSetProperty(uint32_t, Speed)
|
inline T GetSpeed() const{ return _speed; }
|
||||||
|
|
||||||
[[nodiscard]] inline uint32_t GetStat(Statistic stat) const{
|
|
||||||
|
[[nodiscard]] inline T GetStat(Statistic stat) const{
|
||||||
switch (stat){
|
switch (stat){
|
||||||
case Health: return __Health;
|
case Health: return _health;
|
||||||
case PhysicalAttack: return __PhysicalAttack;
|
case PhysicalAttack: return _physicalAttack;
|
||||||
case PhysicalDefense: return __PhysicalDefense;
|
case PhysicalDefense: return _physicalDefense;
|
||||||
case MagicalAttack: return __MagicalAttack;
|
case MagicalAttack: return _magicalAttack;
|
||||||
case MagicalDefense: return __MagicalDefense;
|
case MagicalDefense: return _magicalDefense;
|
||||||
case Speed: return __Speed;
|
case Speed: return _speed;
|
||||||
|
}
|
||||||
|
throw std::exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SetStat(Statistic stat, T value){
|
||||||
|
switch (stat){
|
||||||
|
case Health: _health = value;
|
||||||
|
case PhysicalAttack: _physicalAttack = value;
|
||||||
|
case PhysicalDefense: _physicalDefense = value;
|
||||||
|
case MagicalAttack: _magicalAttack = value;
|
||||||
|
case MagicalDefense: _magicalDefense = value;
|
||||||
|
case Speed: _speed = value;
|
||||||
}
|
}
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,19 +13,19 @@ namespace CreatureLib::Library {
|
||||||
uint8_t _level;
|
uint8_t _level;
|
||||||
std::string _nickname = "";
|
std::string _nickname = "";
|
||||||
|
|
||||||
uint32_t _healthPotential = 0;
|
uint8_t _healthPotential = 0;
|
||||||
uint32_t _physAttackPotential = 0;
|
uint8_t _physAttackPotential = 0;
|
||||||
uint32_t _physDefensePotential = 0;
|
uint8_t _physDefensePotential = 0;
|
||||||
uint32_t _magAttackPotential = 0;
|
uint8_t _magAttackPotential = 0;
|
||||||
uint32_t _magDefensePotential = 0;
|
uint8_t _magDefensePotential = 0;
|
||||||
uint32_t _speedPotential = 0;
|
uint8_t _speedPotential = 0;
|
||||||
|
|
||||||
uint32_t _healthExperience = 0;
|
uint8_t _healthExperience = 0;
|
||||||
uint32_t _physAttackExperience = 0;
|
uint8_t _physAttackExperience = 0;
|
||||||
uint32_t _physDefenseExperience = 0;
|
uint8_t _physDefenseExperience = 0;
|
||||||
uint32_t _magAttackExperience = 0;
|
uint8_t _magAttackExperience = 0;
|
||||||
uint32_t _magDefenseExperience = 0;
|
uint8_t _magDefenseExperience = 0;
|
||||||
uint32_t _speedExperience = 0;
|
uint8_t _speedExperience = 0;
|
||||||
|
|
||||||
std::string _talent = "";
|
std::string _talent = "";
|
||||||
Gender _gender = static_cast<Gender>(-1);
|
Gender _gender = static_cast<Gender>(-1);
|
||||||
|
|
|
@ -4,8 +4,8 @@ CreatureLib::Library::Creature::Creature(const CreatureLib::Library::DataLibrary
|
||||||
const CreatureLib::Library::CreatureSpecies *species,
|
const CreatureLib::Library::CreatureSpecies *species,
|
||||||
const CreatureLib::Library::SpeciesVariant *variant, uint8_t level,
|
const CreatureLib::Library::SpeciesVariant *variant, uint8_t level,
|
||||||
std::string nickname, int8_t talentIndex,
|
std::string nickname, int8_t talentIndex,
|
||||||
CreatureLib::Core::StatisticSet statExperience,
|
CreatureLib::Core::StatisticSet<uint8_t > statExperience,
|
||||||
CreatureLib::Core::StatisticSet statPotential,
|
CreatureLib::Core::StatisticSet<uint8_t > statPotential,
|
||||||
uint32_t identifier, CreatureLib::Library::Gender gender, uint8_t coloring,
|
uint32_t identifier, CreatureLib::Library::Gender gender, uint8_t coloring,
|
||||||
const CreatureLib::Library::Item *heldItem)
|
const CreatureLib::Library::Item *heldItem)
|
||||||
:
|
:
|
||||||
|
@ -52,8 +52,20 @@ int32_t CalculateStat(const CreatureLib::Library::Creature* creature, CreatureLi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t CreatureLib::Library::Creature::CalculateFullStat(CreatureLib::Core::Statistic stat) const {
|
uint32_t CreatureLib::Library::Creature::CalculateFullStat(CreatureLib::Core::Statistic stat) const {
|
||||||
if (stat == Core::Statistic::Health)
|
if (stat == Core::Statistic::Health)
|
||||||
return CalculateHealth(this);
|
return CalculateHealth(this);
|
||||||
return CalculateStat(this, stat);
|
return CalculateStat(this, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t CreatureLib::Library::Creature::GetBaseStat(CreatureLib::Core::Statistic stat) const {
|
||||||
|
return this->GetVariant()->GetStatistic(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CreatureLib::Library::Creature::GetStatPotential(CreatureLib::Core::Statistic stat) const {
|
||||||
|
return this->__StatPotential.GetStat(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t CreatureLib::Library::Creature::GetStatExperience(CreatureLib::Core::Statistic stat) const {
|
||||||
|
return this->__StatExperience.GetStat(stat);
|
||||||
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace CreatureLib::Library{
|
||||||
GetProperty(const SpeciesVariant*, Variant);
|
GetProperty(const SpeciesVariant*, Variant);
|
||||||
GetProperty(uint8_t, Level);
|
GetProperty(uint8_t, Level);
|
||||||
GetProperty(uint32_t, Experience);
|
GetProperty(uint32_t, Experience);
|
||||||
GetProperty(Core::StatisticSet, StatExperience);
|
GetProperty(Core::StatisticSet<uint8_t >, StatExperience);
|
||||||
GetProperty(Core::StatisticSet, StatPotential);
|
GetProperty(Core::StatisticSet<uint8_t >, StatPotential);
|
||||||
GetProperty(uint32_t, UniqueIdentifier);
|
GetProperty(uint32_t, UniqueIdentifier);
|
||||||
GetProperty(Gender, Gender);
|
GetProperty(Gender, Gender);
|
||||||
GetProperty(uint8_t, Coloring);
|
GetProperty(uint8_t, Coloring);
|
||||||
|
@ -26,15 +26,18 @@ namespace CreatureLib::Library{
|
||||||
int8_t _talentIndex;
|
int8_t _talentIndex;
|
||||||
public:
|
public:
|
||||||
Creature(const DataLibrary* library, const CreatureSpecies* species, const SpeciesVariant* variant,
|
Creature(const DataLibrary* library, const CreatureSpecies* species, const SpeciesVariant* variant,
|
||||||
uint8_t level, std::string nickname, int8_t talentIndex, Core::StatisticSet statExperience,
|
uint8_t level, std::string nickname, int8_t talentIndex, Core::StatisticSet<uint8_t > statExperience,
|
||||||
Core::StatisticSet statPotential, uint32_t identifier, Gender gender,
|
Core::StatisticSet<uint8_t > statPotential, uint32_t identifier, Gender gender,
|
||||||
uint8_t coloring, const Item* heldItem);
|
uint8_t coloring, const Item* heldItem);
|
||||||
|
|
||||||
virtual ~Creature(){}
|
virtual ~Creature(){}
|
||||||
|
|
||||||
std::string GetTalent() const;
|
std::string GetTalent() const;
|
||||||
std::string GetNickname() const;
|
std::string GetNickname() const;
|
||||||
virtual int32_t CalculateFullStat(Core::Statistic stat) const;
|
virtual uint32_t CalculateFullStat(Core::Statistic stat) const;
|
||||||
|
virtual uint16_t GetBaseStat(Core::Statistic stat) const;
|
||||||
|
virtual uint8_t GetStatPotential(Core::Statistic stat) const;
|
||||||
|
virtual uint8_t GetStatExperience(Core::Statistic stat) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ int8_t CreatureLib::Library::SpeciesVariant::GetRandomTalent(CreatureLib::Core::
|
||||||
|
|
||||||
CreatureLib::Library::SpeciesVariant::SpeciesVariant(std::string name, float height, float weight,
|
CreatureLib::Library::SpeciesVariant::SpeciesVariant(std::string name, float height, float weight,
|
||||||
uint32_t baseExperience, std::vector<std::string> types,
|
uint32_t baseExperience, std::vector<std::string> types,
|
||||||
CreatureLib::Core::StatisticSet baseStats,
|
CreatureLib::Core::StatisticSet<uint16_t > baseStats,
|
||||||
std::vector<std::string> talents,
|
std::vector<std::string> talents,
|
||||||
std::vector<std::string> secretTalents)
|
std::vector<std::string> secretTalents)
|
||||||
: __Name(name),
|
: __Name(name),
|
||||||
|
|
|
@ -19,13 +19,13 @@ namespace CreatureLib::Library {
|
||||||
GetProperty(uint32_t, BaseExperience);
|
GetProperty(uint32_t, BaseExperience);
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> _types;
|
std::vector<std::string> _types;
|
||||||
const Core::StatisticSet _baseStatistics;
|
const Core::StatisticSet<uint16_t > _baseStatistics;
|
||||||
std::vector<std::string> _talents;
|
std::vector<std::string> _talents;
|
||||||
std::vector<std::string> _secretTalents;
|
std::vector<std::string> _secretTalents;
|
||||||
//CreatureMoves _moves;
|
//CreatureMoves _moves;
|
||||||
public:
|
public:
|
||||||
SpeciesVariant(std::string name, float height, float weight, uint32_t baseExperience,
|
SpeciesVariant(std::string name, float height, float weight, uint32_t baseExperience,
|
||||||
std::vector<std::string> types, Core::StatisticSet baseStats, std::vector<std::string> talents,
|
std::vector<std::string> types, Core::StatisticSet<uint16_t > baseStats, std::vector<std::string> talents,
|
||||||
std::vector<std::string> secretTalents);
|
std::vector<std::string> secretTalents);
|
||||||
|
|
||||||
[[nodiscard]] size_t GetTypeCount() const;
|
[[nodiscard]] size_t GetTypeCount() const;
|
||||||
|
|
|
@ -9,7 +9,8 @@ static DataLibrary* __library = nullptr;
|
||||||
static SpeciesLibrary* BuildSpeciesLibrary(){
|
static SpeciesLibrary* BuildSpeciesLibrary(){
|
||||||
auto l = new SpeciesLibrary();
|
auto l = new SpeciesLibrary();
|
||||||
l->LoadSpecies("testSpecies1", new CreatureSpecies(0, "testSpecies1",
|
l->LoadSpecies("testSpecies1", new CreatureSpecies(0, "testSpecies1",
|
||||||
new SpeciesVariant("default", 1,1, 10, {"fire", "water"}, StatisticSet(10,10,10,10,10,10),
|
new SpeciesVariant("default", 1,1, 10, {"fire", "water"},
|
||||||
|
StatisticSet<uint16_t >(10,10,10,10,10,10),
|
||||||
{"testTalent"}, {"testSecretTalent"}),
|
{"testTalent"}, {"testSecretTalent"}),
|
||||||
0.5f, "testGrowthRate", 5, 100));
|
0.5f, "testGrowthRate", 5, 100));
|
||||||
return l;
|
return l;
|
||||||
|
|
Loading…
Reference in New Issue