use quest extended rules if present

This commit is contained in:
Martin Michelsen
2024-02-13 21:23:33 -08:00
parent 46e509aa69
commit 35e2a9d6f4
2 changed files with 22 additions and 4 deletions
+1 -1
View File
@@ -418,7 +418,7 @@ Some commands only work on the game server and not on the proxy server. The chat
* Episode 3 commands (game server only) * Episode 3 commands (game server only)
* `$spec`: Toggles the allow spectators flag for Episode 3 games. If any players are spectating when this flag is disabled, they will be sent back to the lobby. * `$spec`: Toggles the allow spectators flag for Episode 3 games. If any players are spectating when this flag is disabled, they will be sent back to the lobby.
* `$inftime`: Toggles infinite-time mode. Must be used before starting a battle. If infinite-time mode is enabled, the overall and per-phase time limits will be disabled regardless of the values chosen during battle setup. After completing a battle, infinite-time mode is reset to the server's default value (which can be set in Episode3BehaviorFlags in config.json). * `$inftime`: Toggles infinite-time mode. Must be used before starting a battle. If infinite-time mode is enabled, the overall and per-phase time limits will be disabled regardless of the values chosen during battle setup. After completing a battle, infinite-time mode is reset to the server's default value (which can be set in Episode3BehaviorFlags in config.json).
* `$dicerange [d:L-H] [1:L-H] [a1:L-H] [d1:L-H]`: Sets override dice ranges for the next battle. The min and max dice values from the rules setup menu always apply to the ATK dice, but you can specify a different range for the DEF dice with `d:2-4` (for example). The `1:` override applies to the 1-player team in a 2v1 game (so you would set the 2-player team's desired dice range in the rules menu). You can also specify the 1-player team's ATK and DEF ranges separately with the `a1:` and `d1:` overrides. * `$dicerange [d:L-H] [1:L-H] [a1:L-H] [d1:L-H]`: Sets override dice ranges for the next battle. The min and max dice values from the rules setup menu always apply to the ATK dice, but you can specify a different range for the DEF dice with `d:2-4` (for example). The `1:` override applies to the 1-player team in a 2v1 game (so you would set the 2-player team's desired dice range in the rules menu). You can also specify the 1-player team's ATK and DEF ranges separately with the `a1:` and `d1:` overrides. Note that these ranges will only be used if the chosen map or quest does not override them.
* `$stat <what>`: Shows a statistic about your player or team in the current battle. `<what>` can be `duration`, `fcs-destroyed`, `cards-destroyed`, `damage-given`, `damage-taken`, `opp-cards-destroyed`, `own-cards-destroyed`, `move-distance`, `cards-set`, `fcs-set`, `attack-actions-set`, `techs-set`, `assists-set`, `defenses-self`, `defenses-ally`, `cards-drawn`, `max-attack-damage`, `max-combo`, `attacks-given`, `attacks-taken`, `sc-damage`, `damage-defended`, or `rank`. * `$stat <what>`: Shows a statistic about your player or team in the current battle. `<what>` can be `duration`, `fcs-destroyed`, `cards-destroyed`, `damage-given`, `damage-taken`, `opp-cards-destroyed`, `own-cards-destroyed`, `move-distance`, `cards-set`, `fcs-set`, `attack-actions-set`, `techs-set`, `assists-set`, `defenses-self`, `defenses-ally`, `cards-drawn`, `max-attack-damage`, `max-combo`, `attacks-given`, `attacks-taken`, `sc-damage`, `damage-defended`, or `rank`.
* `$surrender`: Causes your team to immediately lose the current battle. * `$surrender`: Causes your team to immediately lose the current battle.
* `$saverec <name>`: Saves the recording of the last battle. * `$saverec <name>`: Saves the recording of the last battle.
+21 -3
View File
@@ -2603,12 +2603,30 @@ void Server::send_6xB6x41_to_all_clients() const {
} }
} }
void Server::handle_CAx41_map_request(shared_ptr<Client>, const string& data) { void Server::handle_CAx41_map_request(shared_ptr<Client> c, const string& data) {
const auto& cmd = check_size_t<G_MapDataRequest_Ep3_CAx41>(data); const auto& cmd = check_size_t<G_MapDataRequest_Ep3_CAx41>(data);
this->send_debug_command_received_message( this->send_debug_command_received_message(cmd.header.subsubcommand, "MAP DATA");
cmd.header.subsubcommand, "MAP DATA");
this->last_chosen_map = this->options.map_index->for_number(cmd.map_number); this->last_chosen_map = this->options.map_index->for_number(cmd.map_number);
// We don't trust the extended rules fields from the client, and the client
// can't modify it anyway, so we always apply the map's extended rules here.
// This allows map creators to use newserv's extended rules in quests.
if (this->setup_phase == SetupPhase::REGISTRATION) {
auto mv = this->last_chosen_map->version(c->language());
const auto& map_rules = mv->map->default_rules;
auto& server_rules = this->map_and_rules->rules;
if (map_rules.def_dice_value_range != 0xFF) {
server_rules.def_dice_value_range = map_rules.def_dice_value_range;
}
if (map_rules.atk_dice_value_range_2v1 != 0xFF) {
server_rules.atk_dice_value_range_2v1 = map_rules.atk_dice_value_range_2v1;
}
if (map_rules.def_dice_value_range_2v1 != 0xFF) {
server_rules.def_dice_value_range_2v1 = map_rules.def_dice_value_range_2v1;
}
}
this->send_6xB6x41_to_all_clients(); this->send_6xB6x41_to_all_clients();
} }