Updates to latest PkmnLib.
This commit is contained in:
parent
4f50a738a7
commit
761714f2f5
|
@ -5,7 +5,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||||
|
|
||||||
project(Gen7Tests)
|
project(Gen7Tests)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
|
@ -15,14 +15,14 @@ if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
list(GET VERSION_LIST 1 MINOR)
|
list(GET VERSION_LIST 1 MINOR)
|
||||||
if (NOT MINOR MATCHES 0)
|
if (NOT MINOR MATCHES 0)
|
||||||
SET(VERSION ${VERSION}.${MINOR})
|
SET(VERSION ${VERSION}.${MINOR})
|
||||||
endif()
|
endif ()
|
||||||
if (NOT WINDOWS)
|
if (NOT WINDOWS)
|
||||||
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
||||||
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s build_type=Debug)
|
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s build_type=Debug)
|
||||||
else()
|
else ()
|
||||||
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
||||||
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows)
|
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows)
|
||||||
endif()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
conan_basic_setup()
|
conan_basic_setup()
|
||||||
|
@ -30,7 +30,7 @@ conan_basic_setup()
|
||||||
message(STATUS "Using Conan Libs:")
|
message(STATUS "Using Conan Libs:")
|
||||||
foreach (_conanLib ${CONAN_LIBS})
|
foreach (_conanLib ${CONAN_LIBS})
|
||||||
message(STATUS "\t ${_conanLib}")
|
message(STATUS "\t ${_conanLib}")
|
||||||
endforeach()
|
endforeach ()
|
||||||
|
|
||||||
SET(FILE_SOURCE
|
SET(FILE_SOURCE
|
||||||
"src/*.cpp"
|
"src/*.cpp"
|
||||||
|
@ -38,8 +38,10 @@ SET(FILE_SOURCE
|
||||||
)
|
)
|
||||||
file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE})
|
file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE})
|
||||||
add_executable(Gen7Tests ${CORE_SRC_FILES})
|
add_executable(Gen7Tests ${CORE_SRC_FILES})
|
||||||
|
target_precompile_headers(Gen7Tests PUBLIC src/Precompiled.hxx)
|
||||||
|
add_definitions(-DLEVEL_U8)
|
||||||
|
|
||||||
SET(_LINKS CreatureLibLibrary CreatureLibBattling pkmnLib)
|
SET(_LINKS Arbutils CreatureLib pkmnLib)
|
||||||
|
|
||||||
target_link_libraries(Gen7Tests PUBLIC ${_LINKS})
|
target_link_libraries(Gen7Tests PUBLIC ${_LINKS})
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,10 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
||||||
auto lib = new PkmnLib::Library::ItemLibrary();
|
auto lib = new PkmnLib::Library::ItemLibrary();
|
||||||
json j;
|
json j;
|
||||||
fileStream >> j;
|
fileStream >> j;
|
||||||
for (auto i : j.items()) {
|
for (const auto& i : j.items()) {
|
||||||
|
if (i.key().starts_with("$")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto val = i.value();
|
auto val = i.value();
|
||||||
GET(val, name, i);
|
GET(val, name, i);
|
||||||
GET(val, itemType, i);
|
GET(val, itemType, i);
|
||||||
|
@ -55,12 +58,41 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) {
|
||||||
|
|
||||||
auto flags = std::unordered_set<uint>();
|
auto flags = std::unordered_set<uint>();
|
||||||
for (auto flagIndex : _flags.items()) {
|
for (auto flagIndex : _flags.items()) {
|
||||||
flags.insert(Arbutils::CaseInsensitiveConstString::GetHash(flagIndex.value().get<std::string>()));
|
flags.insert(ArbUt::StringView(flagIndex.value().get<std::string>().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto item = new PkmnLib::Library::Item(Arbutils::CaseInsensitiveConstString(_name.get<std::string>()), itemType,
|
CreatureLib::Library::SecondaryEffect* effect = nullptr;
|
||||||
|
auto effectJson = val["effect"];
|
||||||
|
if (effectJson != nullptr) {
|
||||||
|
auto effectName = effectJson["name"];
|
||||||
|
auto parametersJson = effectJson["parameters"];
|
||||||
|
ArbUt::List<CreatureLib::Library::EffectParameter*> parameters;
|
||||||
|
if (parametersJson != nullptr) {
|
||||||
|
for (auto& kv : parametersJson.items()) {
|
||||||
|
auto& p = kv.value();
|
||||||
|
auto t = p.type();
|
||||||
|
switch (t) {
|
||||||
|
case json::value_t::boolean:
|
||||||
|
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<bool>()));
|
||||||
|
break;
|
||||||
|
case json::value_t::number_integer:
|
||||||
|
case json::value_t::number_unsigned:
|
||||||
|
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<int64_t>()));
|
||||||
|
break;
|
||||||
|
case json::value_t::number_float:
|
||||||
|
parameters.Append(new CreatureLib::Library::EffectParameter(p.get<float>()));
|
||||||
|
break;
|
||||||
|
default: continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
effect = new CreatureLib::Library::SecondaryEffect(
|
||||||
|
100, ArbUt::StringView(effectName.get<std::string>().c_str()), parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto item = new PkmnLib::Library::Item(ArbUt::StringView(_name.get<std::string>().c_str()), itemType,
|
||||||
CreatureLib::Library::BattleItemCategory::None, _price.get<int32_t>(),
|
CreatureLib::Library::BattleItemCategory::None, _price.get<int32_t>(),
|
||||||
flags, _flingPower.get<uint8_t>());
|
effect, flags, _flingPower.get<uint8_t>());
|
||||||
lib->Insert(item->GetName(), item);
|
lib->Insert(item->GetName(), item);
|
||||||
}
|
}
|
||||||
return lib;
|
return lib;
|
||||||
|
|
|
@ -33,7 +33,7 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||||
auto lib = new PkmnLib::Library::MoveLibrary();
|
auto lib = new PkmnLib::Library::MoveLibrary();
|
||||||
json j;
|
json j;
|
||||||
fileStream >> j;
|
fileStream >> j;
|
||||||
for (auto i : j.items()) {
|
for (const auto& i : j["data"].items()) {
|
||||||
auto val = i.value();
|
auto val = i.value();
|
||||||
GET(val, name, i);
|
GET(val, name, i);
|
||||||
GET(val, type, i);
|
GET(val, type, i);
|
||||||
|
@ -46,7 +46,7 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||||
GET(val, flags, i);
|
GET(val, flags, i);
|
||||||
if (_pp.get<uint8_t>() == 0)
|
if (_pp.get<uint8_t>() == 0)
|
||||||
continue;
|
continue;
|
||||||
auto type = types->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(_type.get<std::string>()));
|
auto type = types->GetTypeId(ArbUt::StringView(_type.get<std::string>().c_str()));
|
||||||
auto category = ParseCategory(_category.get<std::string>());
|
auto category = ParseCategory(_category.get<std::string>());
|
||||||
if (static_cast<int>(category) == 255)
|
if (static_cast<int>(category) == 255)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -58,7 +58,7 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||||
}
|
}
|
||||||
auto flags = std::unordered_set<uint32_t>();
|
auto flags = std::unordered_set<uint32_t>();
|
||||||
for (auto flagIndex : _flags.items()) {
|
for (auto flagIndex : _flags.items()) {
|
||||||
flags.insert(Arbutils::CaseInsensitiveConstString::GetHash(flagIndex.value().get<std::string>()));
|
flags.insert(ArbUt::StringView(flagIndex.value().get<std::string>().c_str()));
|
||||||
}
|
}
|
||||||
CreatureLib::Library::SecondaryEffect* effect = nullptr;
|
CreatureLib::Library::SecondaryEffect* effect = nullptr;
|
||||||
auto jsonEffect = val["effect"];
|
auto jsonEffect = val["effect"];
|
||||||
|
@ -67,7 +67,7 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||||
auto chanceJson = jsonEffect["chance"];
|
auto chanceJson = jsonEffect["chance"];
|
||||||
auto parametersJson = jsonEffect["parameters"];
|
auto parametersJson = jsonEffect["parameters"];
|
||||||
if (name != nullptr) {
|
if (name != nullptr) {
|
||||||
List<CreatureLib::Library::EffectParameter*> parameters;
|
ArbUt::List<CreatureLib::Library::EffectParameter*> parameters;
|
||||||
auto chance = -1.0f;
|
auto chance = -1.0f;
|
||||||
if (chanceJson != nullptr) {
|
if (chanceJson != nullptr) {
|
||||||
chance = chanceJson.get<float>();
|
chance = chanceJson.get<float>();
|
||||||
|
@ -93,18 +93,18 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
effect = new CreatureLib::Library::SecondaryEffect(
|
effect = new CreatureLib::Library::SecondaryEffect(
|
||||||
chance, Arbutils::CaseInsensitiveConstString(name.get<std::string>()), parameters);
|
chance, ArbUt::StringView(name.get<std::string>().c_str()), parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (effect == nullptr) {
|
if (effect == nullptr) {
|
||||||
effect = new CreatureLib::Library::SecondaryEffect();
|
effect = new CreatureLib::Library::SecondaryEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto move = new PkmnLib::Library::MoveData(Arbutils::CaseInsensitiveConstString(_name.get<std::string>()), type,
|
auto move = new PkmnLib::Library::MoveData(ArbUt::StringView(_name.get<std::string>().c_str()), type, category,
|
||||||
category, _power.get<uint8_t>(), _accuracy.get<uint8_t>(),
|
_power.get<uint8_t>(), _accuracy.get<uint8_t>(), _pp.get<uint8_t>(),
|
||||||
_pp.get<uint8_t>(), target, _priority.get<int8_t>(), effect, flags);
|
target, _priority.get<int8_t>(), effect, flags);
|
||||||
|
|
||||||
lib->Insert(Arbutils::CaseInsensitiveConstString(move->GetName()), move);
|
lib->Insert(ArbUt::StringView(move->GetName().c_str()), move);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
|
|
|
@ -80,7 +80,7 @@ PkmnLib::Library::NatureLibrary* BuildNatures::Build(const std::string& path) {
|
||||||
|
|
||||||
std::cout << "Registered nature with name '" << natureName << "'.\n";
|
std::cout << "Registered nature with name '" << natureName << "'.\n";
|
||||||
library->LoadNature(
|
library->LoadNature(
|
||||||
Arbutils::CaseInsensitiveConstString(natureName),
|
ArbUt::StringView(natureName.c_str()),
|
||||||
new PkmnLib::Library::Nature(parsedIncreased, parsedDecreased, increasedModifier, decreasedModifier));
|
new PkmnLib::Library::Nature(parsedIncreased, parsedDecreased, increasedModifier, decreasedModifier));
|
||||||
}
|
}
|
||||||
return library;
|
return library;
|
||||||
|
|
|
@ -22,6 +22,9 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string&
|
||||||
fileStream >> j;
|
fileStream >> j;
|
||||||
|
|
||||||
for (json::iterator it = j.begin(); it != j.end(); ++it) {
|
for (json::iterator it = j.begin(); it != j.end(); ++it) {
|
||||||
|
if (it.key().starts_with("$")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
auto val = it.value();
|
auto val = it.value();
|
||||||
GET(val, id, it.key());
|
GET(val, id, it.key());
|
||||||
GET(val, species, it.key());
|
GET(val, species, it.key());
|
||||||
|
@ -38,14 +41,19 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string&
|
||||||
|
|
||||||
PkmnLib::Library::PokemonSpecies* species = nullptr;
|
PkmnLib::Library::PokemonSpecies* species = nullptr;
|
||||||
|
|
||||||
|
ArbUt::List<ArbUt::StringView> eggGroups;
|
||||||
|
for (const auto& eg : _eggGroups){
|
||||||
|
eggGroups.Append(eg.get<std::string>().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
auto defaultForme = _formes["default"];
|
auto defaultForme = _formes["default"];
|
||||||
if (!defaultForme.is_null()) {
|
if (!defaultForme.is_null()) {
|
||||||
auto forme = BuildForme("default", defaultForme, it.key(), path, types);
|
auto forme = BuildForme("default", defaultForme, it.key(), path, types);
|
||||||
species = new PkmnLib::Library::PokemonSpecies(
|
species = new PkmnLib::Library::PokemonSpecies(
|
||||||
_id.get<uint16_t>(), Arbutils::CaseInsensitiveConstString(_species.get<std::string>()), forme,
|
_id.get<uint16_t>(), ArbUt::StringView(_species.get<std::string>().c_str()), forme,
|
||||||
_genderRatio.get<int8_t>() / static_cast<float>(100),
|
_genderRatio.get<int8_t>() / static_cast<float>(100),
|
||||||
Arbutils::CaseInsensitiveConstString(_growthRate.get<std::string>()), _catchRate.get<uint8_t>(),
|
ArbUt::StringView(_growthRate.get<std::string>().c_str()), _catchRate.get<uint8_t>(),
|
||||||
_baseHappiness.get<uint8_t>());
|
_baseHappiness.get<uint8_t>(), eggGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (json::iterator formeIt = _formes.begin(); formeIt != _formes.end(); ++formeIt) {
|
for (json::iterator formeIt = _formes.begin(); formeIt != _formes.end(); ++formeIt) {
|
||||||
|
@ -57,25 +65,25 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string&
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (species == nullptr) {
|
if (species == nullptr) {
|
||||||
species = new PkmnLib::Library::PokemonSpecies(
|
species = new PkmnLib::Library::PokemonSpecies(
|
||||||
_id.get<uint16_t>(), Arbutils::CaseInsensitiveConstString(_species.get<std::string>()), forme,
|
_id.get<uint16_t>(), ArbUt::StringView(_species.get<std::string>().c_str()), forme,
|
||||||
static_cast<float>(_genderRatio.get<int8_t>()) / static_cast<float>(100),
|
static_cast<float>(_genderRatio.get<int8_t>()) / static_cast<float>(100),
|
||||||
Arbutils::CaseInsensitiveConstString(_growthRate.get<std::string>()), _catchRate.get<uint8_t>(),
|
ArbUt::StringView(_growthRate.get<std::string>().c_str()), _catchRate.get<uint8_t>(),
|
||||||
_baseHappiness.get<uint8_t>());
|
_baseHappiness.get<uint8_t>(), eggGroups);
|
||||||
} else {
|
} else {
|
||||||
if (species->HasForme(Arbutils::CaseInsensitiveConstString(formeIt.key()))) {
|
if (species->HasForme(ArbUt::StringView(formeIt.key().c_str()))) {
|
||||||
std::cout << "Species '" << it.key() << "' has duplicate forme '" << formeIt.key()
|
std::cout << "Species '" << it.key() << "' has duplicate forme '" << formeIt.key()
|
||||||
<< "'. Skipping.\n";
|
<< "'. Skipping.\n";
|
||||||
delete forme;
|
delete forme;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
species->SetVariant(Arbutils::CaseInsensitiveConstString(formeIt.key()), forme);
|
species->SetVariant(ArbUt::StringView(formeIt.key().c_str()), forme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (species == nullptr) {
|
if (species == nullptr) {
|
||||||
std::cout << "Pokemon with key '" << it.key() << "' does not have any formes.\n";
|
std::cout << "Pokemon with key '" << it.key() << "' does not have any formes.\n";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
lib->Insert(Arbutils::CaseInsensitiveConstString(it.key()), species);
|
lib->Insert(ArbUt::StringView(it.key().c_str()), species);
|
||||||
}
|
}
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
@ -100,24 +108,24 @@ const PkmnLib::Library::PokemonForme* BuildSpecies::BuildForme(const std::string
|
||||||
GET(forme, moves, baseKeyName << " -> " << name);
|
GET(forme, moves, baseKeyName << " -> " << name);
|
||||||
|
|
||||||
auto typeStrings = _types.get<std::vector<std::string>>();
|
auto typeStrings = _types.get<std::vector<std::string>>();
|
||||||
auto types = List<uint8_t>(typeStrings.size());
|
auto types = ArbUt::List<uint8_t>(typeStrings.size());
|
||||||
for (auto i = 0; i < typeStrings.size(); i++) {
|
for (size_t i = 0; i < typeStrings.size(); i++) {
|
||||||
types[i] = typeLibrary->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(typeStrings[i]));
|
types.Append(typeLibrary->GetTypeId(ArbUt::StringView(typeStrings[i].c_str())));
|
||||||
}
|
}
|
||||||
auto stats = ParseStatistics(_baseStats);
|
auto stats = ParseStatistics(_baseStats);
|
||||||
|
|
||||||
auto abilityStrings = _abilities.get<std::vector<std::string>>();
|
auto abilityStrings = _abilities.get<std::vector<std::string>>();
|
||||||
auto abilities = List<Arbutils::CaseInsensitiveConstString>(abilityStrings.size());
|
auto abilities = ArbUt::List<ArbUt::StringView>(abilityStrings.size());
|
||||||
for (auto i = 0; i < abilityStrings.size(); i++) {
|
for (size_t i = 0; i < abilityStrings.size(); i++) {
|
||||||
abilities[i] = Arbutils::CaseInsensitiveConstString(abilityStrings[i]);
|
abilities.Append(ArbUt::StringView(abilityStrings[i].c_str()));
|
||||||
}
|
}
|
||||||
auto hiddenAbilityStrings = _abilities.get<std::vector<std::string>>();
|
auto hiddenAbilityStrings = _abilities.get<std::vector<std::string>>();
|
||||||
auto hiddenAbilities = List<Arbutils::CaseInsensitiveConstString>(hiddenAbilityStrings.size());
|
auto hiddenAbilities = ArbUt::List<ArbUt::StringView>(hiddenAbilityStrings.size());
|
||||||
for (auto i = 0; i < hiddenAbilityStrings.size(); i++) {
|
for (size_t i = 0; i < hiddenAbilityStrings.size(); i++) {
|
||||||
hiddenAbilities[i] = Arbutils::CaseInsensitiveConstString(abilityStrings[i]);
|
hiddenAbilities.Append(ArbUt::StringView(abilityStrings[i].c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PkmnLib::Library::PokemonForme(Arbutils::CaseInsensitiveConstString(name), _height.get<float>(),
|
return new PkmnLib::Library::PokemonForme(ArbUt::StringView(name.c_str()), _height.get<float>(),
|
||||||
_weight.get<float>(), _baseExp.get<uint32_t>(), types, stats, abilities,
|
_weight.get<float>(), _baseExp.get<uint32_t>(), types, stats, abilities,
|
||||||
hiddenAbilities, nullptr);
|
hiddenAbilities, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#ifndef GEN7TESTS_BUILDSPECIES_HPP
|
#ifndef GEN7TESTS_BUILDSPECIES_HPP
|
||||||
#define GEN7TESTS_BUILDSPECIES_HPP
|
#define GEN7TESTS_BUILDSPECIES_HPP
|
||||||
|
#define LEVEL_U8 1
|
||||||
#include <PkmnLib/Library/PokemonLibrary.hpp>
|
#include <PkmnLib/Library/PokemonLibrary.hpp>
|
||||||
#include <CreatureLib/Library/TypeLibrary.hpp>
|
#include <CreatureLib/Library/TypeLibrary.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -27,7 +27,7 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) {
|
||||||
lastStart = i + 1;
|
lastStart = i + 1;
|
||||||
if (hasSkippedFirst) {
|
if (hasSkippedFirst) {
|
||||||
std::cout << "Registered type: " << substr << "\n";
|
std::cout << "Registered type: " << substr << "\n";
|
||||||
auto val = library->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(substr));
|
auto val = library->RegisterType(ArbUt::StringView(substr.c_str()));
|
||||||
types.push_back(val);
|
types.push_back(val);
|
||||||
} else {
|
} else {
|
||||||
hasSkippedFirst = true;
|
hasSkippedFirst = true;
|
||||||
|
@ -37,7 +37,7 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) {
|
||||||
}
|
}
|
||||||
auto substr = line.substr(lastStart, line.length() - lastStart);
|
auto substr = line.substr(lastStart, line.length() - lastStart);
|
||||||
std::cout << "Registered type: " << substr << "\n";
|
std::cout << "Registered type: " << substr << "\n";
|
||||||
auto val = library->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(substr));
|
auto val = library->RegisterType(ArbUt::StringView(substr.c_str()));
|
||||||
types.push_back(val);
|
types.push_back(val);
|
||||||
|
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
|
@ -55,7 +55,7 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) {
|
||||||
current++;
|
current++;
|
||||||
} else {
|
} else {
|
||||||
gotType = true;
|
gotType = true;
|
||||||
attackingType = library->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(substr));
|
attackingType = library->GetTypeId(ArbUt::StringView(substr.c_str()));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ CreatureLib::Library::GrowthRateLibrary* GrowthRatesBuilder::Build(const std::st
|
||||||
for (const auto& i : j.items()) {
|
for (const auto& i : j.items()) {
|
||||||
const auto& name = i.key();
|
const auto& name = i.key();
|
||||||
auto values = i.value();
|
auto values = i.value();
|
||||||
lib->AddGrowthRate(Arbutils::CaseInsensitiveConstString(name),
|
lib->AddGrowthRate(ArbUt::StringView(name.c_str()),
|
||||||
new LookupGrowthRate(values.get<std::vector<uint32_t>>()));
|
new LookupGrowthRate(values.get<std::vector<uint32_t>>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef GEN7TESTS_GROWTHRATESBUILDER_HPP
|
#ifndef GEN7TESTS_GROWTHRATESBUILDER_HPP
|
||||||
#define GEN7TESTS_GROWTHRATESBUILDER_HPP
|
#define GEN7TESTS_GROWTHRATESBUILDER_HPP
|
||||||
|
|
||||||
|
#define LEVEL_U8 1
|
||||||
#include <CreatureLib/Library/GrowthRates/GrowthRate.hpp>
|
#include <CreatureLib/Library/GrowthRates/GrowthRate.hpp>
|
||||||
#include <CreatureLib/Library/GrowthRates/GrowthRateLibrary.hpp>
|
#include <CreatureLib/Library/GrowthRates/GrowthRateLibrary.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
#define CHECK_NATURE_NEUTRAL(name) \
|
#define CHECK_NATURE_NEUTRAL(name) \
|
||||||
{ \
|
{ \
|
||||||
auto nature = natureLib->GetNatureByName(Arbutils::CaseInsensitiveConstString(#name)); \
|
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
||||||
CHECK(nature->GetIncreaseModifier() == Approx(1.0)); \
|
CHECK(nature->GetIncreaseModifier() == Approx(1.0)); \
|
||||||
CHECK(nature->GetDecreaseModifier() == Approx(1.0)); \
|
CHECK(nature->GetDecreaseModifier() == Approx(1.0)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_NATURE(name, increasedStat, decreasedStat) \
|
#define CHECK_NATURE(name, increasedStat, decreasedStat) \
|
||||||
{ \
|
{ \
|
||||||
auto nature = natureLib->GetNatureByName(Arbutils::CaseInsensitiveConstString(#name)); \
|
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
||||||
CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \
|
CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \
|
||||||
CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \
|
CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \
|
||||||
CHECK(nature->GetIncreaseModifier() == Approx(1.1)); \
|
CHECK(nature->GetIncreaseModifier() == Approx(1.1)); \
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#include "../../extern/catch.hpp"
|
#include "../../extern/catch.hpp"
|
||||||
#include "../Library.hpp"
|
#include "../Library.hpp"
|
||||||
|
|
||||||
#define ENSURE_SPECIES_EXISTS(species) \
|
#define ENSURE_SPECIES_EXISTS(species) \
|
||||||
CHECK(library->GetSpeciesLibrary()->Get(Arbutils::CaseInsensitiveConstString(#species))->GetName() == #species);
|
CHECK(library->GetSpeciesLibrary()->Get(ArbUt::StringView(#species))->GetName() == #species);
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure relevant species exist", "[species]") {
|
TEST_CASE("Species - Ensure relevant species exist", "[species]") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
|
@ -18,9 +17,9 @@ TEST_CASE("Species - Ensure species count is valid", "[species]") {
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
|
TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
auto iterator = library->GetSpeciesLibrary()->GetIterator();
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (const auto& v: iterator){
|
auto& lib = library->GetSpeciesLibrary();
|
||||||
|
for (const auto& v : *lib) {
|
||||||
REQUIRE(v.second->HasVariant("default"_cnc.GetHash()));
|
REQUIRE(v.second->HasVariant("default"_cnc.GetHash()));
|
||||||
CHECK(v.second->GetVariant("default"_cnc.GetHash())->GetName() == "default");
|
CHECK(v.second->GetVariant("default"_cnc.GetHash())->GetName() == "default");
|
||||||
i++;
|
i++;
|
||||||
|
@ -30,11 +29,11 @@ TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure each forme has abilities", "[species]") {
|
TEST_CASE("Species - Ensure each forme has abilities", "[species]") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
auto iterator = library->GetSpeciesLibrary()->GetIterator();
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (const auto& v: iterator){
|
auto& lib = library->GetSpeciesLibrary();
|
||||||
for (const auto& forme: v.second->GetVariantsIterator()){
|
for (const auto& v : *lib) {
|
||||||
auto abilities = forme.second->GetTalents();
|
for (const auto& forme : v.second->GetVariantsIterator()) {
|
||||||
|
auto abilities = forme->GetTalents();
|
||||||
CHECK(abilities.Count() != 0);
|
CHECK(abilities.Count() != 0);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
#include "../Library.hpp"
|
#include "../Library.hpp"
|
||||||
|
|
||||||
#define CHECK_EFFECTIVENESS(attack, defense, expected) \
|
#define CHECK_EFFECTIVENESS(attack, defense, expected) \
|
||||||
CHECK(typeLib->GetSingleEffectiveness( \
|
CHECK(typeLib->GetSingleEffectiveness(typeLib->GetTypeId(ArbUt::StringView(#attack)), \
|
||||||
typeLib->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(#attack)), \
|
typeLib->GetTypeId(ArbUt::StringView(#defense))) == expected);
|
||||||
typeLib->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(#defense))) == expected);
|
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Normal, Normal, 1);
|
CHECK_EFFECTIVENESS(Normal, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Normal, Fighting, 1);
|
CHECK_EFFECTIVENESS(Normal, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Normal, Flying, 1);
|
CHECK_EFFECTIVENESS(Normal, Flying, 1);
|
||||||
|
@ -29,7 +28,7 @@ TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fighting, Normal, 2);
|
CHECK_EFFECTIVENESS(Fighting, Normal, 2);
|
||||||
CHECK_EFFECTIVENESS(Fighting, Fighting, 1);
|
CHECK_EFFECTIVENESS(Fighting, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Fighting, Flying, 0.5);
|
CHECK_EFFECTIVENESS(Fighting, Flying, 0.5);
|
||||||
|
@ -51,7 +50,7 @@ TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Flying, Normal, 1);
|
CHECK_EFFECTIVENESS(Flying, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Flying, Fighting, 2);
|
CHECK_EFFECTIVENESS(Flying, Fighting, 2);
|
||||||
CHECK_EFFECTIVENESS(Flying, Flying, 1);
|
CHECK_EFFECTIVENESS(Flying, Flying, 1);
|
||||||
|
@ -73,7 +72,7 @@ TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Poison, Normal, 1);
|
CHECK_EFFECTIVENESS(Poison, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Poison, Fighting, 1);
|
CHECK_EFFECTIVENESS(Poison, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Poison, Flying, 1);
|
CHECK_EFFECTIVENESS(Poison, Flying, 1);
|
||||||
|
@ -95,7 +94,7 @@ TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ground, Normal, 1);
|
CHECK_EFFECTIVENESS(Ground, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Ground, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ground, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Ground, Flying, 0);
|
CHECK_EFFECTIVENESS(Ground, Flying, 0);
|
||||||
|
@ -117,7 +116,7 @@ TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Rock, Normal, 1);
|
CHECK_EFFECTIVENESS(Rock, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Rock, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Rock, Fighting, 0.5);
|
||||||
CHECK_EFFECTIVENESS(Rock, Flying, 2);
|
CHECK_EFFECTIVENESS(Rock, Flying, 2);
|
||||||
|
@ -139,7 +138,7 @@ TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Bug, Normal, 1);
|
CHECK_EFFECTIVENESS(Bug, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Bug, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Bug, Fighting, 0.5);
|
||||||
CHECK_EFFECTIVENESS(Bug, Flying, 0.5);
|
CHECK_EFFECTIVENESS(Bug, Flying, 0.5);
|
||||||
|
@ -161,7 +160,7 @@ TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ghost, Normal, 0);
|
CHECK_EFFECTIVENESS(Ghost, Normal, 0);
|
||||||
CHECK_EFFECTIVENESS(Ghost, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ghost, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Ghost, Flying, 1);
|
CHECK_EFFECTIVENESS(Ghost, Flying, 1);
|
||||||
|
@ -183,7 +182,7 @@ TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Steel, Normal, 1);
|
CHECK_EFFECTIVENESS(Steel, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Steel, Fighting, 1);
|
CHECK_EFFECTIVENESS(Steel, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Steel, Flying, 1);
|
CHECK_EFFECTIVENESS(Steel, Flying, 1);
|
||||||
|
@ -205,7 +204,7 @@ TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fire, Normal, 1);
|
CHECK_EFFECTIVENESS(Fire, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Fire, Fighting, 1);
|
CHECK_EFFECTIVENESS(Fire, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Fire, Flying, 1);
|
CHECK_EFFECTIVENESS(Fire, Flying, 1);
|
||||||
|
@ -227,7 +226,7 @@ TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Water, Normal, 1);
|
CHECK_EFFECTIVENESS(Water, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Water, Fighting, 1);
|
CHECK_EFFECTIVENESS(Water, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Water, Flying, 1);
|
CHECK_EFFECTIVENESS(Water, Flying, 1);
|
||||||
|
@ -249,7 +248,7 @@ TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Grass, Normal, 1);
|
CHECK_EFFECTIVENESS(Grass, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Grass, Fighting, 1);
|
CHECK_EFFECTIVENESS(Grass, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Grass, Flying, 0.5);
|
CHECK_EFFECTIVENESS(Grass, Flying, 0.5);
|
||||||
|
@ -271,7 +270,7 @@ TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Electric, Normal, 1);
|
CHECK_EFFECTIVENESS(Electric, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Electric, Fighting, 1);
|
CHECK_EFFECTIVENESS(Electric, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Electric, Flying, 2);
|
CHECK_EFFECTIVENESS(Electric, Flying, 2);
|
||||||
|
@ -293,7 +292,7 @@ TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Psychic, Normal, 1);
|
CHECK_EFFECTIVENESS(Psychic, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Psychic, Fighting, 2);
|
CHECK_EFFECTIVENESS(Psychic, Fighting, 2);
|
||||||
CHECK_EFFECTIVENESS(Psychic, Flying, 1);
|
CHECK_EFFECTIVENESS(Psychic, Flying, 1);
|
||||||
|
@ -315,7 +314,7 @@ TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ice, Normal, 1);
|
CHECK_EFFECTIVENESS(Ice, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Ice, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ice, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Ice, Flying, 2);
|
CHECK_EFFECTIVENESS(Ice, Flying, 2);
|
||||||
|
@ -337,7 +336,7 @@ TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Dragon, Normal, 1);
|
CHECK_EFFECTIVENESS(Dragon, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Dragon, Fighting, 1);
|
CHECK_EFFECTIVENESS(Dragon, Fighting, 1);
|
||||||
CHECK_EFFECTIVENESS(Dragon, Flying, 1);
|
CHECK_EFFECTIVENESS(Dragon, Flying, 1);
|
||||||
|
@ -359,7 +358,7 @@ TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Dark, Normal, 1);
|
CHECK_EFFECTIVENESS(Dark, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Dark, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Dark, Fighting, 0.5);
|
||||||
CHECK_EFFECTIVENESS(Dark, Flying, 1);
|
CHECK_EFFECTIVENESS(Dark, Flying, 1);
|
||||||
|
@ -381,7 +380,7 @@ TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fairy Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fairy Attacking", "[type]") {
|
||||||
auto typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fairy, Normal, 1);
|
CHECK_EFFECTIVENESS(Fairy, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Fairy, Fighting, 2);
|
CHECK_EFFECTIVENESS(Fairy, Fighting, 2);
|
||||||
CHECK_EFFECTIVENESS(Fairy, Flying, 1);
|
CHECK_EFFECTIVENESS(Fairy, Flying, 1);
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef GEN7TESTS_PRECOMPILED_HXX
|
||||||
|
#define GEN7TESTS_PRECOMPILED_HXX
|
||||||
|
|
||||||
|
#include <PkmnLib/Precompiled.hxx>
|
||||||
|
|
||||||
|
#endif // GEN7TESTS_PRECOMPILED_HXX
|
|
@ -8,10 +8,9 @@
|
||||||
|
|
||||||
#define SETUP_MOVE_TEST(move) \
|
#define SETUP_MOVE_TEST(move) \
|
||||||
auto library = Library::GetLibrary(); \
|
auto library = Library::GetLibrary(); \
|
||||||
auto userMon = \
|
auto userMon = PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50) \
|
||||||
PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50) \
|
.LearnMove(ArbUt::StringView(#move), CreatureLib::Battling::AttackLearnMethod::Unknown) \
|
||||||
.LearnMove(Arbutils::CaseInsensitiveConstString(#move), CreatureLib::Battling::AttackLearnMethod::Unknown) \
|
.Build(); \
|
||||||
->Build(); \
|
|
||||||
auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur"_cnc, 50).Build(); \
|
auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur"_cnc, 50).Build(); \
|
||||||
\
|
\
|
||||||
auto userParty = new CreatureLib::Battling::CreatureParty({userMon}); \
|
auto userParty = new CreatureLib::Battling::CreatureParty({userMon}); \
|
||||||
|
@ -26,15 +25,16 @@
|
||||||
userMon->SetBattleData(battle, battle->GetSides()[0]); \
|
userMon->SetBattleData(battle, battle->GetSides()[0]); \
|
||||||
targetMon->SetBattleData(battle, battle->GetSides()[1]); \
|
targetMon->SetBattleData(battle, battle->GetSides()[1]); \
|
||||||
\
|
\
|
||||||
auto moveData = library->GetMoveLibrary()->Get(Arbutils::CaseInsensitiveConstString(#move)); \
|
auto moveData = library->GetMoveLibrary()->Get(ArbUt::StringView(#move)); \
|
||||||
REQUIRE(moveData->HasSecondaryEffect()); \
|
REQUIRE(moveData->HasSecondaryEffect()); \
|
||||||
auto effect = moveData->GetSecondaryEffect(); \
|
auto& effect = moveData->GetSecondaryEffect(); \
|
||||||
auto script = library->LoadScript(ScriptCategory::Attack, effect->GetEffectName()); \
|
auto script = library->LoadScript(ScriptCategory::Attack, effect->GetEffectName()); \
|
||||||
REQUIRE(script != nullptr); \
|
REQUIRE(script != nullptr); \
|
||||||
script->OnInitialize(effect->GetParameters()); \
|
script->OnInitialize(effect->GetParameters()); \
|
||||||
\
|
\
|
||||||
auto executingMove = \
|
auto executingMove = new CreatureLib::Battling::ExecutingAttack( \
|
||||||
new CreatureLib::Battling::ExecutingAttack({targetMon}, 1, userMon, userMon->GetMoves()[0], script);
|
ArbUt::List<ArbUt::OptionalBorrowedPtr<CreatureLib::Battling::Creature>>{targetMon}, (uint8_t)1, userMon, \
|
||||||
|
userMon->GetMoves()[0], std::unique_ptr<AngelScriptScript::BattleScript>(script));
|
||||||
|
|
||||||
#define CLEANUP_MOVE_TEST \
|
#define CLEANUP_MOVE_TEST \
|
||||||
delete executingMove; \
|
delete executingMove; \
|
||||||
|
@ -67,12 +67,12 @@
|
||||||
#define MOVE_EFFECT_CHANCE(move, chance) \
|
#define MOVE_EFFECT_CHANCE(move, chance) \
|
||||||
TEST_CASE(#move " - Effect Chance = " #chance, "[moves]") { \
|
TEST_CASE(#move " - Effect Chance = " #chance, "[moves]") { \
|
||||||
auto library = Library::GetLibrary(); \
|
auto library = Library::GetLibrary(); \
|
||||||
auto move = library->GetMoveLibrary()->Get(Arbutils::CaseInsensitiveConstString(#move)); \
|
auto move = library->GetMoveLibrary()->Get(ArbUt::StringView(#move)); \
|
||||||
REQUIRE(move->HasSecondaryEffect()); \
|
REQUIRE(move->HasSecondaryEffect()); \
|
||||||
CHECK(move->GetSecondaryEffect()->GetChance() == chance); \
|
CHECK(move->GetSecondaryEffect()->GetChance() == chance); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHANCE_BASED_MOVE(moveName, chance, onEffectCheck) \
|
#define CHANCE_BASED_MOVE(moveName, chance, onEffectCheck) \
|
||||||
ON_MOVE_EFFECT_TRIGGER(moveName, onEffectCheck) \
|
ON_MOVE_EFFECT_TRIGGER(moveName, onEffectCheck) \
|
||||||
MOVE_EFFECT_CHANCE(moveName, chance)
|
MOVE_EFFECT_CHANCE(moveName, chance)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ TEST_CASE("Absorb - Heals on use", "[moves]") {
|
||||||
SETUP_MOVE_TEST(Absorb)
|
SETUP_MOVE_TEST(Absorb)
|
||||||
|
|
||||||
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
||||||
executingMove->GetAttackDataForTarget(targetMon)->GetHit(0)->SetDamage(50);
|
executingMove->GetHitData(targetMon, 0).SetDamage(50);
|
||||||
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
||||||
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 25);
|
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 25);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ TEST_CASE("Absorb - Heals more with big root", "[moves]") {
|
||||||
SETUP_MOVE_TEST(Absorb)
|
SETUP_MOVE_TEST(Absorb)
|
||||||
|
|
||||||
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
||||||
executingMove->GetAttackDataForTarget(targetMon)->GetHit(0)->SetDamage(50);
|
executingMove->GetHitData(targetMon, 0).SetDamage(50);
|
||||||
userMon->SetHeldItem("big_root"_cnc.GetHash());
|
userMon->SetHeldItem("big_root"_cnc.GetHash());
|
||||||
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
||||||
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 18);
|
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 18);
|
||||||
|
|
|
@ -21,7 +21,9 @@ TEST_CASE("Struggle - Damages by 1/4th of users max health", "[moves]") {
|
||||||
userMon->SetBattleData(battle, battle->GetSides()[0]);
|
userMon->SetBattleData(battle, battle->GetSides()[0]);
|
||||||
targetMon->SetBattleData(battle, battle->GetSides()[1]);
|
targetMon->SetBattleData(battle, battle->GetSides()[1]);
|
||||||
|
|
||||||
auto script = library->LoadScript(ScriptCategory::Attack, "Struggle"_cnc);
|
auto& script = ((CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
||||||
|
userMon, CreatureLib::Battling::CreatureIndex(1, 0)))
|
||||||
|
->GetAttackScript();
|
||||||
REQUIRE(script != nullptr);
|
REQUIRE(script != nullptr);
|
||||||
|
|
||||||
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
||||||
|
@ -31,8 +33,6 @@ TEST_CASE("Struggle - Damages by 1/4th of users max health", "[moves]") {
|
||||||
|
|
||||||
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
||||||
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - (userMon->GetMaxHealth() / 4));
|
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - (userMon->GetMaxHealth() / 4));
|
||||||
delete choice;
|
|
||||||
delete script;
|
|
||||||
delete executingMove;
|
delete executingMove;
|
||||||
delete targetParty;
|
delete targetParty;
|
||||||
delete userParty;
|
delete userParty;
|
||||||
|
|
66
src/main.cpp
66
src/main.cpp
|
@ -1,5 +1,5 @@
|
||||||
#define CATCH_CONFIG_RUNNER
|
#define CATCH_CONFIG_RUNNER
|
||||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScripResolver.hpp>
|
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include "../extern/catch.hpp"
|
#include "../extern/catch.hpp"
|
||||||
#include "BuildData/BuildItems.hpp"
|
#include "BuildData/BuildItems.hpp"
|
||||||
|
@ -12,36 +12,36 @@
|
||||||
|
|
||||||
static const char* ScriptsPath = nullptr;
|
static const char* ScriptsPath = nullptr;
|
||||||
|
|
||||||
//static constexpr const char* GetCategoryPath(CreatureLib::Battling::ScriptResolver::ScriptCategory category){
|
// static constexpr const char* GetCategoryPath(CreatureLib::Battling::ScriptResolver::ScriptCategory category){
|
||||||
// switch (category){
|
// switch (category){
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack: return "Moves";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack: return "Moves";
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Talent: return "Abilities";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Talent: return "Abilities";
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Status: return "Status";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Status: return "Status";
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Creature: return "Pokemon";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Creature: return "Pokemon";
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Battle: return "Battle";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Battle: return "Battle";
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Side: return "Side";
|
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Side: return "Side";
|
||||||
// }
|
// }
|
||||||
//}
|
// }
|
||||||
|
|
||||||
|
// static const char* LoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* scriptName){
|
||||||
//static const char* LoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* scriptName){
|
// auto categoryStr = GetCategoryPath(category);
|
||||||
// auto categoryStr = GetCategoryPath(category);
|
// char fullPath[strlen(ScriptsPath) + 1 + strlen(categoryStr) + 1 + strlen(scriptName) + 3];
|
||||||
// char fullPath[strlen(ScriptsPath) + 1 + strlen(categoryStr) + 1 + strlen(scriptName) + 3];
|
// strcpy(fullPath, ScriptsPath);
|
||||||
// strcpy(fullPath, ScriptsPath);
|
// strcat(fullPath, "/");
|
||||||
// strcat(fullPath, "/");
|
// strcat(fullPath, categoryStr);
|
||||||
// strcat(fullPath, categoryStr);
|
// strcat(fullPath, "/");
|
||||||
// strcat(fullPath, "/");
|
// strcat(fullPath, scriptName);
|
||||||
// strcat(fullPath, scriptName);
|
// strcat(fullPath, ".as");
|
||||||
// strcat(fullPath, ".as");
|
// std::ifstream in(fullPath);
|
||||||
// std::ifstream in(fullPath);
|
// std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
||||||
// std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
// char res[contents.size()];
|
||||||
// char res[contents.size()];
|
// return strcpy(res, contents.c_str());
|
||||||
// return strcpy(res, contents.c_str());
|
// }
|
||||||
//}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
Catch::Session session;
|
Catch::Session session;
|
||||||
|
|
||||||
|
std::string workingDirectory = "";
|
||||||
std::string typesFile = "Types.csv";
|
std::string typesFile = "Types.csv";
|
||||||
std::string naturesFile = "Natures.csv";
|
std::string naturesFile = "Natures.csv";
|
||||||
std::string pokemonFile = "Pokemon.json";
|
std::string pokemonFile = "Pokemon.json";
|
||||||
|
@ -51,7 +51,8 @@ int main(int argc, char* argv[]) {
|
||||||
std::string scriptsPath = "Scripts";
|
std::string scriptsPath = "Scripts";
|
||||||
|
|
||||||
using namespace Catch::clara;
|
using namespace Catch::clara;
|
||||||
auto cli = session.cli() | Opt(pokemonFile, "Species")["--species"]("Which species file to load.") |
|
auto cli = session.cli() | Opt(workingDirectory, "Working Directory")["--workdir"]("Which work directory to use.") |
|
||||||
|
Opt(pokemonFile, "Species")["--species"]("Which species file to load.") |
|
||||||
Opt(typesFile, "Types")["--types"]("Which Types file to load.") |
|
Opt(typesFile, "Types")["--types"]("Which Types file to load.") |
|
||||||
Opt(naturesFile, "Natures")["--natures"]("Which Natures file to load.") |
|
Opt(naturesFile, "Natures")["--natures"]("Which Natures file to load.") |
|
||||||
Opt(moveFile, "Moves")["--moves"]("Which Moves file to load.") |
|
Opt(moveFile, "Moves")["--moves"]("Which Moves file to load.") |
|
||||||
|
@ -67,6 +68,10 @@ int main(int argc, char* argv[]) {
|
||||||
if (session.config().showHelp())
|
if (session.config().showHelp())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!workingDirectory.empty()) {
|
||||||
|
chdir(workingDirectory.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
auto typesLibrary = BuildTypes::Build(typesFile);
|
auto typesLibrary = BuildTypes::Build(typesFile);
|
||||||
auto natureLibrary = BuildNatures::Build(naturesFile);
|
auto natureLibrary = BuildNatures::Build(naturesFile);
|
||||||
auto speciesLibrary = BuildSpecies::BuildLibrary(pokemonFile, typesLibrary);
|
auto speciesLibrary = BuildSpecies::BuildLibrary(pokemonFile, typesLibrary);
|
||||||
|
@ -87,13 +92,13 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
auto battleLib = new PkmnLib::Battling::BattleLibrary(
|
auto battleLib = new PkmnLib::Battling::BattleLibrary(
|
||||||
staticLibrary, new PkmnLib::Battling::StatCalculator(), new PkmnLib::Battling::DamageLibrary(),
|
staticLibrary, new PkmnLib::Battling::StatCalculator(), new PkmnLib::Battling::DamageLibrary(),
|
||||||
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, new CreatureLib::Battling::MiscLibrary());
|
new PkmnLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary());
|
||||||
|
|
||||||
scriptResolver->Initialize(battleLib);
|
scriptResolver->Initialize(battleLib);
|
||||||
|
|
||||||
auto asScriptResolver = dynamic_cast<AngelScripResolver*>(scriptResolver);
|
auto asScriptResolver = dynamic_cast<AngelScriptResolver*>(scriptResolver);
|
||||||
|
|
||||||
for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(ScriptsPath)){
|
for (const auto& dirEntry : std::filesystem::recursive_directory_iterator(ScriptsPath)) {
|
||||||
if (dirEntry.is_directory())
|
if (dirEntry.is_directory())
|
||||||
continue;
|
continue;
|
||||||
if (dirEntry.path().parent_path().stem() == "Interfaces")
|
if (dirEntry.path().parent_path().stem() == "Interfaces")
|
||||||
|
@ -127,7 +132,6 @@ class SaveEffectChance : PkmnScript {
|
||||||
}
|
}
|
||||||
})");
|
})");
|
||||||
|
|
||||||
|
|
||||||
asScriptResolver->FinalizeModule();
|
asScriptResolver->FinalizeModule();
|
||||||
|
|
||||||
Library::SetStaticLib(staticLibrary);
|
Library::SetStaticLib(staticLibrary);
|
||||||
|
|
Loading…
Reference in New Issue