make Rules debug string show open cases

This commit is contained in:
Martin Michelsen
2023-09-18 10:12:14 -07:00
parent 80b9af46db
commit 9cb9e8064a
2 changed files with 87 additions and 31 deletions
+71 -16
View File
@@ -1240,69 +1240,124 @@ void Rules::clear() {
string Rules::str() const { string Rules::str() const {
vector<string> tokens; vector<string> tokens;
if (this->char_hp == 0xFF) {
tokens.emplace_back("char_hp=(open)");
} else {
tokens.emplace_back(string_printf("char_hp=%hhu", this->char_hp)); tokens.emplace_back(string_printf("char_hp=%hhu", this->char_hp));
}
switch (this->hp_type) { switch (this->hp_type) {
case HPType::DEFEAT_PLAYER: case HPType::DEFEAT_PLAYER:
tokens.emplace_back("hp_type=DEFEAT_PLAYER"); tokens.emplace_back("hp_type=defeat-player");
break; break;
case HPType::DEFEAT_TEAM: case HPType::DEFEAT_TEAM:
tokens.emplace_back("hp_type=DEFEAT_TEAM"); tokens.emplace_back("hp_type=defeat-team");
break; break;
case HPType::COMMON_HP: case HPType::COMMON_HP:
tokens.emplace_back("hp_type=COMMON_HP"); tokens.emplace_back("hp_type=common-hp");
break; break;
default: default:
if (static_cast<uint8_t>(this->hp_type) == 0xFF) {
tokens.emplace_back("hp_type=(open)");
} else {
tokens.emplace_back(string_printf("hp_type=(%02hhX)", tokens.emplace_back(string_printf("hp_type=(%02hhX)",
static_cast<uint8_t>(this->hp_type))); static_cast<uint8_t>(this->hp_type)));
}
break; break;
} }
if (this->min_dice == 0xFF) {
tokens.emplace_back("min_dice=(open)");
} else if (this->min_dice == 0x00) {
tokens.emplace_back("min_dice=1 (default)");
} else {
tokens.emplace_back(string_printf("min_dice=%hhu", this->min_dice)); tokens.emplace_back(string_printf("min_dice=%hhu", this->min_dice));
}
if (this->max_dice == 0xFF) {
tokens.emplace_back("max_dice=(open)");
} else if (this->max_dice == 0x00) {
tokens.emplace_back("max_dice=6 (default)");
} else {
tokens.emplace_back(string_printf("max_dice=%hhu", this->max_dice)); tokens.emplace_back(string_printf("max_dice=%hhu", this->max_dice));
}
switch (this->dice_exchange_mode) { switch (this->dice_exchange_mode) {
case DiceExchangeMode::HIGH_ATK: case DiceExchangeMode::HIGH_ATK:
tokens.emplace_back("dice_exchange=HIGH_ATK"); tokens.emplace_back("dice_exchange=high-atk");
break; break;
case DiceExchangeMode::HIGH_DEF: case DiceExchangeMode::HIGH_DEF:
tokens.emplace_back("dice_exchange=HIGH_DEF"); tokens.emplace_back("dice_exchange=high-def");
break; break;
case DiceExchangeMode::NONE: case DiceExchangeMode::NONE:
tokens.emplace_back("dice_exchange=NONE"); tokens.emplace_back("dice_exchange=none");
break; break;
default: default:
if (static_cast<uint8_t>(this->dice_exchange_mode) == 0xFF) {
tokens.emplace_back("dice_exchange=(open)");
} else {
tokens.emplace_back(string_printf("dice_exchange=(%02hhX)", tokens.emplace_back(string_printf("dice_exchange=(%02hhX)",
static_cast<uint8_t>(this->dice_exchange_mode))); static_cast<uint8_t>(this->dice_exchange_mode)));
}
break; break;
} }
tokens.emplace_back(string_printf("dice_boost=%s", this->disable_dice_boost ? "DISABLED" : "ENABLED"));
tokens.emplace_back(string_printf("deck_shuffle=%s", this->disable_deck_shuffle ? "DISABLED" : "ENABLED")); auto str_for_disable_bool = +[](uint8_t v) -> string {
tokens.emplace_back(string_printf("deck_loop=%s", this->disable_deck_loop ? "DISABLED" : "ENABLED")); switch (v) {
case 0x00:
return "on";
case 0x01:
return "off";
case 0xFF:
return "(open)";
default:
return string_printf("(%02hhX)", v);
}
};
tokens.emplace_back("dice_boost=" + str_for_disable_bool(this->disable_dice_boost));
tokens.emplace_back("deck_shuffle=" + str_for_disable_bool(this->disable_deck_shuffle));
tokens.emplace_back("deck_loop=" + str_for_disable_bool(this->disable_deck_loop));
switch (this->allowed_cards) { switch (this->allowed_cards) {
case AllowedCards::ALL: case AllowedCards::ALL:
tokens.emplace_back("allowed_cards=ALL"); tokens.emplace_back("allowed_cards=all");
break; break;
case AllowedCards::N_ONLY: case AllowedCards::N_ONLY:
tokens.emplace_back("allowed_cards=N_ONLY"); tokens.emplace_back("allowed_cards=n-only");
break; break;
case AllowedCards::N_R_ONLY: case AllowedCards::N_R_ONLY:
tokens.emplace_back("allowed_cards=N_R_ONLY"); tokens.emplace_back("allowed_cards=n-r-only");
break; break;
case AllowedCards::N_R_S_ONLY: case AllowedCards::N_R_S_ONLY:
tokens.emplace_back("allowed_cards=N_R_S_ONLY"); tokens.emplace_back("allowed_cards=n-r-s-only");
break; break;
default: default:
if (static_cast<uint8_t>(this->allowed_cards) == 0xFF) {
tokens.emplace_back("allowed_cards=(open)");
} else {
tokens.emplace_back(string_printf("allowed_cards=(%02hhX)", tokens.emplace_back(string_printf("allowed_cards=(%02hhX)",
static_cast<uint8_t>(this->allowed_cards))); static_cast<uint8_t>(this->allowed_cards)));
}
break; break;
} }
tokens.emplace_back(string_printf("assist_cards=%s", this->no_assist_cards ? "DISALLOWED" : "ALLOWED")); tokens.emplace_back("allow_assist_cards=" + str_for_disable_bool(this->no_assist_cards));
tokens.emplace_back(string_printf("time_limit=%zumin", static_cast<size_t>(this->overall_time_limit * 5))); if (this->overall_time_limit == 0xFF) {
tokens.emplace_back("overall_time_limit=(open)");
} else if (this->overall_time_limit) {
tokens.emplace_back(string_printf("overall_time_limit=%zumin", static_cast<size_t>(this->overall_time_limit * 5)));
} else {
tokens.emplace_back("overall_time_limit=(infinite)");
}
if (this->phase_time_limit == 0xFF) {
tokens.emplace_back("phase_time_limit=(open)");
} else if (this->phase_time_limit) {
tokens.emplace_back(string_printf("phase_time_limit=%hhusec", this->phase_time_limit)); tokens.emplace_back(string_printf("phase_time_limit=%hhusec", this->phase_time_limit));
} else {
tokens.emplace_back("phase_time_limit=(infinite)");
}
tokens.emplace_back(string_printf("dialogue=%s", this->disable_dialogue ? "DISABLED" : "ENABLED")); tokens.emplace_back("dialogue=" + str_for_disable_bool(this->disable_dialogue));
return "Rules[" + join(tokens, ", ") + "]"; return "Rules[" + join(tokens, ", ") + "]";
} }
+6 -5
View File
@@ -1019,12 +1019,12 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
} __attribute__((packed)); } __attribute__((packed));
/* 20F0 */ parray<AIParams, 3> npc_ai_params; // Unused if name[0] == 0 /* 20F0 */ parray<AIParams, 3> npc_ai_params; // Unused if name[0] == 0
/* 242C */ parray<uint8_t, 8> unknown_a7; // Always FF? /* 242C */ parray<uint8_t, 8> unknown_a7;
// This array specifies which set of AI parameters to use from aiprm.dat. If // This array specifies which set of predefined AI parameters (in aiprm.dat)
// it's -1, then the corresponding NPC's AI parameters are defined in the // to use for each NPC. If a value in this array is -1 (FFFFFFFF), then the
// AIParams structure above. The names of the AI parameter sets defined in // corresponding NPC's AI parameters are defined in the AIParams structure
// aiprm.dat are: // above. The names of the AI parameter sets defined in aiprm.dat are:
// 00 => Sample_Hunter 10 => Endu // 00 => Sample_Hunter 10 => Endu
// 01 => Glustar 11 => Heiz // 01 => Glustar 11 => Heiz
// 02 => Guykild 12 => KC // 02 => Guykild 12 => KC
@@ -1041,6 +1041,7 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
// 0D => Sample_Dark 1D => Sample_Dark // 0D => Sample_Dark 1D => Sample_Dark
// 0E => Break // 0E => Break
// 0F => Creinu // 0F => Creinu
// Presumably 0A is meant to be Stella, and they forgot to change the name.
/* 2434 */ parray<be_int32_t, 3> npc_ai_params_entry_index; /* 2434 */ parray<be_int32_t, 3> npc_ai_params_entry_index;
// In story mode, before_message appears before the battle if it's not blank; // In story mode, before_message appears before the battle if it's not blank;