Initial commit.
This commit is contained in:
commit
9a45d34f9f
|
@ -0,0 +1,121 @@
|
||||||
|
# ClangFormatConfigureSource: 'LLVM'
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 120
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Merge
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Cpp11
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
...
|
|
@ -0,0 +1,3 @@
|
||||||
|
/cmake-build-debug/
|
||||||
|
/cmake-build-release/
|
||||||
|
/.idea/
|
|
@ -0,0 +1,53 @@
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
# Make warnings trigger errors.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
|
project(pkmnLib)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
if (WINDOWS)
|
||||||
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||||
|
endif(WINDOWS)
|
||||||
|
|
||||||
|
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
|
conan_basic_setup()
|
||||||
|
else ()
|
||||||
|
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
message(STATUS "Using ${CMAKE_CXX_COMPILER}")
|
||||||
|
|
||||||
|
# Create Core library with files in src/Core
|
||||||
|
file(GLOB_RECURSE CORE_SRC_FILES "src/*.cpp" "src/*.hpp")
|
||||||
|
add_library(pkmnLib SHARED ${CORE_SRC_FILES})
|
||||||
|
|
||||||
|
if (NOT DEFINED CONAN_EXPORTED)
|
||||||
|
# Create Test executable
|
||||||
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||||
|
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
foreach (_variableName ${CONAN_LIBS})
|
||||||
|
message(STATUS "Lib: ${_variableName}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
#target_link_libraries(pkmnLib ${CONAN_LIBS})
|
||||||
|
conan_target_link_libraries(pkmnLib)
|
||||||
|
target_link_libraries(pkmnLibTests pkmnLib)
|
||||||
|
|
||||||
|
if (WINDOWS)
|
||||||
|
message(STATUS "Using Windows build.")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
|
||||||
|
# Statically link libraries we need in Windows.
|
||||||
|
target_link_libraries(pkmnLib -static -static-libgcc -static-libstdc++)
|
||||||
|
target_link_libraries(pkmnLibTests -static -static-libgcc -static-libstdc++)
|
||||||
|
endif (WINDOWS)
|
||||||
|
|
||||||
|
# Add a definition for the test library
|
||||||
|
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
from conans import ConanFile, CMake
|
||||||
|
|
||||||
|
|
||||||
|
class PkmnLibConan(ConanFile):
|
||||||
|
name = "PkmnLib"
|
||||||
|
license = "TODO"
|
||||||
|
url = "https://git.p-epsilon.com/Deukhoofd/CreatureLib"
|
||||||
|
description = "The core implementation for turn based battling using creatures."
|
||||||
|
settings = "compiler"
|
||||||
|
options = {"shared": [True, False]}
|
||||||
|
default_options = {"shared": True}
|
||||||
|
generators = "cmake"
|
||||||
|
exports_sources = "*"
|
||||||
|
compiler = "clang"
|
||||||
|
requires = "CreatureLib/d26670082260d3eaab2126dc02c5e2fe674e0076@creaturelib/master"
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure()
|
||||||
|
cmake.build()
|
||||||
|
|
||||||
|
# Explicit way:
|
||||||
|
# self.run('cmake "%s/src" %s' % (self.source_folder, cmake.command_line))
|
||||||
|
# self.run("cmake --build . %s" % cmake.build_config)
|
||||||
|
|
||||||
|
def package(self):
|
||||||
|
self.copy("*.hpp", dst="include", src="src")
|
||||||
|
self.copy("*.lib", dst="lib", keep_path=False)
|
||||||
|
self.copy("*.dll", dst="bin", keep_path=False)
|
||||||
|
self.copy("*.dylib*", dst="lib", keep_path=False)
|
||||||
|
self.copy("*.so", dst="lib", keep_path=False)
|
||||||
|
self.copy("*.a", dst="lib", keep_path=False)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef PKMNLIB_MOVECATEGORY_HPP
|
||||||
|
#define PKMNLIB_MOVECATEGORY_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
enum class MoveCategory : uint8_t { Physical, Special, Status };
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_MOVECATEGORY_HPP
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "MoveData.hpp"
|
||||||
|
#include <unitypes.h>
|
||||||
|
PkmnLib::Library::MoveData::MoveData(std::string name, std::string type, PkmnLib::Library::MoveCategory category,
|
||||||
|
uint8_t power, uint8_t accuracy, uint8_t baseUsage,
|
||||||
|
CreatureLib::Library::AttackTarget target, uint8_t priority,
|
||||||
|
std::unordered_set<std::string> flags)
|
||||||
|
: AttackData(name, type, static_cast<CreatureLib::Library::AttackCategory>(category), power, accuracy, baseUsage,
|
||||||
|
target, priority, flags) {}
|
||||||
|
|
||||||
|
PkmnLib::Library::MoveCategory PkmnLib::Library::MoveData::GetCategory() const {
|
||||||
|
return static_cast<PkmnLib::Library::MoveCategory>(AttackData::GetCategory());
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef PKMNLIB_MOVEDATA_HPP
|
||||||
|
#define PKMNLIB_MOVEDATA_HPP
|
||||||
|
|
||||||
|
#include <Library/Attacks/AttackData.hpp>
|
||||||
|
#include <unitypes.h>
|
||||||
|
#include "MoveCategory.hpp"
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class MoveData : public CreatureLib::Library::AttackData {
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
MoveData(std::string name, std::string type, PkmnLib::Library::MoveCategory category, uint8_t power,
|
||||||
|
uint8_t accuracy, uint8_t baseUsage, CreatureLib::Library::AttackTarget target, uint8_t priority,
|
||||||
|
std::unordered_set<std::string> flags);
|
||||||
|
|
||||||
|
PkmnLib::Library::MoveCategory GetCategory() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_MOVEDATA_HPP
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "MoveLibrary.hpp"
|
||||||
|
const CreatureLib::Library::AttackData* PkmnLib::Library::MoveLibrary::operator[](const std::string& name) const {
|
||||||
|
return AttackLibrary::operator[](name);
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef PKMNLIB_MOVELIBRARY_HPP
|
||||||
|
#define PKMNLIB_MOVELIBRARY_HPP
|
||||||
|
|
||||||
|
#include <Library/AttackLibrary.hpp>
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class MoveLibrary : public CreatureLib::Library::AttackLibrary {
|
||||||
|
public:
|
||||||
|
virtual const CreatureLib::Library::AttackData* operator[](const std::string& name) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_MOVELIBRARY_HPP
|
|
@ -0,0 +1 @@
|
||||||
|
#include "PokemonLibrary.hpp"
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef PKMNLIB_POKEMONLIBRARY_HPP
|
||||||
|
#define PKMNLIB_POKEMONLIBRARY_HPP
|
||||||
|
|
||||||
|
#include <Library/DataLibrary.hpp>
|
||||||
|
#include "Species/SpeciesLibrary.hpp"
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class PokemonLibrary : public CreatureLib::Library::DataLibrary {
|
||||||
|
public:
|
||||||
|
PokemonLibrary(CreatureLib::Library::LibrarySettings settings, PkmnLib::Library::SpeciesLibrary* species,
|
||||||
|
CreatureLib::Library::AttackLibrary* attacks, CreatureLib::Library::ItemLibrary* items,
|
||||||
|
CreatureLib::Library::GrowthRateLibrary* growthRates,
|
||||||
|
CreatureLib::Library::TypeLibrary* typeLibrary)
|
||||||
|
: DataLibrary(settings, species, attacks, items, growthRates, typeLibrary) {}
|
||||||
|
const PkmnLib::Library::SpeciesLibrary* GetSpeciesLibrary() const {
|
||||||
|
return reinterpret_cast<const PkmnLib::Library::SpeciesLibrary*>(
|
||||||
|
CreatureLib::Library::DataLibrary::GetSpeciesLibrary());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_POKEMONLIBRARY_HPP
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "PokemonForme.hpp"
|
||||||
|
PkmnLib::Library::PokemonForme::PokemonForme(std::string name, float height, float weight, uint32_t baseExperience,
|
||||||
|
std::vector<uint8_t> types,
|
||||||
|
CreatureLib::Core::StatisticSet<uint16_t> baseStats,
|
||||||
|
std::vector<std::string> talents, std::vector<std::string> secretTalents,
|
||||||
|
const CreatureLib::Library::LearnableAttacks* attacks)
|
||||||
|
: SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks) {}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef PKMNLIB_POKEMONFORME_HPP
|
||||||
|
#define PKMNLIB_POKEMONFORME_HPP
|
||||||
|
|
||||||
|
#include <Library/CreatureData/SpeciesVariant.hpp>
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class PokemonForme : public CreatureLib::Library::SpeciesVariant {
|
||||||
|
public:
|
||||||
|
PokemonForme(std::string name, float height, float weight, uint32_t baseExperience, std::vector<uint8_t> types,
|
||||||
|
CreatureLib::Core::StatisticSet<uint16_t> baseStats, std::vector<std::string> talents,
|
||||||
|
std::vector<std::string> secretTalents, const CreatureLib::Library::LearnableAttacks* attacks);
|
||||||
|
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_POKEMONFORME_HPP
|
|
@ -0,0 +1 @@
|
||||||
|
#include "PokemonSpecies.hpp"
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef PKMNLIB_POKEMONSPECIES_HPP
|
||||||
|
#define PKMNLIB_POKEMONSPECIES_HPP
|
||||||
|
#include <Battling/Models/Creature.hpp>
|
||||||
|
#include "PokemonForme.hpp"
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class PokemonSpecies : public CreatureLib::Library::CreatureSpecies {
|
||||||
|
private:
|
||||||
|
uint8_t _baseHappiness;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PokemonSpecies(uint16_t id, const std::string& name, const PokemonForme* defaultVariant, float genderRatio,
|
||||||
|
const std::string& growthRate, uint8_t captureRate, uint8_t baseHappiness)
|
||||||
|
: CreatureSpecies(id, name, defaultVariant, genderRatio, growthRate, captureRate),
|
||||||
|
_baseHappiness(baseHappiness) {}
|
||||||
|
|
||||||
|
inline uint8_t GetBaseHappiness() const { return _baseHappiness; }
|
||||||
|
|
||||||
|
inline const PokemonForme* GetDefaultForme() const {
|
||||||
|
return reinterpret_cast<const PokemonForme*>(CreatureSpecies::GetVariant("default"));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const PokemonForme* GetForme(const std::string& key) const {
|
||||||
|
return reinterpret_cast<const PokemonForme*>(CreatureSpecies::GetVariant(key));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_POKEMONSPECIES_HPP
|
|
@ -0,0 +1 @@
|
||||||
|
#include "SpeciesLibrary.hpp"
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef PKMNLIB_SPECIESLIBRARY_HPP
|
||||||
|
#define PKMNLIB_SPECIESLIBRARY_HPP
|
||||||
|
|
||||||
|
#include <Library/SpeciesLibrary.hpp>
|
||||||
|
#include "PokemonSpecies.hpp"
|
||||||
|
|
||||||
|
namespace PkmnLib::Library {
|
||||||
|
class SpeciesLibrary : public CreatureLib::Library::SpeciesLibrary {
|
||||||
|
public:
|
||||||
|
inline const PokemonSpecies* GetPkmnSpecies(const std::string& name) const {
|
||||||
|
return reinterpret_cast<const PokemonSpecies*>(CreatureLib::Library::SpeciesLibrary::GetSpecies(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
const PokemonSpecies* operator[](const std::string& name) const { return GetPkmnSpecies(name); }
|
||||||
|
|
||||||
|
void LoadSpecies(const std::string& name, const PokemonSpecies* species){
|
||||||
|
CreatureLib::Library::SpeciesLibrary::LoadSpecies(name, species);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_SPECIESLIBRARY_HPP
|
|
@ -0,0 +1,40 @@
|
||||||
|
#ifdef TESTS_BUILD
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "../../extern/catch.hpp"
|
||||||
|
#include "../../src/Library/Species/SpeciesLibrary.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("Able to build and destroy empty library", "library") {
|
||||||
|
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||||
|
delete lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to build, destroy and insert library", "library") {
|
||||||
|
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||||
|
lib->LoadSpecies("foo",
|
||||||
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0},
|
||||||
|
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||||
|
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100));
|
||||||
|
delete lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to insert and retrieve from library", "library") {
|
||||||
|
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||||
|
lib->LoadSpecies("foo",
|
||||||
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0},
|
||||||
|
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||||
|
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100));
|
||||||
|
auto val = lib->GetSpecies("foo");
|
||||||
|
REQUIRE(val->GetName() == "foo");
|
||||||
|
delete lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,124 @@
|
||||||
|
#ifdef TESTS_BUILD
|
||||||
|
#include "../../extern/catch.hpp"
|
||||||
|
#include "../../src/Library/Species/PokemonSpecies.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("Able to create and destroy species", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get default forme", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
auto forme = species->GetDefaultForme();
|
||||||
|
REQUIRE(forme != nullptr);
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get default forme name", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
auto forme = species->GetDefaultForme();
|
||||||
|
REQUIRE(forme != nullptr);
|
||||||
|
REQUIRE(forme->GetName() == "default");
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species name", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetName() == "foo");
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species id", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetId() == 1);
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species gender ratio", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetGenderRate() == 0.5f);
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species growth rate", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species capture rate", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetCaptureRate() == 100);
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Able to get species base happiness", "library") {
|
||||||
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||||
|
1, "foo",
|
||||||
|
new PkmnLib::Library::PokemonForme(
|
||||||
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
|
0.5f, "testGrowthRate", 100, 100);
|
||||||
|
|
||||||
|
REQUIRE(species->GetBaseHappiness() == 100);
|
||||||
|
|
||||||
|
delete species;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1 @@
|
||||||
|
#include "TestLibrary.hpp"
|
|
@ -0,0 +1,49 @@
|
||||||
|
#ifndef PKMNLIB_TESTLIBRARY_HPP
|
||||||
|
#define PKMNLIB_TESTLIBRARY_HPP
|
||||||
|
|
||||||
|
#include "../../src/Library/PokemonLibrary.hpp"
|
||||||
|
class TestLibrary {
|
||||||
|
private:
|
||||||
|
static PkmnLib::Library::PokemonLibrary* _library;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static PkmnLib::Library::PokemonLibrary* GetLibrary() {
|
||||||
|
if (_library == nullptr) {
|
||||||
|
_library = BuildLibrary();
|
||||||
|
}
|
||||||
|
return _library;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PkmnLib::Library::PokemonLibrary* BuildLibrary() {
|
||||||
|
return new PkmnLib::Library::PokemonLibrary(CreatureLib::Library::LibrarySettings(100, 4),
|
||||||
|
BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
|
||||||
|
BuildGrowthRateLibrary(), BuildTypeLibrary());
|
||||||
|
}
|
||||||
|
|
||||||
|
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary() {
|
||||||
|
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureLib::Library::AttackLibrary* BuildAttackLibrary() {
|
||||||
|
auto lib = new CreatureLib::Library::AttackLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureLib::Library::ItemLibrary* BuildItemLibrary() {
|
||||||
|
auto lib = new CreatureLib::Library::ItemLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureLib::Library::GrowthRateLibrary* BuildGrowthRateLibrary() {
|
||||||
|
auto lib = new CreatureLib::Library::GrowthRateLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureLib::Library::TypeLibrary* BuildTypeLibrary() {
|
||||||
|
auto lib = new CreatureLib::Library::TypeLibrary();
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PKMNLIB_TESTLIBRARY_HPP
|
Loading…
Reference in New Issue