Parse Move Category.
This commit is contained in:
parent
5a7ff141eb
commit
a9fb8e2a38
|
@ -12,6 +12,17 @@ using json = nlohmann::json;
|
|||
return nullptr; \
|
||||
}
|
||||
|
||||
static PkmnLib::Library::MoveCategory ParseCategory(const std::string& input) {
|
||||
if (input == "physical")
|
||||
return PkmnLib::Library::MoveCategory::Physical;
|
||||
else if (input == "special")
|
||||
return PkmnLib::Library::MoveCategory::Special;
|
||||
else if (input == "status")
|
||||
return PkmnLib::Library::MoveCategory::Status;
|
||||
std::cout << "Invalid move category '" << input << ".\n";
|
||||
return static_cast<PkmnLib::Library::MoveCategory>(255);
|
||||
}
|
||||
|
||||
PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
||||
const CreatureLib::Library::TypeLibrary* types) {
|
||||
std::ifstream fileStream(path.c_str());
|
||||
|
@ -36,10 +47,13 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path,
|
|||
if (_pp.get<uint8_t>() == 0)
|
||||
continue;
|
||||
auto type = types->GetTypeId(_type.get<std::string>());
|
||||
auto move = new PkmnLib::Library::MoveData(
|
||||
_name.get<std::string>(), type, PkmnLib::Library::MoveCategory ::Physical, _power.get<uint8_t>(),
|
||||
_accuracy.get<uint8_t>(), _pp.get<uint8_t>(), CreatureLib::Library::AttackTarget::Any,
|
||||
_priority.get<int8_t>(), _flags.get<std::unordered_set<std::string>>());
|
||||
auto category = ParseCategory(_category.get<std::string>());
|
||||
if (static_cast<int>(category) == 255)
|
||||
return nullptr;
|
||||
auto move = new PkmnLib::Library::MoveData(_name.get<std::string>(), type, category, _power.get<uint8_t>(),
|
||||
_accuracy.get<uint8_t>(), _pp.get<uint8_t>(),
|
||||
CreatureLib::Library::AttackTarget::Any, _priority.get<int8_t>(),
|
||||
_flags.get<std::unordered_set<std::string>>());
|
||||
|
||||
lib->LoadAttack(move->GetName(), move);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue