fix battle area number normalization and add more structs/enums

This commit is contained in:
Martin Michelsen
2024-01-30 21:10:50 -08:00
parent 340fbb8ca5
commit 4830f5a41e
12 changed files with 72 additions and 29 deletions
+27 -1
View File
@@ -715,7 +715,7 @@ BattleRules::BattleRules(const JSON& json) {
this->tool_mode = json.get_enum("ToolMode", this->tool_mode);
this->trap_mode = json.get_enum("TrapMode", this->trap_mode);
this->unused_F817 = json.get_int("UnusedF817", this->unused_F817);
this->respawn_mode = json.get_int("RespawnMode", this->respawn_mode);
this->respawn_mode = json.get_enum("RespawnMode", this->respawn_mode);
this->replace_char = json.get_int("ReplaceChar", this->replace_char);
this->drop_weapon = json.get_int("DropWeapon", this->drop_weapon);
this->is_teams = json.get_int("IsTeams", this->is_teams);
@@ -917,6 +917,32 @@ BattleRules::MesetaMode enum_for_name<BattleRules::MesetaMode>(const char* name)
}
}
template <>
const char* name_for_enum<BattleRules::RespawnMode>(BattleRules::RespawnMode v) {
switch (v) {
case BattleRules::RespawnMode::ALLOW:
return "ALLOW";
case BattleRules::RespawnMode::FORBID:
return "FORBID";
case BattleRules::RespawnMode::LIMIT_LIVES:
return "LIMIT_LIVES";
default:
throw invalid_argument("invalid BattleRules::MesetaDropMode value");
}
}
template <>
BattleRules::RespawnMode enum_for_name<BattleRules::RespawnMode>(const char* name) {
if (!strcmp(name, "ALLOW")) {
return BattleRules::RespawnMode::ALLOW;
} else if (!strcmp(name, "FORBID")) {
return BattleRules::RespawnMode::FORBID;
} else if (!strcmp(name, "LIMIT_LIVES")) {
return BattleRules::RespawnMode::LIMIT_LIVES;
} else {
throw invalid_argument("invalid BattleRules::MesetaDropMode name");
}
}
static PlayerInventoryItem make_template_item(bool equipped, uint64_t first_data, uint64_t second_data) {
return PlayerInventoryItem(ItemData(first_data, second_data), equipped);
}