fix rules not serializing properly in tournament state
This commit is contained in:
@@ -1200,14 +1200,14 @@ JSON Rules::json() const {
|
|||||||
{"allowed_cards", name_for_enum(this->allowed_cards)},
|
{"allowed_cards", name_for_enum(this->allowed_cards)},
|
||||||
{"min_dice", this->min_dice},
|
{"min_dice", this->min_dice},
|
||||||
{"max_dice", this->max_dice},
|
{"max_dice", this->max_dice},
|
||||||
{"disable_deck_shuffle", this->disable_deck_shuffle},
|
{"disable_deck_shuffle", static_cast<bool>(this->disable_deck_shuffle)},
|
||||||
{"disable_deck_loop", this->disable_deck_loop},
|
{"disable_deck_loop", static_cast<bool>(this->disable_deck_loop)},
|
||||||
{"char_hp", this->char_hp},
|
{"char_hp", this->char_hp},
|
||||||
{"hp_type", name_for_enum(this->hp_type)},
|
{"hp_type", name_for_enum(this->hp_type)},
|
||||||
{"no_assist_cards", this->no_assist_cards},
|
{"no_assist_cards", static_cast<bool>(this->no_assist_cards)},
|
||||||
{"disable_dialogue", this->disable_dialogue},
|
{"disable_dialogue", static_cast<bool>(this->disable_dialogue)},
|
||||||
{"dice_exchange_mode", name_for_enum(this->dice_exchange_mode)},
|
{"dice_exchange_mode", name_for_enum(this->dice_exchange_mode)},
|
||||||
{"disable_dice_boost", this->disable_dice_boost},
|
{"disable_dice_boost", static_cast<bool>(this->disable_dice_boost)},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -660,7 +660,12 @@ TournamentIndex::TournamentIndex(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto json = JSON::parse(load_file(this->state_filename));
|
JSON json;
|
||||||
|
try {
|
||||||
|
json = JSON::parse(load_file(this->state_filename));
|
||||||
|
} catch (const cannot_open_file&) {
|
||||||
|
json = JSON::list();
|
||||||
|
}
|
||||||
if (json.size() > 0x20) {
|
if (json.size() > 0x20) {
|
||||||
throw runtime_error("tournament JSON list length is incorrect");
|
throw runtime_error("tournament JSON list length is incorrect");
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-9
@@ -848,15 +848,9 @@ void ServerState::load_ep3_data() {
|
|||||||
this->ep3_com_deck_index.reset(new Episode3::COMDeckIndex("system/ep3/com-decks.json"));
|
this->ep3_com_deck_index.reset(new Episode3::COMDeckIndex("system/ep3/com-decks.json"));
|
||||||
|
|
||||||
const string& tournament_state_filename = "system/ep3/tournament-state.json";
|
const string& tournament_state_filename = "system/ep3/tournament-state.json";
|
||||||
try {
|
this->ep3_tournament_index.reset(new Episode3::TournamentIndex(
|
||||||
this->ep3_tournament_index.reset(new Episode3::TournamentIndex(
|
this->ep3_map_index, this->ep3_com_deck_index, tournament_state_filename));
|
||||||
this->ep3_map_index, this->ep3_com_deck_index, tournament_state_filename));
|
config_log.info("Loaded Episode 3 tournament state");
|
||||||
config_log.info("Loaded Episode 3 tournament state");
|
|
||||||
} catch (const exception& e) {
|
|
||||||
config_log.warning("Cannot load Episode 3 tournament state: %s", e.what());
|
|
||||||
this->ep3_tournament_index.reset(new Episode3::TournamentIndex(
|
|
||||||
this->ep3_map_index, this->ep3_com_deck_index, tournament_state_filename, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
config_log.info("Resolving Episode 3 card auction pool");
|
config_log.info("Resolving Episode 3 card auction pool");
|
||||||
for (auto& e : this->ep3_card_auction_pool) {
|
for (auto& e : this->ep3_card_auction_pool) {
|
||||||
|
|||||||
Reference in New Issue
Block a user