From 884a5ce75ab85ec2db23557f7e8e769a6e8e89db Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 9 Feb 2024 19:12:02 -0800 Subject: [PATCH] replace is_trial with is_nte --- src/Episode3/AssistServer.cc | 12 +- src/Episode3/AssistServer.hh | 4 +- src/Episode3/Card.cc | 100 ++--- src/Episode3/CardSpecial.cc | 370 +++++++++--------- src/Episode3/DataIndexes.cc | 8 +- src/Episode3/DataIndexes.hh | 4 +- src/Episode3/DeckState.cc | 4 +- src/Episode3/DeckState.hh | 2 +- src/Episode3/PlayerState.cc | 122 +++--- src/Episode3/PlayerStateSubordinates.cc | 2 +- src/Episode3/RulerServer.cc | 74 ++-- src/Episode3/Server.cc | 130 +++--- src/Episode3/Server.hh | 6 +- src/Lobby.cc | 4 +- src/Main.cc | 4 +- src/Quest.cc | 2 +- src/SaveFileFormats.cc | 2 +- src/SaveFileFormats.hh | 2 +- src/SendCommands.cc | 6 +- system/client-functions/VersionDetectGC.ppc.s | 4 +- 20 files changed, 431 insertions(+), 431 deletions(-) diff --git a/src/Episode3/AssistServer.cc b/src/Episode3/AssistServer.cc index 86b16a67..332bd89c 100644 --- a/src/Episode3/AssistServer.cc +++ b/src/Episode3/AssistServer.cc @@ -6,7 +6,7 @@ using namespace std; namespace Episode3 { -const vector& all_assist_card_ids(bool is_trial) { +const vector& all_assist_card_ids(bool is_nte) { // Note: This order matches the order that the cards are defined in the original // code. This is relevant for consistency of results when choosing a random card // (for God Whim). @@ -29,10 +29,10 @@ const vector& all_assist_card_ids(bool is_trial) { 0x013C, 0x013D, 0x013E, 0x013F, 0x0140, 0x0141, 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0148, 0x014A, 0x014B, 0x014C, 0x014D, 0x014E, 0x023F, 0x0240, 0x0241, 0x0242}; - return is_trial ? ALL_ASSIST_CARD_IDS_TRIAL : ALL_ASSIST_CARD_IDS_FINAL; + return is_nte ? ALL_ASSIST_CARD_IDS_TRIAL : ALL_ASSIST_CARD_IDS_FINAL; } -AssistEffect assist_effect_number_for_card_id(uint16_t card_id, bool is_trial) { +AssistEffect assist_effect_number_for_card_id(uint16_t card_id, bool is_nte) { static const unordered_map card_id_to_effect_final_only({ {0x0018, /* 0x0049 */ AssistEffect::DICE_FEVER_PLUS}, {0x0019, /* 0x004A */ AssistEffect::RICH_PLUS}, @@ -116,7 +116,7 @@ AssistEffect assist_effect_number_for_card_id(uint16_t card_id, bool is_trial) { return card_id_to_effect.at(card_id); } catch (const out_of_range&) { } - if (!is_trial) { + if (!is_nte) { try { return card_id_to_effect_final_only.at(card_id); } catch (const out_of_range&) { @@ -244,7 +244,7 @@ AssistEffect AssistServer::get_active_assist_by_index(size_t index) const { } void AssistServer::populate_effects() { - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); for (size_t z = 0; z < 4; z++) { this->assist_card_defs[z] = nullptr; this->assist_effects[z] = AssistEffect::NONE; @@ -253,7 +253,7 @@ void AssistServer::populate_effects() { uint16_t card_id = hes->assist_card_id == 0xFFFF ? this->card_id_for_card_ref(hes->assist_card_ref) : hes->assist_card_id.load(); - this->assist_effects[z] = assist_effect_number_for_card_id(card_id, is_trial); + this->assist_effects[z] = assist_effect_number_for_card_id(card_id, is_nte); if (this->assist_effects[z] != AssistEffect::NONE) { this->assist_card_defs[z] = this->definition_for_card_id(card_id); } diff --git a/src/Episode3/AssistServer.hh b/src/Episode3/AssistServer.hh index eb2fe454..83dcbfa9 100644 --- a/src/Episode3/AssistServer.hh +++ b/src/Episode3/AssistServer.hh @@ -13,8 +13,8 @@ namespace Episode3 { class Server; -const std::vector& all_assist_card_ids(bool is_trial); -AssistEffect assist_effect_number_for_card_id(uint16_t card_id, bool is_trial); +const std::vector& all_assist_card_ids(bool is_nte); +AssistEffect assist_effect_number_for_card_id(uint16_t card_id, bool is_nte); class AssistServer { public: diff --git a/src/Episode3/Card.cc b/src/Episode3/Card.cc index e38ab654..bbc451c8 100644 --- a/src/Episode3/Card.cc +++ b/src/Episode3/Card.cc @@ -49,7 +49,7 @@ void Card::init() { this->sc_def_entry = s->definition_for_card_id(ps->get_sc_card_id()); this->sc_card_type = ps->get_sc_card_type(); if (this->sc_card_ref == this->card_ref) { - if (s->options.is_trial()) { + if (s->options.is_nte()) { if (s->map_and_rules->rules.char_hp) { this->max_hp = s->map_and_rules->rules.char_hp; this->current_hp = s->map_and_rules->rules.char_hp; @@ -77,7 +77,7 @@ void Card::init() { this->loc.direction = ps->start_facing_direction; // Ep3 NTE always sends 6xB4x0A at construction time; final only does for // non-SC cards - if (s->options.is_trial() || (this->sc_card_ref != this->card_ref)) { + if (s->options.is_nte() || (this->sc_card_ref != this->card_ref)) { this->send_6xB4x4E_4C_4D_if_needed(); } } @@ -124,14 +124,14 @@ ssize_t Card::apply_abnormal_condition( int8_t random_percent) { auto s = this->server(); auto log = s->log_stack(string_printf("apply_abnormal_condition(%02hhX, @%04X, @%04X, %hd, %hhd, %hhd): ", def_effect_index, target_card_ref, sc_card_ref, value, dice_roll_value, random_percent)); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); ssize_t existing_cond_index; for (size_t z = 0; z < this->action_chain.conditions.size(); z++) { const auto& cond = this->action_chain.conditions[z]; if (cond.type == eff.type) { existing_cond_index = z; - if ((!is_trial && eff.type == ConditionType::MV_BONUS) || + if ((!is_nte && eff.type == ConditionType::MV_BONUS) || ((cond.card_definition_effect_index == def_effect_index) && (cond.card_ref == target_card_ref))) { break; @@ -207,7 +207,7 @@ ssize_t Card::apply_abnormal_condition( string cond_str = cond.str(); log.debug("wrote condition %zd => %s", cond_index, cond_str.c_str()); - if (!is_trial) { + if (!is_nte) { s->card_special->update_condition_orders(this->shared_from_this()); for (size_t z = 0; z < this->action_chain.conditions.size(); z++) { if (this->action_chain.conditions[z].type == ConditionType::NONE) { @@ -227,19 +227,19 @@ void Card::apply_ap_and_tp_adjust_assists_to_attack( int16_t* in_defense_power, int16_t* inout_attacker_tp) const { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); uint8_t client_id = attacker_card->get_client_id(); size_t num_assists = s->assist_server->compute_num_assist_effects_for_client(client_id); for (size_t z = 0; z < num_assists; z++) { switch (s->assist_server->get_active_assist_by_index(z)) { case AssistEffect::POWERLESS_RAIN: - if (is_trial) { + if (is_nte) { *inout_attacker_ap = max(*inout_attacker_ap - 2, 0); } break; case AssistEffect::BRAVE_WIND: - if (is_trial) { + if (is_nte) { *inout_attacker_ap = max(*inout_attacker_ap + 2, 0); } break; @@ -249,12 +249,12 @@ void Card::apply_ap_and_tp_adjust_assists_to_attack( } break; case AssistEffect::INFLUENCE: - if (is_trial) { + if (is_nte) { *inout_attacker_ap += attacker_card->player_state()->count_set_cards_for_env_stats_nte(); } break; case AssistEffect::FIX: - if (!is_trial && attacker_card && !attacker_card->def_entry->def.is_sc()) { + if (!is_nte && attacker_card && !attacker_card->def_entry->def.is_sc()) { *inout_attacker_ap = 2; } break; @@ -267,7 +267,7 @@ void Card::apply_ap_and_tp_adjust_assists_to_attack( for (size_t z = 0; z < num_assists; z++) { auto eff = s->assist_server->get_active_assist_by_index(z); if (eff == AssistEffect::AP_ABSORPTION) { - if (is_trial) { + if (is_nte) { if (attacker_card->action_chain.chain.attack_medium == AttackMedium::TECH) { *inout_attacker_ap = *inout_attacker_ap + 2; } else if (attacker_card->action_chain.chain.attack_medium == AttackMedium::PHYSICAL) { @@ -299,7 +299,7 @@ void Card::commit_attack( int16_t* out_effective_damage) { auto s = this->server(); auto log = s->log_stack(string_printf("commit_attack(@%04hX #%04hX, @%04hX #%04hX => %hd (str%zu)): ", this->get_card_ref(), this->get_card_id(), attacker_card->get_card_ref(), attacker_card->get_card_id(), damage, strike_number)); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); int16_t effective_damage = damage; s->card_special->adjust_attack_damage_due_to_conditions( @@ -315,7 +315,7 @@ void Card::commit_attack( int16_t exp_amount = clamp(s->team_exp[team_id], 0, effective_damage); s->team_exp[team_id] -= exp_amount; effective_damage -= exp_amount; - if (!is_trial) { + if (!is_nte) { s->compute_team_dice_bonus(team_id); s->update_battle_state_flags_and_send_6xB4x03_if_needed(); if (cmd) { @@ -368,7 +368,7 @@ void Card::commit_attack( this->propagate_shared_hp_if_needed(); - if (!is_trial && this->def_entry->def.is_sc()) { + if (!is_nte && this->def_entry->def.is_sc()) { this->player_state()->stats.sc_damage_taken += effective_damage; } @@ -508,14 +508,14 @@ void Card::execute_attack(shared_ptr attacker_card) { auto s = this->server(); auto log = s->log_stack(string_printf("execute_attack(@%04X #%04X, @%04X #%04X): ", this->get_card_ref(), this->get_card_id(), attacker_card->get_card_ref(), attacker_card->get_card_id())); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); this->card_flags &= 0xFFFFFFF3; int16_t attack_ap = this->action_metadata.attack_bonus; int16_t attack_tp = 0; - int16_t defense_power = is_trial ? 0 : this->compute_defense_power_for_attacker_card(attacker_card); + int16_t defense_power = is_nte ? 0 : this->compute_defense_power_for_attacker_card(attacker_card); log.debug("ap=%hd, tp=%hd", attack_ap, attack_tp); - if (!is_trial && (attack_ap == 0) && !this->action_metadata.check_flag(0x20)) { + if (!is_nte && (attack_ap == 0) && !this->action_metadata.check_flag(0x20)) { log.debug("ap == 0 and flag 0x20 not set"); return; } else { @@ -540,7 +540,7 @@ void Card::execute_attack(shared_ptr attacker_card) { } else { - if (is_trial) { + if (is_nte) { defense_power = this->compute_defense_power_for_attacker_card(attacker_card); log.debug("ap=%hd, tp=%hd, defense=%hd", attack_ap, attack_tp, defense_power); attacker_card->compute_action_chain_results(true, false); @@ -573,7 +573,7 @@ void Card::execute_attack(shared_ptr attacker_card) { log.debug("target replaced with @%04hX #%04hX", target->get_card_ref(), target->get_card_id()); } - if (!is_trial) { + if (!is_nte) { if (unknown_a9 != 0) { preliminary_damage = 0; log.debug("a9 nonzero; preliminary_damage = 0"); @@ -584,8 +584,8 @@ void Card::execute_attack(shared_ptr attacker_card) { } } - cmd.effect.current_hp = is_trial ? attack_ap : min(attack_ap, 99); - cmd.effect.ap = is_trial ? defense_power : min(defense_power, 99); + cmd.effect.current_hp = is_nte ? attack_ap : min(attack_ap, 99); + cmd.effect.ap = is_nte ? defense_power : min(defense_power, 99); cmd.effect.tp = attack_tp; auto ps = this->player_state(); @@ -603,7 +603,7 @@ void Card::execute_attack(shared_ptr attacker_card) { target->commit_attack(0, attacker_card, &cmd, 0, nullptr); } - if (!is_trial && (this != target.get())) { + if (!is_nte && (this != target.get())) { log.debug("target was replaced; committing zero-damage attack on original card"); this->commit_attack(0, attacker_card, &cmd, 0, nullptr); } @@ -697,7 +697,7 @@ int32_t Card::move_to_location(const Location& loc) { this->card_flags = this->card_flags | 0x80; // On NTE, traps happen now, not after the Move phase - if (s->options.is_trial() && + if (s->options.is_nte() && this->def_entry->def.is_sc() && ((s->overlay_state.tiles[loc.y][loc.x] & 0xF0) == 0x40)) { for (size_t z = 0; z < 4; z++) { @@ -785,7 +785,7 @@ void Card::send_6xB4x4E_4C_4D_if_needed(bool always_send) { auto& metadata = ps->set_card_action_metadatas->at(index); auto s = this->server(); - if (s->options.is_trial()) { + if (s->options.is_nte()) { chain = this->action_chain; metadata = this->action_metadata; @@ -906,7 +906,7 @@ void Card::clear_action_chain_and_metadata_and_most_flags() { void Card::compute_action_chain_results(bool apply_action_conditions, bool ignore_this_card_ap_tp) { auto s = this->server(); auto log = s->log_stack(string_printf("compute_action_chain_results(@%04hX #%04hX): ", this->get_card_ref(), this->get_card_id())); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); this->action_chain.compute_attack_medium(s); this->action_chain.chain.strike_count = 1; @@ -922,7 +922,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor int16_t effective_ap; int16_t effective_tp; StatSwapType stat_swap_type; - if (is_trial) { + if (is_nte) { effective_ap = this->ap; effective_tp = this->tp; stat_swap_type = StatSwapType::NONE; @@ -934,7 +934,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor } // This option doesn't exist in NTE - ignore_this_card_ap_tp &= !is_trial; + ignore_this_card_ap_tp &= !is_nte; for (size_t z = 0; (!ignore_this_card_ap_tp && (z < 8) && (z < this->action_chain.chain.attack_action_card_ref_count)); z++) { auto ce = s->definition_for_card_ref(this->action_chain.chain.attack_action_card_refs[z]); @@ -972,11 +972,11 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor } if (!this->action_chain.check_flag(0x10)) { - this->action_chain.chain.effective_ap = is_trial ? effective_ap : min(effective_ap, 99); + this->action_chain.chain.effective_ap = is_nte ? effective_ap : min(effective_ap, 99); log.debug("set chain effective_ap = %hd", this->action_chain.chain.effective_ap); } if (!this->action_chain.check_flag(0x20)) { - this->action_chain.chain.effective_tp = is_trial ? effective_tp : min(effective_tp, 99); + this->action_chain.chain.effective_tp = is_nte ? effective_tp : min(effective_tp, 99); log.debug("set chain effective_tp = %hd", this->action_chain.chain.effective_tp); } @@ -992,37 +992,37 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor for (size_t z = 0; z < num_assists; z++) { switch (s->assist_server->get_active_assist_by_index(z)) { case AssistEffect::POWERLESS_RAIN: - if (!is_trial && + if (!is_nte && this->card_type_is_sc_or_creature() && (this->action_chain.chain.attack_medium == AttackMedium::PHYSICAL)) { this->action_chain.chain.ap_effect_bonus -= 2; } break; case AssistEffect::BRAVE_WIND: - if (!is_trial && + if (!is_nte && this->card_type_is_sc_or_creature() && (this->action_chain.chain.attack_medium == AttackMedium::PHYSICAL)) { this->action_chain.chain.ap_effect_bonus += 2; } break; case AssistEffect::INFLUENCE: - if (!is_trial && this->card_type_is_sc_or_creature()) { + if (!is_nte && this->card_type_is_sc_or_creature()) { int16_t count = ps->count_set_refs(); this->action_chain.chain.ap_effect_bonus += (count >> 1); } break; case AssistEffect::AP_ABSORPTION: - if (!is_trial && (this->action_chain.chain.attack_medium == AttackMedium::TECH)) { + if (!is_nte && (this->action_chain.chain.attack_medium == AttackMedium::TECH)) { this->action_chain.chain.tp_effect_bonus += 2; } break; case AssistEffect::FIX: - if (is_trial && !this->def_entry->def.is_sc()) { + if (is_nte && !this->def_entry->def.is_sc()) { this->action_chain.chain.ap_effect_bonus = 2 - this->action_chain.chain.card_ap; } break; case AssistEffect::TECH_FIELD: - if (is_trial ? this->def_entry->def.is_sc() : this->card_type_is_sc_or_creature()) { + if (is_nte ? this->def_entry->def.is_sc() : this->card_type_is_sc_or_creature()) { this->action_chain.chain.tp_effect_bonus += 2; } break; @@ -1093,7 +1093,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor break; case AssistEffect::VENGEANCE: if (!this->def_entry->def.is_sc()) { - size_t denom = is_trial ? 2 : 3; + size_t denom = is_nte ? 2 : 3; this->action_chain.chain.ap_effect_bonus += (s->team_num_ally_fcs_destroyed[this->team_id] / denom); } break; @@ -1113,7 +1113,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor log.debug("(unknown attack medium) damage = 0"); } - this->action_chain.chain.damage = is_trial + this->action_chain.chain.damage = is_nte ? (damage * this->action_chain.chain.damage_multiplier) : min(damage * this->action_chain.chain.damage_multiplier, 99); log.debug("overall chain damage = %hd (base) * %hhd (mult) = %hhd", damage, this->action_chain.chain.damage_multiplier, this->action_chain.chain.damage); @@ -1122,7 +1122,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor auto this_sh = this->shared_from_this(); s->card_special->apply_action_conditions(0x03, this_sh, this_sh, 2, nullptr); log.debug("applied action conditions (2)"); - if (!is_trial && this->action_chain.check_flag(0x100)) { + if (!is_nte && this->action_chain.check_flag(0x100)) { this->action_chain.chain.damage = min(this->action_chain.chain.damage + 5, 99); log.debug("(has flag 0x100) chain damage = %hhd", this->action_chain.chain.damage); } @@ -1130,7 +1130,7 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor log.debug("skipped applying action conditions (2)"); } - if (!is_trial) { + if (!is_nte) { num_assists = s->assist_server->compute_num_assist_effects_for_client(this->get_client_id()); for (size_t z = 0; z < num_assists; z++) { switch (s->assist_server->get_active_assist_by_index(z)) { @@ -1157,10 +1157,10 @@ void Card::compute_action_chain_results(bool apply_action_conditions, bool ignor } void Card::unknown_802380C0() { - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); this->card_flags &= 0xFFFFF7FB; - this->action_metadata.clear_flags(is_trial ? 0x10 : 0x30); - this->action_chain.clear_flags(is_trial ? 0x40 : 0x140); + this->action_metadata.clear_flags(is_nte ? 0x10 : 0x30); + this->action_chain.clear_flags(is_nte ? 0x40 : 0x140); this->unknown_80237F98(0); } @@ -1188,7 +1188,7 @@ void Card::unknown_80237F98(bool require_condition_20_or_21) { } this->compute_action_chain_results(1, false); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { this->unknown_80236554(nullptr, nullptr); } if (should_send_updates) { @@ -1201,14 +1201,14 @@ void Card::unknown_80237F88() { } void Card::draw_phase_before() { - if (!this->server()->options.is_trial()) { + if (!this->server()->options.is_nte()) { this->facing_direction = Direction::INVALID_FF; } this->server()->card_special->draw_phase_before_for_card(this->shared_from_this()); } void Card::action_phase_before() { - if (!this->server()->options.is_trial()) { + if (!this->server()->options.is_nte()) { this->clear_action_chain_and_metadata_and_most_flags(); } this->server()->card_special->action_phase_before_for_card(this->shared_from_this()); @@ -1280,7 +1280,7 @@ void Card::unknown_80237A90(const ActionState& pa, uint16_t action_card_ref) { this->facing_direction = pa.facing_direction; this->action_chain.add_attack_action_card_ref(action_card_ref, s); - if (s->options.is_trial()) { + if (s->options.is_nte()) { if (s->ruler_server->count_targets_with_rampage_and_not_pierce_nte(pa)) { this->action_chain.set_flags(0x02); } @@ -1350,7 +1350,7 @@ void Card::dice_phase_before() { } } } - if (s->options.is_trial()) { + if (s->options.is_nte()) { this->clear_action_chain_and_metadata_and_most_flags(); } s->card_special->dice_phase_before_for_card(this->shared_from_this()); @@ -1437,14 +1437,14 @@ void Card::unknown_802362D8(shared_ptr other_card) { void Card::apply_attack_result() { auto s = this->server(); auto ps = this->player_state(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); auto log = s->log_stack(string_printf("apply_attack_result(@%04hX #%04hX): ", this->get_card_ref(), this->get_card_id())); if (!this->action_chain.can_apply_attack()) { return; } - if (is_trial) { + if (is_nte) { if (this->action_chain.check_flag(0x02)) { auto first_target_card = s->card_for_set_card_ref(this->action_chain.chain.target_card_refs[0]); if (first_target_card) { @@ -1580,7 +1580,7 @@ void Card::apply_attack_result() { this->action_chain.set_flags(4); this->card_flags |= 0x200; this->action_chain.clear_target_card_refs(); - if (!is_trial) { + if (!is_nte) { for (size_t client_id = 0; client_id < 4; client_id++) { auto ps = s->player_states[client_id]; if (ps) { diff --git a/src/Episode3/CardSpecial.cc b/src/Episode3/CardSpecial.cc index 59f45ec2..945ab6aa 100644 --- a/src/Episode3/CardSpecial.cc +++ b/src/Episode3/CardSpecial.cc @@ -151,7 +151,7 @@ shared_ptr CardSpecial::server() const { void CardSpecial::adjust_attack_damage_due_to_conditions( shared_ptr target_card, int16_t* inout_damage, uint16_t attacker_card_ref) { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); shared_ptr attacker_card = s->card_for_set_card_ref(attacker_card_ref); auto attack_medium = attacker_card ? attacker_card->action_chain.chain.attack_medium : AttackMedium::UNKNOWN; @@ -161,7 +161,7 @@ void CardSpecial::adjust_attack_damage_due_to_conditions( if (cond.type == ConditionType::NONE) { continue; } - if (!is_trial && this->card_ref_has_ability_trap(cond)) { + if (!is_nte && this->card_ref_has_ability_trap(cond)) { continue; } @@ -176,7 +176,7 @@ void CardSpecial::adjust_attack_damage_due_to_conditions( switch (cond.type) { case ConditionType::WEAK_HIT_BLOCK: - if (!is_trial && (*inout_damage <= cond.value)) { + if (!is_nte && (*inout_damage <= cond.value)) { *inout_damage = 0; } break; @@ -194,7 +194,7 @@ void CardSpecial::adjust_attack_damage_due_to_conditions( exp_deduction = *inout_damage; *inout_damage = 0; } - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_exp_change(target_card, attacker_card_ref, -exp_deduction, true); } this->compute_team_dice_bonus(target_team_id); @@ -203,13 +203,13 @@ void CardSpecial::adjust_attack_damage_due_to_conditions( } case ConditionType::UNKNOWN_73: - if (!is_trial && (cond.value <= *inout_damage)) { + if (!is_nte && (cond.value <= *inout_damage)) { *inout_damage = 0; } break; case ConditionType::HALFGUARD: - if (!is_trial && (cond.value <= *inout_damage)) { + if (!is_nte && (cond.value <= *inout_damage)) { *inout_damage /= 2; } break; @@ -231,7 +231,7 @@ void CardSpecial::adjust_dice_boost_if_team_has_condition_52( } for (size_t z = 0; z < 9; z++) { - if ((this->server()->options.is_trial() || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && + if ((this->server()->options.is_nte() || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && (card->action_chain.conditions[z].type == ConditionType::UNKNOWN_52)) { *inout_dice_boost = *inout_dice_boost * card->action_chain.conditions[z].value8; } @@ -310,10 +310,10 @@ bool CardSpecial::apply_defense_condition( } auto s = this->server(); - bool is_trial = s->options.is_trial(); - bool defender_has_ability_trap = !is_trial && this->card_ref_has_ability_trap(*defender_cond); + bool is_nte = s->options.is_nte(); + bool defender_has_ability_trap = !is_nte && this->card_ref_has_ability_trap(*defender_cond); - if ((is_trial || (flags & 4)) && !this->is_card_targeted_by_condition(*defender_cond, defense_state, defender_card)) { + if ((is_nte || (flags & 4)) && !this->is_card_targeted_by_condition(*defender_cond, defense_state, defender_card)) { if (defender_cond->type != ConditionType::NONE) { G_ApplyConditionEffect_Ep3_6xB4x06 cmd; cmd.effect.flags = 0x04; @@ -345,7 +345,7 @@ bool CardSpecial::apply_defense_condition( } } - if (s->options.is_trial()) { + if (s->options.is_nte()) { auto defender_ps = defender_card->player_state(); if ((when == 0x0F) && (flags & 4) && (defender_cond->type == ConditionType::DROP) && defender_ps) { auto defender_sc_card = defender_ps->get_sc_card(); @@ -397,7 +397,7 @@ bool CardSpecial::apply_defense_condition( *defender_cond, defender_card, expr_value, defender_cond->value, orig_eff->type, flags, attacker_card_ref); if (flags & 4) { - if (is_trial || !(defender_card->card_flags & 2)) { + if (is_nte || !(defender_card->card_flags & 2)) { defender_card->compute_action_chain_results(true, false); } defender_card->action_chain.chain.card_ap = defender_card->ap; @@ -458,13 +458,13 @@ bool CardSpecial::apply_stat_deltas_to_all_cards_from_all_conditions_with_card_r bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condition& cond, shared_ptr card) { auto s = this->server(); auto log = s->log_stack(string_printf("apply_stat_deltas_to_card_from_condition_and_clear_cond(@%04hX #%04hX): ", card->get_card_ref(), card->get_card_id())); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); string cond_str = cond.str(); log.debug("cond: %s", cond_str.c_str()); ConditionType cond_type = cond.type; - int16_t cond_value = is_trial ? cond.value.load() : clamp(cond.value, -99, 99); + int16_t cond_value = is_nte ? cond.value.load() : clamp(cond.value, -99, 99); uint8_t cond_flags = cond.flags; uint16_t cond_card_ref = card->get_card_ref(); cond.clear(); @@ -475,7 +475,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit int16_t ap = clamp(card->ap, -99, 99); int16_t tp = clamp(card->tp, -99, 99); log.debug("A_T_SWAP_0C: swapping AP (%hd) and TP (%hd)", ap, tp); - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0xA0, tp - ap, 0, 0); this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0x80, ap - tp, 0, 0); } @@ -491,7 +491,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit int16_t hp = clamp(card->get_current_hp(), -99, 99); if (hp != ap) { log.debug("A_H_SWAP: swapping AP (%hd) and HP (%hd)", ap, hp); - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0xA0, hp - ap, 0, 0); this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0x20, ap - hp, 0, 0); } @@ -510,9 +510,9 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit // Note: In NTE, this case behaves intuitively, but in non-NTE, it seems // that find_condition was changed to always return null. Perhaps this // was an accident, or perhaps not, but we implement both behaviors. - Condition* other_cond = is_trial ? card->find_condition(ConditionType::AP_OVERRIDE) : nullptr; + Condition* other_cond = is_nte ? card->find_condition(ConditionType::AP_OVERRIDE) : nullptr; if (!other_cond) { - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0xA0, -cond_value, 0, 0); } card->ap = max(card->ap - cond_value, 0); @@ -527,9 +527,9 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit case ConditionType::TP_OVERRIDE: if (cond_flags & 2) { // See note in the AP_OVERRIDE case about why non-NTE always uses null. - Condition* other_cond = is_trial ? card->find_condition(ConditionType::TP_OVERRIDE) : nullptr; + Condition* other_cond = is_nte ? card->find_condition(ConditionType::TP_OVERRIDE) : nullptr; if (!other_cond) { - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0x80, -cond_value, 0, 0); } card->tp = max(card->tp - cond_value, 0); @@ -543,7 +543,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit break; case ConditionType::MISC_AP_BONUSES: if (cond_flags & 2) { - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0xA0, -cond_value, 0, 0); } card->ap = max(card->ap - cond_value, 0); @@ -554,7 +554,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit break; case ConditionType::MISC_TP_BONUSES: if (cond_flags & 2) { - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_stat_delta(card, cond_card_ref, 0x80, -cond_value, 0, 0); } card->tp = max(card->tp - cond_value, 0); @@ -564,7 +564,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit } break; case ConditionType::AP_SILENCE: - if (is_trial) { + if (is_nte) { goto trial_unimplemented; } if (cond_flags & 2) { @@ -576,7 +576,7 @@ bool CardSpecial::apply_stat_deltas_to_card_from_condition_and_clear_cond(Condit } break; case ConditionType::TP_SILENCE: - if (is_trial) { + if (is_nte) { goto trial_unimplemented; } if (cond_flags & 2) { @@ -641,7 +641,7 @@ void CardSpecial::compute_attack_ap( int16_t* out_value, uint16_t attacker_card_ref) { auto s = this->server(); - auto is_trial = s->options.is_trial(); + auto is_nte = s->options.is_nte(); auto attacker_card = s->card_for_set_card_ref(attacker_card_ref); AttackMedium attacker_sc_attack_medium = attacker_card @@ -656,7 +656,7 @@ void CardSpecial::compute_attack_ap( for (size_t cond_index = 0; cond_index < 9; cond_index++) { auto& cond = card->action_chain.conditions[cond_index]; if (cond.type == ConditionType::NONE || - (!is_trial && this->card_ref_has_ability_trap(cond)) || + (!is_nte && this->card_ref_has_ability_trap(cond)) || !s->ruler_server->check_usability_or_apply_condition_for_card_refs( card->action_chain.conditions[cond_index].card_ref, target_card->get_card_ref(), @@ -686,7 +686,7 @@ void CardSpecial::compute_attack_ap( } } - if (!is_trial) { + if (!is_nte) { if (attacker_card && attacker_card->get_condition_value(ConditionType::UNKNOWN_7D)) { *out_value = *out_value * 1.5f; } @@ -704,7 +704,7 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( uint16_t condition_giver_card_ref) { auto s = this->server(); auto log = s->log_stack("compute_attack_env_stats: "); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); string pa_str = pa.str(); log.debug("pa=%s, card=@%04hX #%04hX, dice_roll=%hhu, target=@%04hX, condition_giver=@%04hX", pa_str.c_str(), card->get_card_ref(), card->get_card_id(), dice_roll.value, target_card_ref, condition_giver_card_ref); @@ -723,7 +723,7 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( auto ps = card->player_state(); log.debug("base ps = %hhu", ps->client_id); - ast.num_set_cards = is_trial ? ps->count_set_cards_for_env_stats_nte() : ps->count_set_cards(); + ast.num_set_cards = is_nte ? ps->count_set_cards_for_env_stats_nte() : ps->count_set_cards(); auto condition_giver_card = s->card_for_set_card_ref(condition_giver_card_ref); auto target_card = s->card_for_set_card_ref(target_card_ref); if (!target_card) { @@ -734,7 +734,7 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( for (size_t z = 0; z < 4; z++) { auto other_ps = s->get_player_state(z); if (other_ps) { - ps_num_set_cards += is_trial ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); + ps_num_set_cards += is_nte ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); } } ast.total_num_set_cards = ps_num_set_cards; @@ -749,9 +749,9 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( auto other_ps = s->get_player_state(z); if (other_ps) { if (target_card_team_id == other_ps->get_team_id()) { - target_team_num_set_cards += is_trial ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); + target_team_num_set_cards += is_nte ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); } else { - non_target_team_num_set_cards += is_trial ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); + non_target_team_num_set_cards += is_nte ? other_ps->count_set_cards_for_env_stats_nte() : other_ps->count_set_cards(); } } } @@ -780,7 +780,7 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( } ast.num_item_or_creature_cards_in_hand = num_item_or_creature_cards_in_hand; - if (is_trial) { + if (is_nte) { ast.num_destroyed_ally_fcs = s->team_num_cards_destroyed[ps->get_team_id()] - card->num_ally_fcs_destroyed_at_set_time; } else { ast.num_destroyed_ally_fcs = card->num_destroyed_ally_fcs; @@ -870,7 +870,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( uint32_t* unknown_p11, uint16_t sc_card_ref) { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); auto attacker_card = s->card_for_set_card_ref(attacker_card_ref); auto target_card = s->card_for_set_card_ref(target_card_ref); @@ -891,7 +891,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( target_card_loc.x = 0; target_card_loc.y = 0; target_card_loc.direction = Direction::RIGHT; - } else if (is_trial) { + } else if (is_nte) { target_card_loc = target_card->loc; } else { this->get_card1_loc_with_card2_opposite_direction(&target_card_loc, target_card, attacker_card); @@ -910,12 +910,12 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( return nullptr; } - uint32_t pierce_flag = is_trial ? 0x00000080 : (0x00002000 << target_client_id); + uint32_t pierce_flag = is_nte ? 0x00000080 : (0x00002000 << target_client_id); bool has_pierce = ((target_client_id != 0xFF) && attacker_card && (attacker_card->action_chain.check_flag(pierce_flag))); - if (has_pierce && is_trial) { + if (has_pierce && is_nte) { return nullptr; } @@ -923,7 +923,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( if (target_card && !(target_card->card_flags & 3)) { for (size_t x = 0; x < 9; x++) { auto& cond = target_card->action_chain.conditions[x]; - if (!is_trial && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { + if (!is_nte && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { continue; } if (cond.type == ConditionType::NONE) { @@ -941,7 +941,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( continue; } auto target_ps = target_card->player_state(); - if (has_pierce || (!is_trial && (unknown_p7 != 0)) || !target_ps) { + if (has_pierce || (!is_nte && (unknown_p7 != 0)) || !target_ps) { continue; } @@ -1007,7 +1007,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( for (size_t z = 0; (z < 9) && (candidate_cards.size() < 36); z++) { auto& cond = other_set_card->action_chain.conditions[z]; - if (!is_trial && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { + if (!is_nte && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { continue; } if (cond.type == ConditionType::NONE) { @@ -1025,7 +1025,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( switch (other_set_card->action_chain.conditions[z].type) { case ConditionType::GUARD_CREATURE: if (!has_pierce && - (is_trial || (unknown_p7 != 0)) && + (is_nte || (unknown_p7 != 0)) && ((unknown_p3 != 0) || (unknown_p4 != 0)) && (target_client_id == client_id) && target_card && @@ -1035,11 +1035,11 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::DEFENDER: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && (unknown_p4 != 0) && (target_card_ref == other_set_card->action_chain.conditions[z].condition_giver_card_ref)) { candidate_cards.emplace_back(other_set_card); - if (!is_trial && unknown_p11 && (def_effect_index != 0xFF) && (set_card_ref != 0xFFFF) && + if (!is_nte && unknown_p11 && (def_effect_index != 0xFF) && (set_card_ref != 0xFFFF) && !s->ruler_server->check_usability_or_apply_condition_for_card_refs( set_card_ref, sc_card_ref, other_set_card->get_card_ref(), def_effect_index, attack_medium)) { *unknown_p11 = 1; @@ -1048,7 +1048,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::UNKNOWN_39: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && (unknown_p3 != 0) && (target_card_ref == other_set_card->action_chain.conditions[z].condition_giver_card_ref)) { candidate_cards.emplace_back(other_set_card); @@ -1056,7 +1056,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::SURVIVAL_DECOYS: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && attacker_card && (attacker_card->action_chain.chain.target_card_ref_count > 1) && (unknown_p3 != 0) && @@ -1065,7 +1065,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( } break; case ConditionType::REFLECT: - if (!is_trial && (unknown_p7 == 0) && (unknown_p3 != 0)) { + if (!is_nte && (unknown_p7 == 0) && (unknown_p3 != 0)) { if (target_card_ref == other_set_card->action_chain.conditions[z].condition_giver_card_ref) { if (unknown_p9) { *unknown_p9 = 0; @@ -1083,10 +1083,10 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( } auto other_sc = other_ps->get_sc_card(); - if (other_sc && !(other_sc->card_flags & (is_trial ? 1 : 3))) { + if (other_sc && !(other_sc->card_flags & (is_nte ? 1 : 3))) { for (size_t z = 0; (z < 9) && (candidate_cards.size() < 36); z++) { auto& cond = other_sc->action_chain.conditions[z]; - if (!is_trial && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { + if (!is_nte && (unknown_p7 == 0) && this->card_ref_has_ability_trap(cond)) { continue; } if (cond.type == ConditionType::NONE) { @@ -1104,7 +1104,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( switch (cond.type) { case ConditionType::GUARD_CREATURE: if (!has_pierce && - (is_trial || (unknown_p7 != 0)) && + (is_nte || (unknown_p7 != 0)) && ((unknown_p3 != 0) || (unknown_p4 != 0)) && (target_client_id == client_id) && target_card && @@ -1114,11 +1114,11 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::DEFENDER: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && (unknown_p4 != 0) && (target_card_ref == cond.condition_giver_card_ref)) { candidate_cards.emplace_back(other_sc); - if (!is_trial && unknown_p11 && (def_effect_index != 0xFF) && (set_card_ref != 0xFFFF) && + if (!is_nte && unknown_p11 && (def_effect_index != 0xFF) && (set_card_ref != 0xFFFF) && !s->ruler_server->check_usability_or_apply_condition_for_card_refs( set_card_ref, sc_card_ref, other_sc->get_card_ref(), def_effect_index, attack_medium)) { *unknown_p11 = 1; @@ -1127,7 +1127,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::UNKNOWN_39: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && (unknown_p3 != 0) && (target_card_ref == cond.condition_giver_card_ref)) { candidate_cards.emplace_back(other_sc); @@ -1135,7 +1135,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( break; case ConditionType::SURVIVAL_DECOYS: if (!has_pierce && - (is_trial || (unknown_p7 == 0)) && + (is_nte || (unknown_p7 == 0)) && attacker_card && (attacker_card->action_chain.chain.target_card_ref_count > 1) && (unknown_p3 != 0) && @@ -1144,7 +1144,7 @@ shared_ptr CardSpecial::compute_replaced_target_based_on_conditions( } break; case ConditionType::REFLECT: - if (!is_trial && (unknown_p7 == 0) && (unknown_p3 != 0)) { + if (!is_nte && (unknown_p7 == 0) && (unknown_p3 != 0)) { if (target_card_ref == cond.condition_giver_card_ref) { if (unknown_p9) { *unknown_p9 = 0; @@ -1325,7 +1325,7 @@ size_t CardSpecial::count_cards_with_card_id_except_card_ref( vector> CardSpecial::get_all_set_cards_by_team_and_class( CardClass card_class, uint8_t team_id, bool exclude_destroyed_cards) const { auto s = this->server(); - if (s->options.is_trial()) { + if (s->options.is_nte()) { team_id = 0xFF; exclude_destroyed_cards = false; } @@ -1425,13 +1425,13 @@ bool CardSpecial::evaluate_effect_arg2_condition( auto set_card = s->card_for_set_card_ref(set_card_ref); bool set_card_has_ability_trap = - (!s->options.is_trial() && + (!s->options.is_nte() && set_card && this->card_has_condition_with_ref(set_card, ConditionType::ABILITY_TRAP, 0xFFFF, 0xFFFF)); switch (arg2_text[0]) { case 'C': - if (s->options.is_trial()) { + if (s->options.is_nte()) { return false; } card = s->card_for_set_card_ref(set_card_ref); @@ -1533,16 +1533,16 @@ bool CardSpecial::evaluate_effect_arg2_condition( uint16_t action_card_ref = as.action_card_refs[z]; if (action_card_ref != 0xFFFF) { auto ce = s->definition_for_card_ref(action_card_ref); - if (card_class_is_tech_like(ce->def.card_class(), s->options.is_trial())) { + if (card_class_is_tech_like(ce->def.card_class(), s->options.is_nte())) { return true; } } } return false; case 0x04: // n04 - return card->action_chain.check_flag(s->options.is_trial() ? 0x00000080 : 0x0001E000); + return card->action_chain.check_flag(s->options.is_nte() ? 0x00000080 : 0x0001E000); case 0x05: // n05 - return card->action_chain.check_flag(s->options.is_trial() ? 0x00000002 : 0x00001E00); + return card->action_chain.check_flag(s->options.is_nte() ? 0x00000002 : 0x00001E00); case 0x06: // n06 return (card->get_definition()->def.card_class() == CardClass::NATIVE_CREATURE); case 0x07: // n07 @@ -1560,7 +1560,7 @@ bool CardSpecial::evaluate_effect_arg2_condition( case 0x0D: { // n13 auto ce = card->get_definition(); return ((ce->def.card_class() == CardClass::GUARD_ITEM) || - (!s->options.is_trial() && (ce->def.card_class() == CardClass::MAG_ITEM)) || + (!s->options.is_nte() && (ce->def.card_class() == CardClass::MAG_ITEM)) || s->ruler_server->find_condition_on_card_ref( card->get_card_ref(), ConditionType::GUARD_CREATURE, 0, 0, 0)); } @@ -1600,7 +1600,7 @@ bool CardSpecial::evaluate_effect_arg2_condition( return s->ruler_server->find_condition_on_card_ref( card->get_card_ref(), ConditionType::FREEZE, 0, 0, 0); case 0x15: { // n21 - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { uint8_t client_id = client_id_for_card_ref(sc_card_ref); if (client_id != 0xFF) { return card->action_chain.check_flag(0x00002000 << client_id); @@ -1609,7 +1609,7 @@ bool CardSpecial::evaluate_effect_arg2_condition( return false; } case 0x16: { // n22 - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { uint8_t client_id = client_id_for_card_ref(sc_card_ref); if (client_id != 0xFF) { return card->action_chain.check_flag(0x00000200 << client_id); @@ -1637,7 +1637,7 @@ bool CardSpecial::evaluate_effect_arg2_condition( card, ConditionType::ANY, set_card_ref, ((v % 10) == 0) ? 0xFF : (v % 10)) != nullptr); } case 'r': - return (!set_card_has_ability_trap || s->options.is_trial()) && (random_percent < atoi(arg2_text + 1)); + return (!set_card_has_ability_trap || s->options.is_nte()) && (random_percent < atoi(arg2_text + 1)); case 's': { auto ce = card->get_definition(); return ((ce->def.self_cost >= arg2_text[1] - '0') && @@ -1651,7 +1651,7 @@ bool CardSpecial::evaluate_effect_arg2_condition( uint8_t v = atoi(arg2_text + 1); // TODO: Figure out what this logic actually does and rename the variables // or comment it appropriately. - if (s->options.is_trial()) { + if (s->options.is_nte()) { return (v < set_card->unknown_a9); } else if (when == 4) { uint32_t y = set_card->unknown_a9 & 0xFFFFFFFE; @@ -1778,12 +1778,12 @@ bool CardSpecial::execute_effect( string cond_str = cond.str(); log.debug("cond=%s, card=@%04hX, expr_value=%hd, unknown_p5=%hd, cond_type=%s, unknown_p7=%" PRIu32 ", attacker_card_ref=@%04hX", cond_str.c_str(), ref_for_card(card), expr_value, unknown_p5, name_for_condition_type(cond_type), unknown_p7, attacker_card_ref); } - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); int16_t clamped_expr_value = clamp(expr_value, -99, 99); cond.value8 = clamped_expr_value; - if (!is_trial) { + if (!is_nte) { if (this->card_ref_has_ability_trap(cond)) { return false; } @@ -1807,7 +1807,7 @@ bool CardSpecial::execute_effect( } int16_t positive_expr_value = max(clamped_expr_value, 0); - int16_t clamped_unknown_p5 = clamp(unknown_p5, 0, is_trial ? unknown_p5 : 99); + int16_t clamped_unknown_p5 = clamp(unknown_p5, 0, is_nte ? unknown_p5 : 99); auto attacker_sc = s->card_for_set_card_ref(attacker_card_ref); auto attack_medium = attacker_sc ? attacker_sc->action_chain.chain.attack_medium : AttackMedium::UNKNOWN; @@ -1834,7 +1834,7 @@ bool CardSpecial::execute_effect( return false; case ConditionType::MV_BONUS: - if (is_trial) { + if (is_nte) { return false; } [[fallthrough]]; @@ -1847,7 +1847,7 @@ bool CardSpecial::execute_effect( case ConditionType::AP_BOOST: if (unknown_p7 & 1) { - if (is_trial) { + if (is_nte) { card->action_chain.chain.ap_effect_bonus += positive_expr_value; } else { card->action_chain.chain.ap_effect_bonus = clamp( @@ -1870,7 +1870,7 @@ bool CardSpecial::execute_effect( case ConditionType::TP_BOOST: if (unknown_p7 & 1) { - if (is_trial) { + if (is_nte) { card->action_chain.chain.tp_effect_bonus += positive_expr_value; } else { card->action_chain.chain.tp_effect_bonus = clamp( @@ -1881,8 +1881,8 @@ bool CardSpecial::execute_effect( case ConditionType::GIVE_DAMAGE: if ((unknown_p7 & 4) != 0) { - int16_t current_hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); - int16_t new_hp = is_trial ? (current_hp - positive_expr_value) : clamp(current_hp - positive_expr_value, -99, 99); + int16_t current_hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t new_hp = is_nte ? (current_hp - positive_expr_value) : clamp(current_hp - positive_expr_value, -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, -positive_expr_value, 0, 1); new_hp = max(new_hp, 0); if (new_hp != current_hp) { @@ -1895,8 +1895,8 @@ bool CardSpecial::execute_effect( case ConditionType::A_T_SWAP_0C: case ConditionType::A_T_SWAP_PERM: if (unknown_p7 & 4) { - int16_t ap = is_trial ? card->ap : clamp(card->ap, -99, 99); - int16_t tp = is_trial ? card->tp : clamp(card->tp, -99, 99); + int16_t ap = is_nte ? card->ap : clamp(card->ap, -99, 99); + int16_t tp = is_nte ? card->tp : clamp(card->tp, -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0xA0, tp - ap, 0, 0); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x80, ap - tp, 0, 0); card->ap = tp; @@ -1908,8 +1908,8 @@ bool CardSpecial::execute_effect( case ConditionType::A_H_SWAP: case ConditionType::A_H_SWAP_PERM: if (unknown_p7 & 4) { - int16_t ap = is_trial ? card->ap : clamp(card->ap, -99, 99); - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t ap = is_nte ? card->ap : clamp(card->ap, -99, 99); + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0xA0, hp - ap, 0, 0); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, ap - hp, 1, 0); cond.flags |= 2; @@ -1923,8 +1923,8 @@ bool CardSpecial::execute_effect( case ConditionType::HEAL: if (unknown_p7 & 4) { - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); - int16_t new_hp = is_trial ? (hp + positive_expr_value) : clamp(hp + positive_expr_value, -99, 99); + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t new_hp = is_nte ? (hp + positive_expr_value) : clamp(hp + positive_expr_value, -99, 99); log.debug("HEAL: hp=%hd, positive_expr_value=%hd, new_hp=%hd", hp, positive_expr_value, new_hp); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, new_hp - hp, true, true); if (new_hp != hp) { @@ -1948,7 +1948,7 @@ bool CardSpecial::execute_effect( return true; } this->send_6xB4x06_for_card_destroyed(card, attacker_card_ref); - if (!is_trial) { + if (!is_nte) { card->unknown_802380C0(); } if (!ps->return_set_card_to_hand1(card->get_card_ref())) { @@ -1973,9 +1973,9 @@ bool CardSpecial::execute_effect( case ConditionType::UNIT_BLOW: if (unknown_p7 & 1) { size_t count = this->count_action_cards_with_condition_for_all_current_attacks(ConditionType::UNIT_BLOW, 0xFFFF); - int16_t clamped_count = is_trial ? count : clamp(count, -99, 99); + int16_t clamped_count = is_nte ? count : clamp(count, -99, 99); int16_t result = card->action_chain.chain.ap_effect_bonus + clamped_count * positive_expr_value; - card->action_chain.chain.ap_effect_bonus = is_trial ? result : clamp(result, -99, 99); + card->action_chain.chain.ap_effect_bonus = is_nte ? result : clamp(result, -99, 99); } return false; @@ -1986,7 +1986,7 @@ bool CardSpecial::execute_effect( if (target_card) { CardShortStatus stat = target_card->get_short_status(); if (stat.card_flags & 2) { - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); int16_t new_hp = max(0, hp - 1); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, -1, 0, 1); if (hp != new_hp) { @@ -2002,9 +2002,9 @@ bool CardSpecial::execute_effect( case ConditionType::COMBO_AP: if (unknown_p7 & 1) { int16_t count = this->count_action_cards_with_condition_for_all_current_attacks(ConditionType::COMBO_AP, 0xFFFF); - int16_t clamped_count = is_trial ? count : clamp(count, -99, 99); + int16_t clamped_count = is_nte ? count : clamp(count, -99, 99); int16_t result = card->action_chain.chain.ap_effect_bonus + clamped_count * clamped_count; - card->action_chain.chain.ap_effect_bonus = is_trial ? result : clamp(result, -99, 99); + card->action_chain.chain.ap_effect_bonus = is_nte ? result : clamp(result, -99, 99); } return false; @@ -2018,7 +2018,7 @@ bool CardSpecial::execute_effect( return true; case ConditionType::ABILITY_TRAP: - if (is_trial && (unknown_p7 & 4)) { + if (is_nte && (unknown_p7 & 4)) { bool needs_update = false; for (ssize_t z = 8; z >= 0; z--) { auto& cond = card->action_chain.conditions[z]; @@ -2059,9 +2059,9 @@ bool CardSpecial::execute_effect( (cond.type == ConditionType::ADD_1_TO_MV_COST) || (cond.type == ConditionType::CURSE) || (cond.type == ConditionType::PIERCE_RAMPAGE_BLOCK) || - (!is_trial && (cond.type == ConditionType::FREEZE)) || + (!is_nte && (cond.type == ConditionType::FREEZE)) || (cond.type == ConditionType::UNKNOWN_1E) || - (!is_trial && (cond.type == ConditionType::DROP))) { + (!is_nte && (cond.type == ConditionType::DROP))) { G_ApplyConditionEffect_Ep3_6xB4x06 cmd; cmd.effect.flags = 0x04; cmd.effect.attacker_card_ref = this->send_6xB4x06_if_card_ref_invalid(attacker_card_ref, 0x0C); @@ -2081,7 +2081,7 @@ bool CardSpecial::execute_effect( if (unknown_p7 & 4) { auto sc_card = s->card_for_set_card_ref(attacker_card_ref); if (!sc_card || (sc_card->action_chain.chain.attack_medium == AttackMedium::PHYSICAL)) { - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); int16_t new_hp = lround(hp * 0.5f); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, new_hp - hp, 0, 1); if (new_hp != hp) { @@ -2093,10 +2093,10 @@ bool CardSpecial::execute_effect( return true; case ConditionType::EXPLOSION: - if (unknown_p7 & (is_trial ? 0x02 : 0x40)) { + if (unknown_p7 & (is_nte ? 0x02 : 0x40)) { size_t count = this->count_action_cards_with_condition_for_all_current_attacks(ConditionType::EXPLOSION, 0xFFFF); - int16_t clamped_count = is_trial ? count : clamp(count, -99, 99); - card->action_metadata.attack_bonus = is_trial + int16_t clamped_count = is_nte ? count : clamp(count, -99, 99); + card->action_metadata.attack_bonus = is_nte ? (clamped_count * clamped_count) : clamp(clamped_count * clamped_count, -99, 99); } @@ -2121,16 +2121,16 @@ bool CardSpecial::execute_effect( if (!ps) { return false; } - if (!is_trial) { + if (!is_nte) { card->unknown_802380C0(); } - return ps->discard_card_or_add_to_draw_pile(card->get_card_ref(), !is_trial); + return ps->discard_card_or_add_to_draw_pile(card->get_card_ref(), !is_nte); } case ConditionType::AP_LOSS: if (unknown_p7 & 1) { int16_t new_value = card->action_chain.chain.ap_effect_bonus - positive_expr_value; - card->action_chain.chain.ap_effect_bonus = is_trial ? new_value : clamp(new_value, -99, 99); + card->action_chain.chain.ap_effect_bonus = is_nte ? new_value : clamp(new_value, -99, 99); } return true; @@ -2138,7 +2138,7 @@ bool CardSpecial::execute_effect( if (unknown_p7 & 1) { size_t leader_count = this->count_cards_with_card_id_except_card_ref(expr_value, 0xFFFF); int16_t new_value = card->action_chain.chain.ap_effect_bonus + leader_count; - card->action_chain.chain.ap_effect_bonus = is_trial ? new_value : clamp(new_value, -99, 99); + card->action_chain.chain.ap_effect_bonus = is_nte ? new_value : clamp(new_value, -99, 99); } return true; @@ -2146,8 +2146,8 @@ bool CardSpecial::execute_effect( if (unknown_p7 & 4) { this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, positive_expr_value, 0, 1); if (positive_expr_value != 0) { - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); - int16_t new_hp = is_trial ? (hp + positive_expr_value) : clamp(hp + positive_expr_value, -99, 99); + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t new_hp = is_nte ? (hp + positive_expr_value) : clamp(hp + positive_expr_value, -99, 99); card->set_current_hp(new_hp, true, false); this->destroy_card_if_hp_zero(card, attacker_card_ref); } @@ -2175,7 +2175,7 @@ bool CardSpecial::execute_effect( } this->compute_team_dice_bonus(attacker_team_id); this->compute_team_dice_bonus(target_team_id); - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_exp_change(card, attacker_card_ref, -positive_expr_value, 1); } s->update_battle_state_flags_and_send_6xB4x03_if_needed(); @@ -2207,7 +2207,7 @@ bool CardSpecial::execute_effect( } case ConditionType::DROP: - if (!is_trial && (unknown_p7 & 4)) { + if (!is_nte && (unknown_p7 & 4)) { auto ps = card->player_state(); if (ps) { uint8_t team_id = ps->get_team_id(); @@ -2226,7 +2226,7 @@ bool CardSpecial::execute_effect( case ConditionType::ACTION_DISRUPTER: if (unknown_p7 & 4) { - if (is_trial) { + if (is_nte) { card->action_metadata.defense_card_ref_count = 0; } else { for (size_t z = 0; z < card->action_chain.chain.attack_action_card_ref_count; z++) { @@ -2298,7 +2298,7 @@ bool CardSpecial::execute_effect( } else { s->team_exp[team_id] = existing_exp + clamped_expr_value; } - if (!is_trial) { + if (!is_nte) { this->send_6xB4x06_for_exp_change(card, attacker_card_ref, clamped_expr_value, 1); } this->compute_team_dice_bonus(team_id); @@ -2318,7 +2318,7 @@ bool CardSpecial::execute_effect( if (attacker_sc && (unknown_p7 & 4)) { vector card_refs; card_refs.emplace_back(attacker_sc->get_card_ref()); - if (is_trial) { + if (is_nte) { for (size_t z = 0; z < attacker_sc->action_chain.chain.target_card_ref_count; z++) { card_refs.emplace_back(attacker_sc->action_chain.chain.target_card_refs[z]); } @@ -2347,17 +2347,17 @@ bool CardSpecial::execute_effect( auto ce = card->get_definition(); if (ce) { size_t count = this->count_cards_with_card_id_except_card_ref(ce->def.card_id, card->get_card_ref()); - int16_t clamped_count = is_trial ? count : clamp(count, -99, 99); + int16_t clamped_count = is_nte ? count : clamp(count, -99, 99); int16_t new_value = card->action_chain.chain.ap_effect_bonus + clamped_count * positive_expr_value; - card->action_chain.chain.ap_effect_bonus = is_trial ? new_value : clamp(new_value, -99, 99); + card->action_chain.chain.ap_effect_bonus = is_nte ? new_value : clamp(new_value, -99, 99); } } return true; case ConditionType::BERSERK: if (unknown_p7 & 4) { - int16_t hp = is_trial ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); - int16_t new_hp = is_trial + int16_t hp = is_nte ? card->get_current_hp() : clamp(card->get_current_hp(), -99, 99); + int16_t new_hp = is_nte ? (hp - card->action_chain.chain.damage) : clamp(hp - this->max_all_attack_bonuses(nullptr), -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x20, new_hp - hp, false, true); @@ -2394,7 +2394,7 @@ bool CardSpecial::execute_effect( case ConditionType::AP_GROWTH: if (unknown_p7 & 4) { this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0xA0, positive_expr_value, 0, 1); - card->ap = is_trial + card->ap = is_nte ? (card->ap + positive_expr_value) : clamp(card->ap + positive_expr_value, -99, 99); } @@ -2403,7 +2403,7 @@ bool CardSpecial::execute_effect( case ConditionType::TP_GROWTH: if (unknown_p7 & 4) { this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x80, positive_expr_value, 0, 1); - card->tp = is_trial + card->tp = is_nte ? (card->tp + positive_expr_value) : clamp(card->tp + positive_expr_value, -99, 99); } @@ -2415,7 +2415,7 @@ bool CardSpecial::execute_effect( if (attacker_card && (attacker_card != card)) { int16_t new_ap = (positive_expr_value < 51) ? (card->ap / 2) : card->ap; int16_t new_tp = (positive_expr_value < 51) ? (card->tp / 2) : card->tp; - if (!is_trial) { + if (!is_nte) { new_ap = clamp(new_ap, -99, 99); new_tp = clamp(new_tp, -99, 99); } @@ -2430,13 +2430,13 @@ bool CardSpecial::execute_effect( case ConditionType::MISC_GUARDS: if (unknown_p7 & 8) { int16_t new_value = positive_expr_value + card->action_metadata.defense_bonus; - card->action_metadata.defense_bonus = is_trial ? new_value : clamp(new_value, -99, 99); + card->action_metadata.defense_bonus = is_nte ? new_value : clamp(new_value, -99, 99); } return true; case ConditionType::AP_OVERRIDE: if ((unknown_p7 & 4) && !(cond.flags & 2)) { - cond.value = is_trial ? (positive_expr_value - card->ap) : clamp(positive_expr_value - card->ap, -99, 99); + cond.value = is_nte ? (positive_expr_value - card->ap) : clamp(positive_expr_value - card->ap, -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0xA0, cond.value, false, false); card->ap = positive_expr_value; cond.flags |= 2; @@ -2445,7 +2445,7 @@ bool CardSpecial::execute_effect( case ConditionType::TP_OVERRIDE: if ((unknown_p7 & 4) && !(cond.flags & 2)) { - cond.value = is_trial ? (positive_expr_value - card->tp) : clamp(positive_expr_value - card->tp, -99, 99); + cond.value = is_nte ? (positive_expr_value - card->tp) : clamp(positive_expr_value - card->tp, -99, 99); this->send_6xB4x06_for_stat_delta(card, attacker_card_ref, 0x80, cond.value, false, false); card->tp = positive_expr_value; cond.flags |= 2; @@ -2454,12 +2454,12 @@ bool CardSpecial::execute_effect( case ConditionType::UNKNOWN_64: case ConditionType::FORWARD_DAMAGE: - if (is_trial) { + if (is_nte) { return false; } [[fallthrough]]; case ConditionType::SLAYERS_ASSASSINS: - if (is_trial) { + if (is_nte) { auto card = s->card_for_set_card_ref(attacker_card_ref); bool card_found = false; if (!card) { @@ -2498,13 +2498,13 @@ bool CardSpecial::execute_effect( if (unknown_p7 & 1) { ssize_t count = this->count_cards_with_card_id_except_card_ref(expr_value, 0xFFFF); int16_t new_value = count + card->action_chain.chain.tp_effect_bonus; - card->action_chain.chain.tp_effect_bonus = is_trial ? new_value : clamp(new_value, -99, 99); + card->action_chain.chain.tp_effect_bonus = is_nte ? new_value : clamp(new_value, -99, 99); } return true; case ConditionType::MISC_AP_BONUSES: if ((unknown_p7 & 4) && !(cond.flags & 2)) { - if (is_trial) { + if (is_nte) { int16_t orig_ap = card->ap; card->ap = max(positive_expr_value + card->ap, 0); cond.value = card->ap - orig_ap; @@ -2520,7 +2520,7 @@ bool CardSpecial::execute_effect( case ConditionType::MISC_TP_BONUSES: if ((unknown_p7 & 4) && !(cond.flags & 2)) { - if (is_trial) { + if (is_nte) { int16_t orig_tp = card->tp; card->tp = max(positive_expr_value + card->tp, 0); cond.value = card->tp - orig_tp; @@ -2536,7 +2536,7 @@ bool CardSpecial::execute_effect( case ConditionType::MISC_DEFENSE_BONUSES: case ConditionType::WEAK_SPOT_INFLUENCE: - if (is_trial) { + if (is_nte) { return false; } if (unknown_p7 & 0x20) { @@ -2547,7 +2547,7 @@ bool CardSpecial::execute_effect( case ConditionType::MOSTLY_HALFGUARDS: case ConditionType::DAMAGE_MODIFIER_2: - if (is_trial) { + if (is_nte) { return false; } if (unknown_p7 & 0x40) { @@ -2556,7 +2556,7 @@ bool CardSpecial::execute_effect( return true; case ConditionType::PERIODIC_FIELD: - if (is_trial) { + if (is_nte) { return false; } if ((unknown_p7 & 0x40) && @@ -2566,7 +2566,7 @@ bool CardSpecial::execute_effect( return true; case ConditionType::AP_SILENCE: - if (is_trial) { + if (is_nte) { return false; } if ((unknown_p7 & 4) && !(cond.flags & 2)) { @@ -2579,7 +2579,7 @@ bool CardSpecial::execute_effect( return false; case ConditionType::TP_SILENCE: - if (is_trial) { + if (is_nte) { return false; } if ((unknown_p7 & 4) && !(cond.flags & 2)) { @@ -2592,7 +2592,7 @@ bool CardSpecial::execute_effect( return false; case ConditionType::RAMPAGE_AP_LOSS: - if (is_trial) { + if (is_nte) { return false; } if (unknown_p7 & 1) { @@ -2602,7 +2602,7 @@ bool CardSpecial::execute_effect( return true; case ConditionType::UNKNOWN_77: - if (is_trial) { + if (is_nte) { return false; } if (attacker_sc && (unknown_p7 & 4)) { @@ -2639,7 +2639,7 @@ const Condition* CardSpecial::find_condition_with_parameters( uint16_t set_card_ref, uint8_t def_effect_index) const { - if (this->server()->options.is_trial()) { + if (this->server()->options.is_nte()) { // The NTE version of this function returns a boolean instead of a pointer; // we always return a pointer for simplicity reasons, even for NTE. for (size_t z = 0; z < 9; z++) { @@ -2705,7 +2705,7 @@ void CardSpecial::get_card1_loc_with_card2_opposite_direction( uint16_t CardSpecial::get_card_id_with_effective_range( shared_ptr card1, uint16_t default_card_id, shared_ptr card2) const { auto s = this->server(); - if (s->options.is_trial()) { + if (s->options.is_nte()) { return default_card_id; } else if (card2 && !(static_cast(card2->facing_direction) & 0x80)) { return this->server()->ruler_server->get_card_id_with_effective_range( @@ -2939,18 +2939,18 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; case 0x0A: // p10 ret = this->find_all_cards_on_same_or_other_team(client_id, true); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x0B: // p11 ret = this->find_all_set_cards_on_client_team(client_id); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x0C: // p12 - if (s->options.is_trial()) { + if (s->options.is_nte()) { ret = this->find_cards_by_condition_inc_exc( ConditionType::NONE, ConditionType::AERIAL, AssistEffect::NONE, AssistEffect::FLY); } else { @@ -2960,25 +2960,25 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; case 0x0D: // p13 ret = this->find_cards_by_condition_inc_exc(ConditionType::FREEZE); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x0E: // p14 ret = this->find_cards_in_hp_range(-1000, 3); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x0F: // p15 ret = this->get_all_set_cards(); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x10: { // p16 ret = this->find_cards_in_hp_range(8, 1000); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; @@ -3068,7 +3068,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( ret = this->find_cards_by_condition_inc_exc(ConditionType::PARALYZE); break; case 0x19: // p25 - if (s->options.is_trial()) { + if (s->options.is_nte()) { // This appears to be a copy/paste error in NTE that was fixed in the // final version. Presumably include_cond should be ConditionType::FLY // here, not PARALYZE. @@ -3154,25 +3154,25 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; case 0x24: { // p36 // On NTE, this includes SCs and items; on other versions, it's SCs only - static const auto should_include = +[](shared_ptr ce, bool is_trial) -> bool { - return (ce && (ce->def.is_sc() || (is_trial ? (ce->def.type == CardType::ITEM) : false))); + static const auto should_include = +[](shared_ptr ce, bool is_nte) -> bool { + return (ce && (ce->def.is_sc() || (is_nte ? (ce->def.type == CardType::ITEM) : false))); }; - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); if (as.original_attacker_card_ref == 0xFFFF) { for (size_t z = 0; (z < 4 * 9) && (as.target_card_refs[z] != 0xFFFF); z++) { auto result_card = s->card_for_set_card_ref(as.target_card_refs[z]); - if (result_card && should_include(result_card->get_definition(), is_trial)) { + if (result_card && should_include(result_card->get_definition(), is_nte)) { ret.emplace_back(result_card); } } - } else if (card2 && should_include(card2->get_definition(), is_trial)) { + } else if (card2 && should_include(card2->get_definition(), is_nte)) { ret.emplace_back(card2); } break; } case 0x25: // p37 ret = this->find_all_cards_on_same_or_other_team(client_id, false); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; @@ -3199,13 +3199,13 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; case 0x27: // p39 ret = this->find_all_set_cards_with_cost_in_range(4, 99); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; case 0x28: // p40 ret = this->find_all_set_cards_with_cost_in_range(0, 3); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); } break; @@ -3217,7 +3217,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( parray range; compute_effective_range(range, s->options.card_index, range_card_id, card1_loc, s->map_and_rules); auto result_card_refs = ps->get_all_cards_within_range( - range, card1_loc, s->options.is_trial() ? card1->get_team_id() : 0xFF); + range, card1_loc, s->options.is_nte() ? card1->get_team_id() : 0xFF); for (uint16_t result_card_ref : result_card_refs) { auto result_card = s->card_for_set_card_ref(result_card_ref); if (result_card && @@ -3228,7 +3228,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( } } - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { for (size_t z = 0; z < 8; z++) { auto result_card = ps->get_set_card(z); if (result_card && (card1 != result_card) && @@ -3273,7 +3273,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; } case 0x2B: // p43 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } for (size_t z = 0; (z < 4 * 9) && (as.target_card_refs[z] != 0xFFFF); z++) { @@ -3292,7 +3292,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( } break; case 0x2C: { // p44 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } auto ps = s->get_player_state(client_id); @@ -3308,14 +3308,14 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; } case 0x2D: // p45 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } this->sum_last_attack_damage(&ret, nullptr, nullptr); ret = this->filter_cards_by_range(ret, card1, card1_loc, card2); break; case 0x2E: // p46 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } if (card1) { @@ -3338,7 +3338,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( } break; case 0x2F: { // p47 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } uint8_t client_id = client_id_for_card_ref(as.original_attacker_card_ref); @@ -3351,7 +3351,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( break; } case 0x30: // p48 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } if (card1) { @@ -3392,7 +3392,7 @@ vector> CardSpecial::get_targeted_cards_for_condition( } break; case 0x31: // p49 - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } if (card1) { @@ -3472,7 +3472,7 @@ bool CardSpecial::is_card_targeted_by_condition( ce && ((ce->def.type == CardType::ITEM) || ce->def.is_sc()) && (cond.remaining_turns != 100) && - (s->options.is_trial() || (client_id_for_card_ref(card->get_card_ref()) == client_id_for_card_ref(cond.card_ref)))) { + (s->options.is_nte() || (client_id_for_card_ref(card->get_card_ref()) == client_id_for_card_ref(cond.card_ref)))) { return false; } if (cond.remaining_turns == 102) { @@ -3562,14 +3562,14 @@ void CardSpecial::send_6xB4x06_for_card_destroyed( attacker_card_ref, 0x13); cmd.effect.target_card_ref = destroyed_card->get_card_ref(); cmd.effect.value = 0; - cmd.effect.operation = s->options.is_trial() ? 0x78 : 0x7E; + cmd.effect.operation = s->options.is_nte() ? 0x78 : 0x7E; this->server()->send(cmd); } uint16_t CardSpecial::send_6xB4x06_if_card_ref_invalid( uint16_t card_ref, int16_t value) const { auto s = this->server(); - if (!s->options.is_trial() && !s->card_ref_is_empty_or_has_valid_card_id(card_ref)) { + if (!s->options.is_nte() && !s->card_ref_is_empty_or_has_valid_card_id(card_ref)) { if (value != 0) { G_ApplyConditionEffect_Ep3_6xB4x06 cmd; cmd.effect.flags = 0x04; @@ -3606,15 +3606,15 @@ void CardSpecial::send_6xB4x06_for_stat_delta( } } - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); G_ApplyConditionEffect_Ep3_6xB4x06 cmd; cmd.effect.flags = flags | 2; cmd.effect.attacker_card_ref = this->send_6xB4x06_if_card_ref_invalid(attacker_card_ref, 10); cmd.effect.target_card_ref = card->get_card_ref(); cmd.effect.value = -hp_delta; - cmd.effect.ap = is_trial ? card->ap : clamp(card->ap, 0, 99); + cmd.effect.ap = is_nte ? card->ap : clamp(card->ap, 0, 99); cmd.effect.current_hp = clamp(card->get_current_hp(), 0, 99); - cmd.effect.tp = is_trial ? card->tp : clamp(card->tp, 0, 99); + cmd.effect.tp = is_nte ? card->tp : clamp(card->tp, 0, 99); if (!unknown_p7) { cmd.effect.current_hp |= 0x80; } @@ -3637,7 +3637,7 @@ bool CardSpecial::should_cancel_condition_due_to_anti_abnormality( } auto s = this->server(); - if (s->options.is_trial()) { + if (s->options.is_nte()) { if (this->card_has_condition_with_ref(card, ConditionType::ABILITY_TRAP, 0xFFFF, 0xFFFF)) { return true; } @@ -3650,7 +3650,7 @@ bool CardSpecial::should_cancel_condition_due_to_anti_abnormality( switch (eff.type) { case ConditionType::GUOM: case ConditionType::CURSE: - if (s->options.is_trial()) { + if (s->options.is_nte()) { return false; } [[fallthrough]]; @@ -3660,7 +3660,7 @@ bool CardSpecial::should_cancel_condition_due_to_anti_abnormality( case ConditionType::ACID: case ConditionType::FREEZE: case ConditionType::DROP: { - if (s->options.is_trial()) { + if (s->options.is_nte()) { return (card->find_condition(ConditionType::ANTI_ABNORMALITY_2) != nullptr); } else { const auto* cond = this->find_condition_with_parameters(card, ConditionType::ANTI_ABNORMALITY_2, 0xFFFF, 0xFF); @@ -3821,8 +3821,8 @@ int16_t CardSpecial::max_all_attack_bonuses(size_t* out_count) const { void CardSpecial::unknown_80244AA8(shared_ptr card) { ActionState as = this->create_attack_state_from_card_action_chain(card); - bool is_trial = this->server()->options.is_trial(); - if (!is_trial) { + bool is_nte = this->server()->options.is_nte(); + if (!is_nte) { for (size_t client_id = 0; client_id < 4; client_id++) { auto ps = this->server()->player_states[client_id]; if (ps) { @@ -3842,7 +3842,7 @@ void CardSpecial::unknown_80244AA8(shared_ptr card) { this->evaluate_and_apply_effects(0x27, card->get_card_ref(), as, 0xFFFF); } - this->apply_defense_conditions(as, 0x13, card, is_trial ? 0x1F : 0x04); + this->apply_defense_conditions(as, 0x13, card, is_nte ? 0x1F : 0x04); this->evaluate_and_apply_effects(0x13, card->get_card_ref(), as, 0xFFFF); } @@ -3935,7 +3935,7 @@ void CardSpecial::evaluate_and_apply_effects( uint16_t apply_defense_condition_to_card_ref) { auto s = this->server(); auto log = s->log_stack(string_printf("evaluate_and_apply_effects(%02hhX, @%04hX, @%04hX): ", when, set_card_ref, sc_card_ref)); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); { string as_str = as.str(); @@ -3943,7 +3943,7 @@ void CardSpecial::evaluate_and_apply_effects( when, set_card_ref, as_str.c_str(), sc_card_ref, apply_defense_condition_to_all_cards ? "true" : "false", apply_defense_condition_to_card_ref); } - if (!is_trial) { + if (!is_nte) { set_card_ref = this->send_6xB4x06_if_card_ref_invalid(set_card_ref, 1); } @@ -3953,7 +3953,7 @@ void CardSpecial::evaluate_and_apply_effects( return; } - if (is_trial) { + if (is_nte) { auto set_card = s->card_for_set_card_ref(set_card_ref); if ((set_card != nullptr) && set_card->get_condition_value(ConditionType::ABILITY_TRAP)) { return; @@ -4020,7 +4020,7 @@ void CardSpecial::evaluate_and_apply_effects( string refs_str = refs_str_for_cards_vector(targeted_cards); effect_log.debug("targeted_cards=[%s]", refs_str.c_str()); bool all_targets_matched = false; - if (!is_trial && + if (!is_nte && !targeted_cards.empty() && ((card_effect.type == ConditionType::UNKNOWN_64) || (card_effect.type == ConditionType::MISC_DEFENSE_BONUSES) || @@ -4104,7 +4104,7 @@ void CardSpecial::evaluate_and_apply_effects( cmd.effect.flags = 0x04; cmd.effect.attacker_card_ref = this->send_6xB4x06_if_card_ref_invalid(as_attacker_card_ref, 0x14); cmd.effect.target_card_ref = target_card->get_card_ref(); - cmd.effect.value = is_trial ? 0 : target_card->action_chain.conditions[applied_cond_index].remaining_turns; + cmd.effect.value = is_nte ? 0 : target_card->action_chain.conditions[applied_cond_index].remaining_turns; cmd.effect.operation = static_cast(card_effect.type); s->send(cmd); @@ -4428,8 +4428,8 @@ void CardSpecial::on_card_destroyed( for (size_t cond_index = 0; cond_index < 9; cond_index++) { auto& cond = attacker_card->action_chain.conditions[cond_index]; if (cond.type == ConditionType::CURSE) { - bool is_trial = this->server()->options.is_trial(); - this->execute_effect(cond, attacker_card, 0, 0, ConditionType::CURSE, is_trial ? 0x1F : 0x04, 0xFFFF); + bool is_nte = this->server()->options.is_nte(); + this->execute_effect(cond, attacker_card, 0, 0, ConditionType::CURSE, is_nte ? 0x1F : 0x04, 0xFFFF); } } } @@ -4708,11 +4708,11 @@ void CardSpecial::unknown_8024AAB8(const ActionState& as) { } void CardSpecial::move_phase_before_for_card(shared_ptr card) { - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); ActionState as = this->create_attack_state_from_card_action_chain(card); - this->apply_defense_conditions(as, 0x09, card, is_trial ? 0x1F : 0x04); + this->apply_defense_conditions(as, 0x09, card, is_nte ? 0x1F : 0x04); this->evaluate_and_apply_effects(0x09, card->get_card_ref(), as, 0xFFFF); - if (!is_trial) { + if (!is_nte) { this->apply_defense_conditions(as, 0x27, card, 0x04); this->evaluate_and_apply_effects(0x27, card->get_card_ref(), as, 0xFFFF); } @@ -4722,7 +4722,7 @@ void CardSpecial::dice_phase_before_for_card(shared_ptr card) { auto s = this->server(); auto ps = card->player_state(); - if (s->options.is_trial() && (!ps || !ps->is_team_turn())) { + if (s->options.is_nte() && (!ps || !ps->is_team_turn())) { return; } @@ -4739,7 +4739,7 @@ void CardSpecial::dice_phase_before_for_card(shared_ptr card) { } } - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { this->apply_defense_conditions(as, 0x46, card, 0x04); this->evaluate_and_apply_effects(0x46, card->get_card_ref(), as, sc_card_ref); } @@ -4753,7 +4753,7 @@ template void CardSpecial::apply_effects_on_phase_change_t(shared_ptr unknown_p2, const ActionState* existing_as) { auto s = this->server(); auto log = s->log_stack(string_printf("apply_effects_on_phase_change_t<%02hhX, %02hhX>(@%04hX #%04hX): ", When1, When2, unknown_p2->get_card_ref(), unknown_p2->get_card_id())); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); ActionState as; if (!existing_as) { @@ -4762,12 +4762,12 @@ void CardSpecial::apply_effects_on_phase_change_t(shared_ptr unknown_p2, c as = *existing_as; } - this->apply_defense_conditions(as, When1, unknown_p2, is_trial ? 0x1F : 0x04); + this->apply_defense_conditions(as, When1, unknown_p2, is_nte ? 0x1F : 0x04); for (size_t z = 0; (z < 4 * 9) && (as.target_card_refs[z] != 0xFFFF); z++) { auto card = s->card_for_set_card_ref(as.target_card_refs[z]); if (card) { ActionState target_as = this->create_defense_state_for_card_pair_action_chains(unknown_p2, card); - this->apply_defense_conditions(target_as, When1, card, is_trial ? 0x1F : 0x04); + this->apply_defense_conditions(target_as, When1, card, is_nte ? 0x1F : 0x04); } } auto card = this->sc_card_for_card(unknown_p2); @@ -4799,7 +4799,7 @@ void CardSpecial::action_phase_before_for_card(shared_ptr unknown_p2) { } void CardSpecial::unknown_8024945C(shared_ptr unknown_p2, const ActionState* existing_as) { - this->apply_effects_on_phase_change_t<0x0A, 0x0A>(unknown_p2, this->server()->options.is_trial() ? nullptr : existing_as); + this->apply_effects_on_phase_change_t<0x0A, 0x0A>(unknown_p2, this->server()->options.is_nte() ? nullptr : existing_as); } void CardSpecial::unknown_8024966C(shared_ptr unknown_p2, const ActionState* existing_as) { @@ -4861,7 +4861,7 @@ shared_ptr CardSpecial::sc_card_for_card(shared_ptr unknown_p2) { void CardSpecial::unknown_8024A9D8(const ActionState& pa, uint16_t action_card_ref) { for (size_t z = 0; (z < 8) && (pa.action_card_refs[z] != 0xFFFF); z++) { - if (this->server()->options.is_trial() || (action_card_ref == 0xFFFF) || (action_card_ref == pa.action_card_refs[z])) { + if (this->server()->options.is_nte() || (action_card_ref == 0xFFFF) || (action_card_ref == pa.action_card_refs[z])) { if (pa.original_attacker_card_ref == 0xFFFF) { this->evaluate_and_apply_effects(0x29, pa.action_card_refs[z], pa, pa.attacker_card_ref); this->evaluate_and_apply_effects(0x2A, pa.action_card_refs[z], pa, pa.attacker_card_ref); @@ -4966,7 +4966,7 @@ void CardSpecial::unknown_t2(shared_ptr unknown_p2) { defender_card = sc_card; } - uint8_t apply_defense_conditions_flags = s->options.is_trial() ? 0x1F : 0x04; + uint8_t apply_defense_conditions_flags = s->options.is_nte() ? 0x1F : 0x04; this->apply_defense_conditions(as, When1, unknown_p2, apply_defense_conditions_flags); this->apply_defense_conditions(as, When2, unknown_p2, apply_defense_conditions_flags); if (defender_card) { @@ -5015,14 +5015,14 @@ void CardSpecial::unknown_8024A394(shared_ptr card) { bool CardSpecial::client_has_atk_dice_boost_condition(uint8_t client_id) { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); auto ps = s->get_player_state(client_id); if (ps) { auto card = ps->get_sc_card(); if (card) { for (size_t z = 0; z < 9; z++) { - if ((is_trial || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && + if ((is_nte || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && (card->action_chain.conditions[z].type == ConditionType::ATK_DICE_BOOST)) { return true; } @@ -5032,7 +5032,7 @@ bool CardSpecial::client_has_atk_dice_boost_condition(uint8_t client_id) { auto card = ps->get_set_card(set_index); if (card) { for (size_t z = 0; z < 9; z++) { - if ((is_trial || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && + if ((is_nte || !this->card_ref_has_ability_trap(card->action_chain.conditions[z])) && (card->action_chain.conditions[z].type == ConditionType::ATK_DICE_BOOST)) { return true; } diff --git a/src/Episode3/DataIndexes.cc b/src/Episode3/DataIndexes.cc index d730dcb9..9729d5dc 100644 --- a/src/Episode3/DataIndexes.cc +++ b/src/Episode3/DataIndexes.cc @@ -341,10 +341,10 @@ const char* name_for_direction(Direction d) { } } -bool card_class_is_tech_like(CardClass cc, bool is_trial) { +bool card_class_is_tech_like(CardClass cc, bool is_nte) { // NTE does not consider BOSS_TECH to be a tech-like card class, but that's // probably because that card class just doesn't exist on NTE. - if (is_trial) { + if (is_nte) { return (cc == CardClass::TECH) || (cc == CardClass::PHOTON_BLAST); } else { return (cc == CardClass::TECH) || (cc == CardClass::PHOTON_BLAST) || (cc == CardClass::BOSS_TECH); @@ -2420,8 +2420,8 @@ shared_ptr MapIndex::VersionedMap::trial() const { return this->trial_map; } -const std::string& MapIndex::VersionedMap::compressed(bool is_trial) const { - if (is_trial) { +const std::string& MapIndex::VersionedMap::compressed(bool is_nte) const { + if (is_nte) { if (this->compressed_trial_data.empty()) { auto md = this->trial(); this->compressed_trial_data = prs_compress(md.get(), sizeof(*md)); diff --git a/src/Episode3/DataIndexes.hh b/src/Episode3/DataIndexes.hh index ac7c20e2..6c841429 100644 --- a/src/Episode3/DataIndexes.hh +++ b/src/Episode3/DataIndexes.hh @@ -164,7 +164,7 @@ enum class CardClass : uint16_t { }; const char* name_for_card_class(CardClass cc); -bool card_class_is_tech_like(CardClass cc, bool is_trial); +bool card_class_is_tech_like(CardClass cc, bool is_nte); enum class TargetMode : uint8_t { NONE = 0x00, // Used for defense cards, mags, shields, etc. @@ -1486,7 +1486,7 @@ public: VersionedMap(std::string&& compressed_data, uint8_t language); std::shared_ptr trial() const; - const std::string& compressed(bool is_trial) const; + const std::string& compressed(bool is_nte) const; private: mutable std::shared_ptr trial_map; diff --git a/src/Episode3/DeckState.cc b/src/Episode3/DeckState.cc index 5fcd9e75..b931522c 100644 --- a/src/Episode3/DeckState.cc +++ b/src/Episode3/DeckState.cc @@ -183,7 +183,7 @@ void DeckState::restart() { this->shuffle(); } -void DeckState::do_mulligan(bool is_trial) { +void DeckState::do_mulligan(bool is_nte) { for (size_t z = 0; z < this->entries.size(); z++) { if (this->entries[z].state == CardState::DISCARDED) { this->entries[z].state = CardState::DRAWABLE; @@ -191,7 +191,7 @@ void DeckState::do_mulligan(bool is_trial) { } this->draw_index = 1; - if (is_trial || this->shuffle_enabled) { + if (is_nte || this->shuffle_enabled) { // Get the next 5 cards from the deck, and put the previous 5 cards after // them (so they will be shuffled back in). for (uint8_t z = 0; z < 5; z++) { diff --git a/src/Episode3/DeckState.hh b/src/Episode3/DeckState.hh index ac0b9bfb..5f1b780f 100644 --- a/src/Episode3/DeckState.hh +++ b/src/Episode3/DeckState.hh @@ -94,7 +94,7 @@ public: void restart(); void shuffle(); - void do_mulligan(bool is_trial); + void do_mulligan(bool is_nte); void print(FILE* stream, std::shared_ptr card_index = nullptr) const; diff --git a/src/Episode3/PlayerState.cc b/src/Episode3/PlayerState.cc index 35ec8b8b..5af59723 100644 --- a/src/Episode3/PlayerState.cc +++ b/src/Episode3/PlayerState.cc @@ -91,7 +91,7 @@ void PlayerState::init() { this->sc_card = make_shared(this->deck_state->sc_card_id(), this->sc_card_ref, this->client_id, s); this->sc_card->init(); this->draw_initial_hand(); - if (s->options.is_trial()) { + if (s->options.is_nte()) { this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); this->send_set_card_updates(true); } @@ -156,7 +156,7 @@ void PlayerState::apply_assist_card_effect_on_set( assist_card_id = s->card_id_for_card_ref(this->card_refs[6]); } - auto assist_effect = assist_effect_number_for_card_id(assist_card_id, s->options.is_trial()); + auto assist_effect = assist_effect_number_for_card_id(assist_card_id, s->options.is_nte()); if ((assist_effect == AssistEffect::RESISTANCE) || (assist_effect == AssistEffect::INDEPENDENT)) { this->assist_card_set_number = 0; @@ -176,7 +176,7 @@ void PlayerState::apply_assist_card_effect_on_set( } if (hand_index < 6) { - if (s->options.is_trial()) { + if (s->options.is_nte()) { if (this->deck_state->draw_card_by_ref(this->discard_log_card_refs[0])) { this->pop_from_discard_log(0); } @@ -208,7 +208,7 @@ void PlayerState::apply_assist_card_effect_on_set( case AssistEffect::SKIP_SET: case AssistEffect::SKIP_ACT: - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { this->assist_delay_turns = 2; } break; @@ -253,13 +253,13 @@ void PlayerState::apply_assist_card_effect_on_set( } } - bool is_trial = s->options.is_trial(); - if (!is_trial) { + bool is_nte = s->options.is_nte(); + if (!is_nte) { this->on_cards_destroyed(); } this->atk_points = min(9, this->atk_points + (total_cost >> 1)); this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); - if (!is_trial) { + if (!is_nte) { s->send_6xB4x05(); } break; @@ -320,7 +320,7 @@ void PlayerState::apply_assist_card_effect_on_set( s->update_battle_state_flags_and_send_6xB4x03_if_needed(); this->num_destroyed_fcs = 0; - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { s->team_num_cards_destroyed[this->team_id] = 0; for (size_t client_id = 0; client_id < 4; client_id++) { const auto other_ps = s->get_player_state(client_id); @@ -343,20 +343,20 @@ void PlayerState::apply_assist_card_effect_on_set( break; case AssistEffect::SLOW_TIME: { - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); for (size_t client_id = 0; client_id < 4; client_id++) { auto other_ps = s->get_player_state(client_id); if (!other_ps) { continue; } - if (is_trial + if (is_nte ? (other_ps->assist_remaining_turns != 90 && other_ps->assist_remaining_turns != 99) : (other_ps->assist_remaining_turns < 10)) { other_ps->assist_remaining_turns = min(9, other_ps->assist_remaining_turns << 1); } - for (ssize_t set_index = is_trial ? 0 : -1; set_index < 8; set_index++) { + for (ssize_t set_index = is_nte ? 0 : -1; set_index < 8; set_index++) { auto card = (set_index == -1) ? other_ps->get_sc_card() : other_ps->get_set_card(set_index); @@ -366,7 +366,7 @@ void PlayerState::apply_assist_card_effect_on_set( if (cond.type == ConditionType::NONE) { continue; } - if (is_trial) { + if (is_nte) { if (cond.remaining_turns < 49) { cond.remaining_turns <<= 1; } @@ -376,7 +376,7 @@ void PlayerState::apply_assist_card_effect_on_set( } } } - if (!is_trial) { + if (!is_nte) { other_ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); other_ps->send_set_card_updates(); } @@ -385,33 +385,33 @@ void PlayerState::apply_assist_card_effect_on_set( } case AssistEffect::QUICK_TIME: { - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); for (size_t client_id = 0; client_id < 4; client_id++) { auto other_ps = s->get_player_state(client_id); if (!other_ps) { continue; } - if (is_trial + if (is_nte ? (other_ps->assist_remaining_turns != 90 && other_ps->assist_remaining_turns != 99) : (other_ps->assist_remaining_turns < 10)) { other_ps->assist_remaining_turns = ((other_ps->assist_remaining_turns + 1) >> 1); } - for (ssize_t set_index = is_trial ? 0 : -1; set_index < 8; set_index++) { + for (ssize_t set_index = is_nte ? 0 : -1; set_index < 8; set_index++) { auto card = (set_index == -1) ? other_ps->get_sc_card() : other_ps->get_set_card(set_index); if (card) { for (size_t cond_index = 0; cond_index < 9; cond_index++) { auto& cond = card->action_chain.conditions[cond_index]; - if ((cond.type != ConditionType::NONE) && (cond.remaining_turns < (is_trial ? 99 : 10))) { + if ((cond.type != ConditionType::NONE) && (cond.remaining_turns < (is_nte ? 99 : 10))) { cond.remaining_turns = (cond.remaining_turns + 1) >> 1; } } } } - if (!is_trial) { + if (!is_nte) { other_ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); other_ps->send_set_card_updates(); } @@ -428,7 +428,7 @@ void PlayerState::apply_assist_card_effect_on_set( break; case AssistEffect::SKIP_TURN: - if (!s->options.is_trial() && (!setter_ps || (setter_ps->team_id == this->team_id))) { + if (!s->options.is_nte() && (!setter_ps || (setter_ps->team_id == this->team_id))) { this->assist_delay_turns = 6; } else { this->assist_delay_turns = 5; @@ -450,7 +450,7 @@ void PlayerState::apply_dice_effects() { case AssistEffect::DICE_FEVER: for (size_t die_index = 0; die_index < 2; die_index++) { if (this->dice_results[die_index] > 0) { - this->dice_results[die_index] = s->options.is_trial() ? 6 : 5; + this->dice_results[die_index] = s->options.is_nte() ? 6 : 5; } } break; @@ -469,7 +469,7 @@ void PlayerState::apply_dice_effects() { } break; case AssistEffect::DICE_FEVER_PLUS: - if (s->options.is_trial()) { + if (s->options.is_nte()) { break; } for (size_t die_index = 0; die_index < 2; die_index++) { @@ -607,7 +607,7 @@ void PlayerState::discard_and_redraw_hand() { this->discard_ref_from_hand(this->card_refs[0]); } - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { G_Unknown_Ep3_6xB4x2C cmd; cmd.change_type = 3; cmd.client_id = this->client_id; @@ -631,7 +631,7 @@ bool PlayerState::discard_card_or_add_to_draw_pile(uint16_t card_ref, bool add_t this->card_refs[set_index + 8] = 0xFFFF; auto card = this->set_cards[set_index]; if (card) { - if (this->server()->options.is_trial()) { + if (this->server()->options.is_nte()) { card->update_stats_on_destruction(); this->set_cards[set_index].reset(); } else { @@ -711,7 +711,7 @@ bool PlayerState::do_mulligan() { this->discard_ref_from_hand(this->card_refs[0]); } - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { G_Unknown_Ep3_6xB4x2C cmd; cmd.change_type = 3; cmd.client_id = this->client_id; @@ -720,10 +720,10 @@ bool PlayerState::do_mulligan() { s->send(cmd); } - this->deck_state->do_mulligan(s->options.is_trial()); + this->deck_state->do_mulligan(s->options.is_nte()); this->draw_hand(5); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { this->discard_log_card_refs.clear(0xFFFF); } return true; @@ -736,7 +736,7 @@ void PlayerState::draw_hand(ssize_t override_count) { size_t num_assists = s->assist_server->compute_num_assist_effects_for_client(this->client_id); for (size_t z = 0; z < num_assists; z++) { auto eff = s->assist_server->get_active_assist_by_index(z); - if ((eff == AssistEffect::RICH_PLUS) && !s->options.is_trial()) { + if ((eff == AssistEffect::RICH_PLUS) && !s->options.is_nte()) { count = 4 - this->get_hand_size(); } else if (eff == AssistEffect::RICH) { count = 6 - this->get_hand_size(); @@ -755,7 +755,7 @@ void PlayerState::draw_hand(ssize_t override_count) { break; } } - if (!s->options.is_trial() && (s->get_setup_phase() == SetupPhase::MAIN_BATTLE)) { + if (!s->options.is_nte() && (s->get_setup_phase() == SetupPhase::MAIN_BATTLE)) { this->stats.num_cards_drawn++; } } @@ -1095,18 +1095,18 @@ void PlayerState::on_cards_destroyed() { void PlayerState::replace_all_set_assists_with_random_assists() { auto s = this->server(); - bool is_trial = s->options.is_trial(); - const auto& assist_card_ids = all_assist_card_ids(is_trial); + bool is_nte = s->options.is_nte(); + const auto& assist_card_ids = all_assist_card_ids(is_nte); for (size_t client_id = 0; client_id < 4; client_id++) { auto other_ps = s->get_player_state(client_id); if (other_ps && - ((other_ps->card_refs[6] != 0xFFFF) || (!is_trial && (other_ps->set_assist_card_id != 0xFFFF)))) { + ((other_ps->card_refs[6] != 0xFFFF) || (!is_nte && (other_ps->set_assist_card_id != 0xFFFF)))) { uint16_t card_id = 0x0130; while (card_id == 0x0130) { // God Whim size_t index = s->get_random(assist_card_ids.size()); card_id = assist_card_ids[index]; // In NTE, God Whim can use ANY card, even unobtainable cards. - if (!is_trial && !this->god_whim_can_use_hidden_cards) { + if (!is_nte && !this->god_whim_can_use_hidden_cards) { auto ce = s->definition_for_card_id(card_id); if (!ce || ce->def.cannot_drop) { continue; @@ -1133,7 +1133,7 @@ bool PlayerState::replace_assist_card_by_id(uint16_t card_id) { this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); s->assist_server->populate_effects(); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { for (size_t client_id = 0; client_id < 4; client_id++) { auto other_ps = s->get_player_state(client_id); if (other_ps) { @@ -1193,7 +1193,7 @@ bool PlayerState::return_set_card_to_hand1(uint16_t card_ref) { if (card && (card->get_card_ref() == card_ref)) { uint16_t set_card_ref = this->card_refs[set_index + 8]; this->card_refs[set_index + 8] = 0xFFFF; - if (this->server()->options.is_trial()) { + if (this->server()->options.is_nte()) { card->update_stats_on_destruction(); this->set_cards[set_index].reset(); } else { @@ -1238,12 +1238,12 @@ uint8_t PlayerState::roll_dice_with_effects(size_t num_dice) { void PlayerState::send_set_card_updates(bool always_send) { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); uint16_t mask = 0; if (this->sc_card) { this->sc_card->send_6xB4x4E_4C_4D_if_needed(always_send); - } else if (is_trial) { + } else if (is_nte) { this->send_6xB4x0A_for_set_card(0); } else { this->set_card_action_chains->at(0).clear(); @@ -1255,7 +1255,7 @@ void PlayerState::send_set_card_updates(bool always_send) { auto card = this->set_cards[set_index]; if (card) { card->send_6xB4x4E_4C_4D_if_needed(always_send); - } else if (is_trial) { + } else if (is_nte) { this->send_6xB4x0A_for_set_card(set_index + 1); } else { mask |= 1 << (set_index + 1); @@ -1264,7 +1264,7 @@ void PlayerState::send_set_card_updates(bool always_send) { } } - // mask will always be 0 here if is_trial is true + // mask will always be 0 here if is_nte is true if (mask && !s->get_should_copy_prev_states_to_current_states()) { G_ClearSetCardConditions_Ep3_6xB4x4F cmd; cmd.client_id = this->client_id; @@ -1341,7 +1341,7 @@ bool PlayerState::set_card_from_hand( this->deck_state->set_card_ref_in_play(card_ref); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); auto ce = s->definition_for_card_ref(card_ref); if (ce->def.type == CardType::ITEM || ce->def.type == CardType::CREATURE) { if ((card_index < 7) || (card_index >= 15)) { @@ -1379,7 +1379,7 @@ bool PlayerState::set_card_from_hand( target_ps->assist_card_set_number = s->next_assist_card_set_number++; this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); - if (!is_trial) { + if (!is_nte) { target_ps->apply_assist_card_effect_on_set(this->shared_from_this()); } target_ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); @@ -1396,7 +1396,7 @@ bool PlayerState::set_card_from_hand( other_ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); } } - if (is_trial) { + if (is_nte) { target_ps->apply_assist_card_effect_on_set(this->shared_from_this()); } } @@ -1408,13 +1408,13 @@ bool PlayerState::set_card_from_hand( this->compute_total_set_cards_cost(); s->card_special->on_card_set(this->shared_from_this(), card_ref); - if (!is_trial && (ce->def.type == CardType::ASSIST)) { + if (!is_nte && (ce->def.type == CardType::ASSIST)) { s->check_for_destroyed_cards_and_send_6xB4x05_6xB4x02(); } this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); s->send_6xB4x05(); - if (!is_trial) { + if (!is_nte) { G_Unknown_Ep3_6xB4x4A cmd; cmd.card_refs.clear(0xFFFF); cmd.card_refs[0] = card_ref; @@ -1596,14 +1596,14 @@ void PlayerState::update_hand_and_equip_state_and_send_6xB4x02_if_needed( void PlayerState::set_random_assist_card_from_hand_for_free() { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); vector candidate_card_refs; for (size_t hand_index = 0; hand_index < 6; hand_index++) { uint16_t card_ref = this->card_refs[hand_index]; auto ce = s->definition_for_card_ref(card_ref); if (ce && (ce->def.type == CardType::ASSIST) && - (assist_effect_number_for_card_id(ce->def.card_id, is_trial) != AssistEffect::SQUEEZE)) { + (assist_effect_number_for_card_id(ce->def.card_id, is_nte) != AssistEffect::SQUEEZE)) { candidate_card_refs.emplace_back(card_ref); } } @@ -1660,7 +1660,7 @@ void PlayerState::send_6xB4x04_if_needed(bool always_send) { if (always_send || (cmd.card_statuses != *this->card_short_statuses)) { auto s = this->server(); *this->card_short_statuses = cmd.card_statuses; - if (s->options.is_trial() || !s->get_should_copy_prev_states_to_current_states()) { + if (s->options.is_nte() || !s->get_should_copy_prev_states_to_current_states()) { s->send(cmd); } } @@ -1754,7 +1754,7 @@ int16_t PlayerState::get_assist_turns_remaining() { bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { auto s = this->server(); - bool is_trial = s->options.is_trial(); + bool is_nte = s->options.is_nte(); auto attacker_card = s->card_for_set_card_ref(pa.attacker_card_ref); if (attacker_card) { @@ -1762,7 +1762,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { } auto action_type = s->ruler_server->get_pending_action_type(pa); - if (!is_trial) { + if (!is_nte) { this->subtract_or_check_atk_or_def_points_for_action(pa, 1); } @@ -1780,7 +1780,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { do { card->unknown_80237A90(pa, pa.action_card_refs[z]); card->unknown_802379BC(pa.action_card_refs[z]); - if (!is_trial) { + if (!is_nte) { if (pa.action_card_refs[z] != 0xFFFF) { cmd.card_refs[z] = pa.action_card_refs[z]; cmd.entry_count++; @@ -1788,7 +1788,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { auto ce = s->definition_for_card_ref(pa.action_card_refs[z]); if (ce) { auto card_class = ce->def.card_class(); - if (card_class_is_tech_like(card_class, is_trial)) { + if (card_class_is_tech_like(card_class, is_nte)) { this->stats.num_tech_cards_set++; } if ((card_class == CardClass::ATTACK_ACTION) || @@ -1812,7 +1812,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { auto target_card = s->card_for_set_card_ref(pa.target_card_refs[z]); if (target_card) { target_card->unknown_802379DC(pa); - if (!is_trial) { + if (!is_nte) { if (this->client_id == target_card->get_client_id()) { this->stats.defense_actions_set_on_self++; } else { @@ -1822,7 +1822,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { } } } - if (!is_trial) { + if (!is_nte) { G_Unknown_Ep3_6xB4x4A cmd; cmd.card_refs.clear(0xFFFF); cmd.client_id = this->client_id; @@ -1832,7 +1832,7 @@ bool PlayerState::set_action_cards_for_action_state(const ActionState& pa) { s->send(cmd); } } - if (is_trial) { + if (is_nte) { this->subtract_or_check_atk_or_def_points_for_action(pa, 1); } for (size_t z = 0; (z < pa.action_card_refs.size()) && (pa.action_card_refs[z] != 0xFFFF); z++) { @@ -1872,7 +1872,7 @@ void PlayerState::dice_phase_before() { this->assist_flags &= (AssistFlag::HAS_WON_BATTLE | AssistFlag::WINNER_DECIDED_BY_DEFEAT | AssistFlag::WINNER_DECIDED_BY_RANDOM | - (this->server()->options.is_trial() ? AssistFlag::NONE : AssistFlag::ELIGIBLE_FOR_DICE_BOOST)); + (this->server()->options.is_nte() ? AssistFlag::NONE : AssistFlag::ELIGIBLE_FOR_DICE_BOOST)); this->set_assist_flags_from_assist_effects(); this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(0); this->send_set_card_updates(); @@ -1900,7 +1900,7 @@ void PlayerState::handle_homesick_assist_effect_from_bomb(shared_ptr card) this->return_set_card_to_hand2(card_ref); this->log_discard(card_ref, 1); // On NTE, the card is destroyed immediately - if (s->options.is_trial()) { + if (s->options.is_nte()) { this->set_cards[set_index]->update_stats_on_destruction(); this->set_cards[set_index].reset(); } else { @@ -1913,7 +1913,7 @@ void PlayerState::handle_homesick_assist_effect_from_bomb(shared_ptr card) if (this->deck_state->set_card_ref_drawable_next(card_ref)) { this->log_discard(card_ref, 1); // On NTE, the card is destroyed immediately - if (s->options.is_trial()) { + if (s->options.is_nte()) { this->set_cards[set_index]->update_stats_on_destruction(); this->set_cards[set_index].reset(); } else { @@ -1930,7 +1930,7 @@ void PlayerState::apply_main_die_assist_effects(uint8_t* die_value) const { for (size_t z = 0; z < num_assists; z++) { switch (s->assist_server->get_active_assist_by_index(z)) { case AssistEffect::DICE_FEVER: - *die_value = s->options.is_trial() ? 6 : 5; + *die_value = s->options.is_nte() ? 6 : 5; break; case AssistEffect::DICE_HALF: *die_value = ((*die_value + 1) >> 1); @@ -1939,7 +1939,7 @@ void PlayerState::apply_main_die_assist_effects(uint8_t* die_value) const { (*die_value)++; break; case AssistEffect::DICE_FEVER_PLUS: - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { *die_value = 6; } break; @@ -2027,7 +2027,7 @@ void PlayerState::roll_main_dice_or_apply_after_effects() { this->dice_results[0] = this->atk_points; this->dice_results[1] = this->def_points; - if (s->options.is_trial()) { + if (s->options.is_nte()) { this->atk_bonuses = this->atk_points - atk_before_bonuses; this->def_bonuses = this->def_points - def_before_bonuses; } @@ -2035,7 +2035,7 @@ void PlayerState::roll_main_dice_or_apply_after_effects() { this->def_points += s->team_dice_bonus[this->team_id]; this->atk_points = clamp(this->atk_points, 1, 9); this->def_points = clamp(this->def_points, 1, 9); - if (!s->options.is_trial()) { + if (!s->options.is_nte()) { this->atk_bonuses = this->atk_points - atk_before_bonuses; this->def_bonuses = this->def_points - def_before_bonuses; } @@ -2091,7 +2091,7 @@ void PlayerState::send_6xB4x0A_for_set_card(size_t set_index) { this->set_card_action_chains->at(set_index) = this->unknown_a12; this->set_card_action_metadatas->at(set_index) = this->unknown_a13; - if (s->options.is_trial()) { + if (s->options.is_nte()) { G_UpdateActionChainAndMetadata_Ep3NTE_6xB4x0A cmd; cmd.client_id = this->client_id; cmd.index = set_index; diff --git a/src/Episode3/PlayerStateSubordinates.cc b/src/Episode3/PlayerStateSubordinates.cc index 6c90c395..b3c0bb94 100644 --- a/src/Episode3/PlayerStateSubordinates.cc +++ b/src/Episode3/PlayerStateSubordinates.cc @@ -439,7 +439,7 @@ void ActionChainWithConds::compute_attack_medium(shared_ptr server) { if (!ce) { continue; } - if (card_class_is_tech_like(ce->def.card_class(), server->options.is_trial())) { + if (card_class_is_tech_like(ce->def.card_class(), server->options.is_nte())) { this->chain.attack_medium = AttackMedium::TECH; } } diff --git a/src/Episode3/RulerServer.cc b/src/Episode3/RulerServer.cc index 26958098..98f7f695 100644 --- a/src/Episode3/RulerServer.cc +++ b/src/Episode3/RulerServer.cc @@ -243,8 +243,8 @@ bool RulerServer::card_has_pierce_or_rampage( *out_has_rampage = false; bool ret; - bool is_trial = this->server()->options.is_trial(); - if (is_trial) { + bool is_nte = this->server()->options.is_nte(); + if (is_nte) { ret = true; } else { if (cond_type == ConditionType::NONE) { @@ -292,7 +292,7 @@ bool RulerServer::card_has_pierce_or_rampage( auto ce = this->definition_for_card_ref(sc_status.card_ref); // This appears to be an NTE bug: Major Pierce doesn't work on Arkz SCs. if (ce && - (!is_trial || (ce->def.type == CardType::HUNTERS_SC)) && + (!is_nte || (ce->def.type == CardType::HUNTERS_SC)) && (this->get_card_ref_max_hp(sc_status.card_ref) <= sc_status.current_hp * 2)) { return ret; } @@ -382,10 +382,10 @@ bool RulerServer::attack_action_has_pierce_and_not_rampage(const ActionState& pa return false; } - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); auto attack_medium = this->get_attack_medium(pa); auto stat = this->short_statuses[client_id]; - if (!stat || (!is_trial && !this->card_exists_by_status(stat->at(0))) || (stat->at(0).card_ref == 0xFFFF)) { + if (!stat || (!is_nte && !this->card_exists_by_status(stat->at(0))) || (stat->at(0).card_ref == 0xFFFF)) { return false; } @@ -424,7 +424,7 @@ bool RulerServer::attack_action_has_pierce_and_not_rampage(const ActionState& pa return nullopt; }; - if (is_trial) { + if (is_nte) { auto res = check_chain(); if (res.has_value()) { return res.value(); @@ -457,7 +457,7 @@ bool RulerServer::attack_action_has_pierce_and_not_rampage(const ActionState& pa } } - if (!is_trial) { + if (!is_nte) { auto res = check_chain(); if (res.has_value()) { return res.value(); @@ -663,7 +663,7 @@ bool RulerServer::card_ref_has_free_maneuver(uint16_t card_ref) const { } bool RulerServer::card_ref_is_aerial(uint16_t card_ref) const { - if (!this->server()->options.is_trial()) { + if (!this->server()->options.is_nte()) { const auto* stat = this->short_status_for_card_ref(card_ref); if (!stat || !this->card_exists_by_status(*stat)) { return false; @@ -822,13 +822,13 @@ bool RulerServer::check_pierce_and_rampage( uint16_t action_card_ref, uint8_t def_effect_index, AttackMedium attack_medium) const { - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); // Note: NTE doesn't set this to zero; it apparently expects the caller to. *out_has_pierce = false; const auto* card_short_status = this->short_status_for_card_ref(card_ref); - if (!is_trial && (cond_type == ConditionType::NONE)) { + if (!is_nte && (cond_type == ConditionType::NONE)) { return false; } @@ -850,7 +850,7 @@ bool RulerServer::check_pierce_and_rampage( client_short_statuses = nullptr; } - bool apply_check_result = (is_trial || + bool apply_check_result = (is_nte || this->check_usability_or_apply_condition_for_card_refs( action_card_ref, attacker_card_ref, card_ref, def_effect_index, attack_medium)); @@ -952,7 +952,7 @@ bool RulerServer::check_usability_or_condition_apply( log.debug("ce1 missing"); return false; } - if (!s->options.is_trial() && (ce1->def.type == CardType::ITEM) && this->card_id_is_boss_sc(card_id2)) { + if (!s->options.is_nte() && (ce1->def.type == CardType::ITEM) && this->card_id_is_boss_sc(card_id2)) { log.debug("ce1 is item and card_id2 is boss sc"); return false; } @@ -989,7 +989,7 @@ bool RulerServer::check_usability_or_condition_apply( // second should not be given, so we'd return true if the criterion passes. If // neither of these cases apply, we should return false as a failsafe even if // the criterion passes. NTE did not have such a check. - bool ret = s->options.is_trial() || (!(def_effect_index & 0x80) || (client_id1 == client_id2)) || (client_id2 == 0xFF); + bool ret = s->options.is_nte() || (!(def_effect_index & 0x80) || (client_id1 == client_id2)) || (client_id2 == 0xFF); switch (criterion_code) { case CriterionCode::NONE: return ret; @@ -1397,7 +1397,7 @@ uint16_t RulerServer::compute_attack_or_defense_costs( cost_bias++; } - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); if (pa.action_card_refs[0] == 0xFFFF) { total_cost = cost_bias + 1; } else { @@ -1413,14 +1413,14 @@ uint16_t RulerServer::compute_attack_or_defense_costs( return 99; } total_cost += (ce->def.self_cost + cost_bias); - if (card_class_is_tech_like(ce->def.card_class(), s->options.is_trial())) { + if (card_class_is_tech_like(ce->def.card_class(), s->options.is_nte())) { total_cost += tech_cost_bias; } total_ally_cost += ce->def.ally_cost; if (this->card_has_mighty_knuckle(pa.action_card_refs[z])) { has_mighty_knuckle = true; } - if (!is_trial) { + if (!is_nte) { size_t num_assists = this->assist_server->compute_num_assist_effects_for_client(pa.client_id); for (size_t w = 0; w < num_assists; w++) { auto assist_effect = this->assist_server->get_active_assist_by_index(w); @@ -1437,9 +1437,9 @@ uint16_t RulerServer::compute_attack_or_defense_costs( size_t num_assists = this->assist_server->compute_num_assist_effects_for_client(pa.client_id); for (size_t w = 0; w < num_assists; w++) { auto assist_effect = this->assist_server->get_active_assist_by_index(w); - if (is_trial && (assist_effect == AssistEffect::INFLATION)) { + if (is_nte && (assist_effect == AssistEffect::INFLATION)) { assist_cost_bias++; - } else if (is_trial && (assist_effect == AssistEffect::DEFLATION)) { + } else if (is_nte && (assist_effect == AssistEffect::DEFLATION)) { assist_cost_bias--; } else if ((assist_effect == AssistEffect::BATTLE_ROYALE) && (pa.action_card_refs[0] == 0xFFFF)) { @@ -1450,7 +1450,7 @@ uint16_t RulerServer::compute_attack_or_defense_costs( if (has_mighty_knuckle) { if (!allow_mighty_knuckle) { - if (!is_trial) { + if (!is_nte) { final_cost = 0; } } else { @@ -1495,7 +1495,7 @@ bool RulerServer::compute_effective_range_and_target_mode_for_attack( auto target_mode = ce->def.target_mode; if (this->card_ref_or_sc_has_fixed_range(pa.attacker_card_ref)) { card_id = this->card_id_for_card_ref(pa.attacker_card_ref); - if (!this->server()->options.is_trial()) { + if (!this->server()->options.is_nte()) { auto sc_ce = this->definition_for_card_id(card_id); if (sc_ce && (static_cast(target_mode) < 6)) { target_mode = sc_ce->def.target_mode; @@ -1679,8 +1679,8 @@ int32_t RulerServer::error_code_for_client_setting_card( return -0x76; } - bool is_trial = this->server()->options.is_trial(); - if (!is_trial && !this->is_card_ref_in_hand(card_ref)) { + bool is_nte = this->server()->options.is_nte(); + if (!is_nte && !this->is_card_ref_in_hand(card_ref)) { return -0x5E; } @@ -1720,8 +1720,8 @@ int32_t RulerServer::error_code_for_client_setting_card( } // Check for assists that can only be set on yourself - auto eff = assist_effect_number_for_card_id(ce->def.card_id, is_trial); - if (((eff == AssistEffect::LEGACY) || (!is_trial && (eff == AssistEffect::EXCHANGE))) && + auto eff = assist_effect_number_for_card_id(ce->def.card_id, is_nte); + if (((eff == AssistEffect::LEGACY) || (!is_nte && (eff == AssistEffect::EXCHANGE))) && (assist_target_client_id != 0xFF) && (assist_target_client_id != client_id_for_card_ref(card_ref))) { return -0x75; @@ -1760,7 +1760,7 @@ int32_t RulerServer::error_code_for_client_setting_card( if ((ce->def.type == CardType::ITEM) || (ce->def.type == CardType::CREATURE)) { int16_t existing_fcs_cost = 0; - bool limit_summoning_by_count = !is_trial && + bool limit_summoning_by_count = !is_nte && this->find_condition_on_card_ref(short_statuses->at(0).card_ref, ConditionType::FC_LIMIT_BY_COUNT); for (size_t z = 7; z < 15; z++) { const auto& this_status = short_statuses->at(z); @@ -1800,7 +1800,7 @@ int32_t RulerServer::error_code_for_client_setting_card( return 0; } - if (is_trial) { + if (is_nte) { // It seems NTE assumes that teams always start on the same ends of the // map; non-NTE removes this restriction. if (team_id == 1) { @@ -2088,7 +2088,7 @@ uint8_t RulerServer::get_card_ref_max_hp(uint16_t card_ref) const { return 0; } else if (((ce->def.type == CardType::HUNTERS_SC) || (ce->def.type == CardType::ARKZ_SC)) && (this->map_and_rules->rules.char_hp > 0) && - (this->server()->options.is_trial() || !this->card_ref_is_boss_sc(card_ref))) { + (this->server()->options.is_nte() || !this->card_ref_is_boss_sc(card_ref))) { return this->map_and_rules->rules.char_hp; } else { return ce->def.hp.stat; @@ -2237,7 +2237,7 @@ bool RulerServer::is_attack_valid(const ActionState& pa) { return false; } - if (!this->server()->options.is_trial() && (attacker_card_status->card_flags & 2)) { + if (!this->server()->options.is_nte() && (attacker_card_status->card_flags & 2)) { this->error_code3 = -0x60; return false; } @@ -2354,8 +2354,8 @@ bool RulerServer::is_attack_or_defense_valid(const ActionState& pa) { } // NTE apparently does not check the action's cost here - bool is_trial = this->server()->options.is_trial(); - int16_t cost = is_trial ? 0 : this->compute_attack_or_defense_costs(pa, false, nullptr); + bool is_nte = this->server()->options.is_nte(); + int16_t cost = is_nte ? 0 : this->compute_attack_or_defense_costs(pa, false, nullptr); switch (this->get_pending_action_type(pa)) { case ActionType::ATTACK: @@ -2451,7 +2451,7 @@ bool RulerServer::is_defense_valid(const ActionState& pa) { } } - if (!this->server()->options.is_trial() && + if (!this->server()->options.is_nte() && (this->find_condition_on_card_ref(pa.target_card_refs[0], ConditionType::HOLD) || this->find_condition_on_card_ref(pa.target_card_refs[0], ConditionType::CANNOT_DEFEND))) { this->error_code3 = -0x63; @@ -2482,7 +2482,7 @@ size_t RulerServer::max_move_distance_for_card_ref(uint32_t card_ref) const { return 0; } - if (this->server()->options.is_trial()) { + if (this->server()->options.is_nte()) { if (ce->def.type == CardType::ITEM) { return ce->def.mv.stat; } @@ -2612,14 +2612,14 @@ void RulerServer::replace_D1_D2_rank_cards_with_Attack( } AttackMedium RulerServer::get_attack_medium(const ActionState& pa) const { - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); for (size_t z = 0; z < 8; z++) { uint16_t card_ref = pa.action_card_refs[z]; if (card_ref == 0xFFFF) { return AttackMedium::PHYSICAL; } auto ce = this->definition_for_card_ref(card_ref); - if (ce && card_class_is_tech_like(ce->def.card_class(), is_trial)) { + if (ce && card_class_is_tech_like(ce->def.card_class(), is_nte)) { return AttackMedium::TECH; } } @@ -2640,10 +2640,10 @@ int32_t RulerServer::set_cost_for_card(uint8_t client_id, uint16_t card_ref) con return -0x7D; } - bool is_trial = this->server()->options.is_trial(); + bool is_nte = this->server()->options.is_nte(); auto short_statuses = this->short_statuses[client_id]; int32_t ret = ce->def.self_cost; - if (!is_trial && + if (!is_nte && short_statuses && this->card_exists_by_status(short_statuses->at(0)) && this->find_condition_on_card_ref(short_statuses->at(0).card_ref, ConditionType::UNKNOWN_69)) { @@ -2678,7 +2678,7 @@ int32_t RulerServer::set_cost_for_card(uint8_t client_id, uint16_t card_ref) con auto eff = this->assist_server->get_active_assist_by_index(z); if (eff == AssistEffect::LAND_PRICE) { // In NTE, Land Price is apparently 2x rather than 1.5x - ret = is_trial ? (ret << 1) : (ret + (ret >> 1)); + ret = is_nte ? (ret << 1) : (ret + (ret >> 1)); } else if (eff == AssistEffect::DEFLATION) { ret = max(0, ret - 1); } else if (eff == AssistEffect::INFLATION) { diff --git a/src/Episode3/Server.cc b/src/Episode3/Server.cc index d6fcabad..91a423ea 100644 --- a/src/Episode3/Server.cc +++ b/src/Episode3/Server.cc @@ -205,7 +205,7 @@ void Server::send(const void* data, size_t size, uint8_t command, bool enable_ma string masked_data; if (enable_masking && - !this->options.is_trial() && + !this->options.is_nte() && !(this->options.behavior_flags & BehaviorFlag::DISABLE_MASKING) && (size >= 8)) { masked_data.assign(reinterpret_cast(data), size); @@ -235,7 +235,7 @@ void Server::send(const void* data, size_t size, uint8_t command, bool enable_ma void Server::send_6xB4x46() const { // Note: This function is not part of the original implementation; it was // factored out from its callsites in this file and the strings were changed. - if (this->options.is_trial()) { + if (this->options.is_nte()) { G_ServerVersionStrings_Ep3NTE_6xB4x46 cmd; cmd.version_signature.encode(VERSION_SIGNATURE_NTE, 1); cmd.date_str1.encode(format_time(this->options.card_index->definitions_mtime() * 1000000), 1); @@ -256,10 +256,10 @@ void Server::send_6xB4x46() const { } } -string Server::prepare_6xB6x41_map_definition(shared_ptr map, uint8_t language, bool is_trial) { +string Server::prepare_6xB6x41_map_definition(shared_ptr map, uint8_t language, bool is_nte) { auto vm = map->version(language); - const auto& compressed = vm->compressed(is_trial); + const auto& compressed = vm->compressed(is_nte); StringWriter w; uint32_t subcommand_size = (compressed.size() + sizeof(G_MapData_Ep3_6xB6x41) + 3) & (~3); @@ -280,7 +280,7 @@ void Server::send_commands_for_joining_spectator(Channel& ch) const { } if (this->last_chosen_map) { - string data = this->prepare_6xB6x41_map_definition(this->last_chosen_map, ch.language, this->options.is_trial()); + string data = this->prepare_6xB6x41_map_definition(this->last_chosen_map, ch.language, this->options.is_nte()); this->log().info("Sending %c version of map %08" PRIX32, char_for_language_code(ch.language), this->last_chosen_map->map_number); ch.send(0x6C, 0x00, data); } @@ -516,7 +516,7 @@ bool Server::check_for_battle_end() { } } - if (this->options.is_trial()) { + if (this->options.is_nte()) { if (teams_defeated[0] || teams_defeated[1]) { ret = true; for (size_t client_id = 0; client_id < 4; client_id++) { @@ -548,7 +548,7 @@ bool Server::check_for_battle_end() { } else { // Not DEFEAT_TEAM - if (this->options.is_trial()) { + if (this->options.is_nte()) { uint8_t loser_team_id = 0; for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; @@ -738,7 +738,7 @@ void Server::destroy_cards_with_zero_hp() { for (ssize_t set_index = -1; set_index < 8; set_index++) { auto card = (set_index < 0) ? ps->get_sc_card() : ps->get_set_card(set_index); if (card && !(card->card_flags & 2) && (card->get_current_hp() < 1)) { - card->destroy_set_card(this->options.is_trial() ? nullptr : card->w_destroyer_sc_card.lock()); + card->destroy_set_card(this->options.is_nte() ? nullptr : card->w_destroyer_sc_card.lock()); any_card_destroyed = true; } } @@ -784,7 +784,7 @@ void Server::dice_phase_after() { size_t num_assists = this->assist_server->compute_num_assist_effects_for_client(client_id); for (size_t z = 0; z < num_assists; z++) { auto eff = this->assist_server->get_active_assist_by_index(z); - if ((eff == AssistEffect::CHARITY) || (!this->options.is_trial() && (eff == AssistEffect::CHARITY_PLUS))) { + if ((eff == AssistEffect::CHARITY) || (!this->options.is_nte() && (eff == AssistEffect::CHARITY_PLUS))) { int16_t exp_delta = (eff == AssistEffect::CHARITY_PLUS) ? -1 : 1; for (size_t other_client_id = 0; other_client_id < 4; other_client_id++) { auto other_ps = this->player_states[other_client_id]; @@ -843,7 +843,7 @@ void Server::draw_phase_after() { } // Apparently the hard limit of 1000 was added after NTE was released - if (this->overall_time_expired || (!this->options.is_trial() && (this->round_num >= 1000))) { + if (this->overall_time_expired || (!this->options.is_nte() && (this->round_num >= 1000))) { bool no_winner_specified = true; for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; @@ -934,7 +934,7 @@ void Server::end_action_phase() { // that this can only ever be 0 or 2, but we may have to delete the enum if // that turns out to be false. this->action_subphase = static_cast(static_cast(this->action_subphase) + 2); - if (this->options.is_trial()) { + if (this->options.is_nte()) { this->unknown_8023EEF4(); this->update_battle_state_flags_and_send_6xB4x03_if_needed(0); this->send_6xB4x02_for_all_players_if_needed(); @@ -1059,7 +1059,7 @@ bool Server::is_registration_complete() const { } void Server::move_phase_after() { - if (!this->options.is_trial()) { + if (!this->options.is_nte()) { for (size_t trap_type = 0; trap_type < 5; trap_type++) { uint8_t trap_tile_index = this->chosen_trap_tile_index_of_type[trap_type]; if (trap_tile_index == 0xFF) { @@ -1264,7 +1264,7 @@ G_UpdateDecks_Ep3_6xB4x07 Server::prepare_6xB4x07_decks_update() const { void Server::send_all_state_updates() { this->send(this->prepare_6xB4x07_decks_update()); - if (this->options.is_trial()) { + if (this->options.is_nte()) { G_UpdateMap_Ep3NTE_6xB4x05 cmd; cmd.state = *this->map_and_rules; this->send(cmd); @@ -1323,19 +1323,19 @@ void Server::set_client_id_ready_to_advance_phase(uint8_t client_id, BattlePhase return; } - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); auto ps = this->player_states[client_id]; if (ps && (this->current_team_turn1 == ps->get_team_id()) && - (!is_trial || (this->battle_phase == battle_phase)) && + (!is_nte || (this->battle_phase == battle_phase)) && (this->setup_phase == SetupPhase::MAIN_BATTLE)) { ps->assist_flags |= AssistFlag::READY_TO_END_PHASE; ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); if (this->battle_phase == BattlePhase::DICE) { - if (is_trial || !(ps->assist_flags & AssistFlag::ELIGIBLE_FOR_DICE_BOOST) || this->map_and_rules->rules.disable_dice_boost) { + if (is_nte || !(ps->assist_flags & AssistFlag::ELIGIBLE_FOR_DICE_BOOST) || this->map_and_rules->rules.disable_dice_boost) { ps->assist_flags &= (~AssistFlag::ELIGIBLE_FOR_DICE_BOOST); ps->roll_main_dice_or_apply_after_effects(); - if (!is_trial && (ps->get_atk_points() < 3) && (ps->get_def_points() < 3)) { + if (!is_nte && (ps->get_atk_points() < 3) && (ps->get_def_points() < 3)) { ps->assist_flags |= AssistFlag::ELIGIBLE_FOR_DICE_BOOST; } } else { @@ -1372,11 +1372,11 @@ void Server::set_client_id_ready_to_advance_phase(uint8_t client_id, BattlePhase } if (should_advance_phase) { - if (!this->options.is_trial()) { + if (!this->options.is_nte()) { this->copy_player_states_to_prev_states(); } this->advance_battle_phase(); - if (!this->options.is_trial()) { + if (!this->options.is_nte()) { this->send_set_card_updates_and_6xB4x04_if_needed(); } this->clear_player_flags_after_dice_phase(); @@ -1387,19 +1387,19 @@ void Server::set_client_id_ready_to_advance_phase(uint8_t client_id, BattlePhase } void Server::set_phase_after() { - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); for (size_t client_id = 0; client_id < 4; client_id++) { auto ps = this->player_states[client_id]; if (ps) { auto card = ps->get_sc_card(); if (card) { - this->card_special->apply_action_conditions(0x06, nullptr, card, is_trial ? 0x1F : 0x04, nullptr); + this->card_special->apply_action_conditions(0x06, nullptr, card, is_nte ? 0x1F : 0x04, nullptr); } for (size_t set_index = 0; set_index < 8; set_index++) { auto card = ps->get_set_card(set_index); if (card) { - this->card_special->apply_action_conditions(0x06, nullptr, card, is_trial ? 0x1F : 0x04, nullptr); + this->card_special->apply_action_conditions(0x06, nullptr, card, is_nte ? 0x1F : 0x04, nullptr); } } } @@ -1418,7 +1418,7 @@ void Server::set_phase_after() { switch (this->assist_server->get_active_assist_by_index(z)) { case AssistEffect::SHUFFLE_ALL: case AssistEffect::SHUFFLE_GROUP: - if (is_trial || + if (is_nte || (!this->map_and_rules->rules.disable_deck_shuffle && !this->map_and_rules->rules.disable_deck_loop)) { ps->discard_and_redraw_hand(); } @@ -1436,7 +1436,7 @@ void Server::set_phase_after() { ps->discard_all_assist_cards_from_hand(); break; case AssistEffect::ASSIST_VANISH: - if (!is_trial) { + if (!is_nte) { clients_with_assist_vanish[client_id] = true; } else if (ps->get_assist_turns_remaining() != 90) { ps->discard_set_assist_card(); @@ -1482,7 +1482,7 @@ void Server::set_player_deck_valid(uint8_t client_id) { } void Server::setup_and_start_battle() { - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); this->setup_phase = SetupPhase::STARTER_ROLLS; @@ -1491,7 +1491,7 @@ void Server::setup_and_start_battle() { for (size_t z = 0; z < 4; z++) { if (!this->check_presence_entry(z)) { - if (!is_trial) { + if (!is_nte) { this->name_entries[z].clear(); } } else { @@ -1500,7 +1500,7 @@ void Server::setup_and_start_battle() { } } - if (!is_trial && (this->map_and_rules->rules.hp_type == HPType::COMMON_HP)) { + if (!is_nte && (this->map_and_rules->rules.hp_type == HPType::COMMON_HP)) { int16_t team_hp[2] = {99, 99}; for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; @@ -1578,7 +1578,7 @@ void Server::setup_and_start_battle() { } } else if ((tile_type == 0x10) || (tile_type == 0x20) || (tile_type == 0x50)) { this->map_and_rules->map.tiles[y][x] = 0; - } else if (is_trial && (tile_type == 0x40) && (this->num_trap_tiles_nte < 0x10)) { + } else if (is_nte && (tile_type == 0x40) && (this->num_trap_tiles_nte < 0x10)) { this->trap_tile_locs_nte[this->num_trap_tiles_nte][0] = x; this->trap_tile_locs_nte[this->num_trap_tiles_nte][1] = y; this->num_trap_tiles_nte++; @@ -1586,7 +1586,7 @@ void Server::setup_and_start_battle() { } } - if (!is_trial) { + if (!is_nte) { for (size_t trap_type = 0; trap_type < 5; trap_type++) { this->chosen_trap_tile_index_of_type[trap_type] = 0xFF; @@ -1609,7 +1609,7 @@ void Server::setup_and_start_battle() { } } - if (is_trial) { + if (is_nte) { this->send_all_state_updates(); this->send_6xB4x02_for_all_players_if_needed(); @@ -1636,7 +1636,7 @@ void Server::setup_and_start_battle() { this->registration_phase = RegistrationPhase::BATTLE_STARTED; this->update_battle_state_flags_and_send_6xB4x03_if_needed(true); - if (!is_trial) { + if (!is_nte) { this->send_6xB4x50_trap_tile_locations(); G_UpdateMap_Ep3_6xB4x05 cmd; cmd.state = *this->map_and_rules; @@ -1775,7 +1775,7 @@ void Server::on_server_data_input(shared_ptr sender_c, const string& dat throw runtime_error("unknown CAx subsubcommand"); } - if (this->options.is_trial() || !header.mask_key) { + if (this->options.is_nte() || !header.mask_key) { (this->*handler)(sender_c, data); } else { string unmasked_data = data; @@ -1808,7 +1808,7 @@ void Server::handle_CAx0B_mulligan_hand(shared_ptr, const string& data) } } - if (!this->options.is_trial() || (error_code == 0)) { + if (!this->options.is_nte() || (error_code == 0)) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num.load(); out_cmd.error_code = error_code; @@ -1835,7 +1835,7 @@ void Server::handle_CAx0C_end_mulligan_phase(shared_ptr, const string& d error_code = -0x78; } - if (this->options.is_trial() && error_code) { + if (this->options.is_nte() && error_code) { return; } @@ -1866,7 +1866,7 @@ void Server::handle_CAx0C_end_mulligan_phase(shared_ptr, const string& d } } - if (!this->options.is_trial() || !error_code) { + if (!this->options.is_nte() || !error_code) { G_ActionResult_Ep3_6xB4x1E out_cmd_fin; out_cmd_fin.sequence_num = in_cmd.header.sequence_num; out_cmd_fin.response_phase = 2; @@ -1884,7 +1884,7 @@ void Server::handle_CAx0D_end_non_action_phase(shared_ptr, const string& throw runtime_error("invalid client ID"); } - if (!this->options.is_trial()) { + if (!this->options.is_nte()) { G_ActionResult_Ep3_6xB4x1E out_cmd_ack; out_cmd_ack.sequence_num = in_cmd.header.sequence_num; out_cmd_ack.response_phase = 1; @@ -1895,7 +1895,7 @@ void Server::handle_CAx0D_end_non_action_phase(shared_ptr, const string& G_ActionResult_Ep3_6xB4x1E out_cmd_fin; out_cmd_fin.sequence_num = in_cmd.header.sequence_num; - out_cmd_fin.response_phase = this->options.is_trial() ? 0 : 2; + out_cmd_fin.response_phase = this->options.is_nte() ? 0 : 2; this->send(out_cmd_fin); } @@ -1930,7 +1930,7 @@ void Server::handle_CAx0E_discard_card_from_hand(shared_ptr, const strin } } - if (!this->options.is_trial() || (error_code == 0)) { + if (!this->options.is_nte() || (error_code == 0)) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num; out_cmd.error_code = error_code; @@ -1975,10 +1975,10 @@ void Server::handle_CAx0F_set_card_from_hand(shared_ptr, const string& d this->ruler_server->error_code1 = error_code; } - if (!this->options.is_trial() || always_send_response) { + if (!this->options.is_nte() || always_send_response) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num; - out_cmd.error_code = this->options.is_trial() ? (was_set ? 0 : 1) : this->ruler_server->error_code1; + out_cmd.error_code = this->options.is_nte() ? (was_set ? 0 : 1) : this->ruler_server->error_code1; this->send(out_cmd); } @@ -2016,10 +2016,10 @@ void Server::handle_CAx10_move_fc_to_location(shared_ptr, const string& this->ruler_server->error_code2 = error_code; } - if (!this->options.is_trial() || (this->ruler_server->error_code2 == 0)) { + if (!this->options.is_nte() || (this->ruler_server->error_code2 == 0)) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num; - out_cmd.error_code = this->options.is_trial() ? 0 : this->ruler_server->error_code2; + out_cmd.error_code = this->options.is_nte() ? 0 : this->ruler_server->error_code2; this->send(out_cmd); } @@ -2054,11 +2054,11 @@ void Server::handle_CAx11_enqueue_attack_or_defense(shared_ptr, const st this->ruler_server->error_code3 = error_code; } - bool is_trial = this->options.is_trial(); - if (!is_trial || (error_code == 0)) { + bool is_nte = this->options.is_nte(); + if (!is_nte || (error_code == 0)) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num; - out_cmd.error_code = is_trial ? !!this->ruler_server->error_code3 : this->ruler_server->error_code3; + out_cmd.error_code = is_nte ? !!this->ruler_server->error_code3 : this->ruler_server->error_code3; this->send(out_cmd); } @@ -2081,7 +2081,7 @@ void Server::handle_CAx12_end_attack_list(shared_ptr, const string& data this->end_attack_list_for_client(in_cmd.client_id); } - if (!this->options.is_trial() || (error_code == 0)) { + if (!this->options.is_nte() || (error_code == 0)) { G_ActionResult_Ep3_6xB4x1E out_cmd; out_cmd.sequence_num = in_cmd.header.sequence_num; this->send(out_cmd); @@ -2134,7 +2134,7 @@ void Server::handle_CAx13_update_map_during_setup_t(shared_ptr, const st } void Server::handle_CAx13_update_map_during_setup(shared_ptr c, const string& data) { - if (this->options.is_trial()) { + if (this->options.is_nte()) { this->handle_CAx13_update_map_during_setup_t(c, data); } else { this->handle_CAx13_update_map_during_setup_t(c, data); @@ -2167,7 +2167,7 @@ void Server::handle_CAx14_update_deck_during_setup(shared_ptr, const str if (verify_error) { throw runtime_error(string_printf("invalid deck: -0x%" PRIX32, verify_error)); } - if (!this->options.is_trial() && !(this->options.behavior_flags & BehaviorFlag::SKIP_D1_D2_REPLACE)) { + if (!this->options.is_nte() && !(this->options.behavior_flags & BehaviorFlag::SKIP_D1_D2_REPLACE)) { this->ruler_server->replace_D1_D2_rank_cards_with_Attack(entry.card_ids); } *this->deck_entries[in_cmd.client_id] = in_cmd.entry; @@ -2244,10 +2244,10 @@ void Server::handle_CAx1D_start_battle(shared_ptr, const string& data) { in_cmd.header.subsubcommand, "START BATTLE"); if (!this->battle_in_progress) { - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); bool should_start = false; - if (is_trial) { + if (is_nte) { should_start = (this->registration_phase == RegistrationPhase::REGISTERED); } else if (this->update_registration_phase()) { should_start = true; @@ -2511,7 +2511,7 @@ void Server::send_6xB6x41_to_all_clients() const { } if (map_commands_by_language[c->language()].empty()) { map_commands_by_language[c->language()] = this->prepare_6xB6x41_map_definition( - this->last_chosen_map, c->language(), this->options.is_trial()); + this->last_chosen_map, c->language(), this->options.is_nte()); } this->log().info("Sending %c version of map %08" PRIX32, char_for_language_code(c->language()), this->last_chosen_map->map_number); send_command(c, 0x6C, 0x00, map_commands_by_language[c->language()]); @@ -2584,9 +2584,9 @@ void Server::handle_CAx49_card_counts(shared_ptr, const string& data) { } void Server::compute_losing_team_id_and_add_winner_flags(uint32_t flags) { - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); - if (!is_trial) { + if (!is_nte) { for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; if (ps) { @@ -2602,7 +2602,7 @@ void Server::compute_losing_team_id_and_add_winner_flags(uint32_t flags) { int8_t losing_team_id = -1; array team_counts = {0, 0}; - if (!is_trial) { + if (!is_nte) { // First, check which team has more dead SCs for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; @@ -2702,7 +2702,7 @@ void Server::compute_losing_team_id_and_add_winner_flags(uint32_t flags) { if (losing_team_id != ps->get_team_id()) { ps->assist_flags |= winner_flags; } - if (!is_trial || (losing_team_id != ps->get_team_id())) { + if (!is_nte || (losing_team_id != ps->get_team_id())) { ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); } } @@ -2730,7 +2730,7 @@ void Server::unknown_8023EEF4() { return; } - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); while (this->unknown_a14 < this->num_pending_attacks_with_cards) { auto card = this->attack_cards[this->unknown_a14]; if (this->get_current_team_turn() == card->get_team_id()) { @@ -2738,7 +2738,7 @@ void Server::unknown_8023EEF4() { log.debug("card @%04hX #%04hX can attack", card->get_card_ref(), card->get_card_id()); string as_str = as.str(); log.debug("as: %s", as_str.c_str()); - if (is_trial) { + if (is_nte) { this->replace_targets_due_to_destruction_nte(&as); } else { this->replace_targets_due_to_destruction_or_conditions(&as); @@ -2764,7 +2764,7 @@ void Server::unknown_8023EEF4() { G_SetActionState_Ep3_6xB4x29 cmd; cmd.unknown_a1 = this->unknown_a14; cmd.state = this->pending_attacks_with_cards[this->unknown_a14]; - if (is_trial) { + if (is_nte) { this->replace_targets_due_to_destruction_nte(&cmd.state); } else { this->replace_targets_due_to_destruction_or_conditions(&cmd.state); @@ -2774,7 +2774,7 @@ void Server::unknown_8023EEF4() { this->card_special->unknown_8024AAB8(as); - if (!is_trial) { + if (!is_nte) { this->attack_cards[this->unknown_a14]->compute_action_chain_results(1, 0); this->attack_cards[this->unknown_a14]->unknown_80236374(this->attack_cards[this->unknown_a14], &as); if (!this->attack_cards[this->unknown_a14]->action_chain.check_flag(0x40)) { @@ -2808,7 +2808,7 @@ void Server::unknown_8023EEF4() { this->send_6xB4x02_for_all_players_if_needed(); } - if (!is_trial) { + if (!is_nte) { this->update_battle_state_flags_and_send_6xB4x03_if_needed(); this->send_6xB4x02_for_all_players_if_needed(); } @@ -3047,11 +3047,11 @@ void Server::unknown_8023EE48() { } void Server::unknown_8023EE80() { - bool is_trial = this->options.is_trial(); + bool is_nte = this->options.is_nte(); if (this->unknown_a14 < this->num_pending_attacks_with_cards) { this->attack_cards[this->unknown_a14]->apply_attack_result(); - if (is_trial) { + if (is_nte) { for (size_t z = 0; z < 4; z++) { auto ps = this->player_states[z]; if (ps) { @@ -3064,7 +3064,7 @@ void Server::unknown_8023EE80() { this->check_for_battle_end(); - if (is_trial) { + if (is_nte) { this->unknown_8023EEF4(); this->update_battle_state_flags_and_send_6xB4x03_if_needed(); this->send_6xB4x02_for_all_players_if_needed(); @@ -3111,7 +3111,7 @@ vector> Server::const_cast_set_cards_v( } void Server::send_6xB4x39() const { - if (this->options.is_trial()) { + if (this->options.is_nte()) { G_UpdateAllPlayerStatistics_Ep3NTE_6xB4x39 cmd; for (size_t z = 0; z < 4; z++) { if (this->player_states[z]) { @@ -3132,7 +3132,7 @@ void Server::send_6xB4x39() const { void Server::send_6xB4x05() { this->compute_all_map_occupied_bits(); - if (this->options.is_trial()) { + if (this->options.is_nte()) { G_UpdateMap_Ep3NTE_6xB4x05 cmd; cmd.state = *this->map_and_rules; this->send(cmd); diff --git a/src/Episode3/Server.hh b/src/Episode3/Server.hh index 23a16160..1a95020d 100644 --- a/src/Episode3/Server.hh +++ b/src/Episode3/Server.hh @@ -75,7 +75,7 @@ public: std::shared_ptr tournament; std::array, 5> trap_card_ids; - inline bool is_trial() const { + inline bool is_nte() const { return (this->behavior_flags & BehaviorFlag::IS_TRIAL_EDITION); } }; @@ -106,7 +106,7 @@ public: if (cmd.header.size != sizeof(cmd) / 4) { throw std::logic_error("outbound command size field is incorrect"); } - if (!this->options.is_trial() && (cmd.header.subsubcommand == 0x06)) { + if (!this->options.is_nte() && (cmd.header.subsubcommand == 0x06)) { this->num_6xB4x06_commands_sent++; this->prev_num_6xB4x06_commands_sent = this->num_6xB4x06_commands_sent; if (this->num_6xB4x06_commands_sent > 0x100) { @@ -231,7 +231,7 @@ public: G_UpdateDecks_Ep3_6xB4x07 prepare_6xB4x07_decks_update() const; G_SetPlayerNames_Ep3_6xB4x1C prepare_6xB4x1C_names_update() const; - static std::string prepare_6xB6x41_map_definition(std::shared_ptr map, uint8_t language, bool is_trial); + static std::string prepare_6xB6x41_map_definition(std::shared_ptr map, uint8_t language, bool is_nte); void send_6xB6x41_to_all_clients() const; G_SetTrapTileLocations_Ep3_6xB4x50 prepare_6xB4x50_trap_tile_locations() const; diff --git a/src/Lobby.cc b/src/Lobby.cc index e54fceee..c56dae97 100644 --- a/src/Lobby.cc +++ b/src/Lobby.cc @@ -429,9 +429,9 @@ void Lobby::create_ep3_server() { this->log.info("Recreating Episode 3 server state"); } auto tourn = this->tournament_match ? this->tournament_match->tournament.lock() : nullptr; - bool is_trial = this->base_version == Version::GC_EP3_NTE; + bool is_nte = this->base_version == Version::GC_EP3_NTE; Episode3::Server::Options options = { - .card_index = is_trial ? s->ep3_card_index_trial : s->ep3_card_index, + .card_index = is_nte ? s->ep3_card_index_trial : s->ep3_card_index, .map_index = s->ep3_map_index, .behavior_flags = s->ep3_behavior_flags, .random_crypt = this->random_crypt, diff --git a/src/Main.cc b/src/Main.cc index 6743c0b4..85f40d57 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -112,7 +112,7 @@ Version get_cli_version(Arguments& args, Version default_value = Version::UNKNOW return Version::GC_V3; } else if (args.get("xb")) { return Version::XB_V3; - } else if (args.get("ep3-trial")) { + } else if (args.get("ep3-nte")) { return Version::GC_EP3_NTE; } else if (args.get("ep3")) { return Version::GC_EP3; @@ -2461,7 +2461,7 @@ Many versions also accept or require a version option. The version options are:\ --gc-nte: GC Episodes 1&2 Trial Edition\n\ --gc: GC Episodes 1&2\n\ --xb: Xbox Episodes 1&2\n\ - --ep3-trial: GC Episode 3 Trial Edition\n\ + --ep3-nte: GC Episode 3 Trial Edition\n\ --ep3: GC Episode 3\n\ --bb: Blue Burst\n\ \n", diff --git a/src/Quest.cc b/src/Quest.cc index 94fa0560..bbeea680 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -974,7 +974,7 @@ string decode_gci_data( } } else if (header.is_ep3()) { - if (header.is_trial()) { + if (header.is_nte()) { if (known_seed >= 0) { return decrypt_download_quest_data_section( r.getv(header.data_size), header.data_size, known_seed, true, true); diff --git a/src/SaveFileFormats.cc b/src/SaveFileFormats.cc index ada08225..3a735ab5 100644 --- a/src/SaveFileFormats.cc +++ b/src/SaveFileFormats.cc @@ -113,7 +113,7 @@ bool PSOGCIFileHeader::is_ep3() const { return (this->game_id[2] == 'S'); } -bool PSOGCIFileHeader::is_trial() const { +bool PSOGCIFileHeader::is_nte() const { return (this->game_id[0] == 'D'); } diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index c0f7b353..1af5b390 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -89,7 +89,7 @@ struct PSOGCIFileHeader { bool is_ep12() const; bool is_ep3() const; - bool is_trial() const; + bool is_nte() const; } __attribute__((packed)); struct PSOGCSystemFile { diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 0892dbc0..f27b5068 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2789,12 +2789,12 @@ void send_ep3_card_battle_table_state(shared_ptr l, uint16_t table_number throw runtime_error("invalid battle table seat number"); } - bool is_trial = (c->version() == Version::GC_EP3_NTE); - auto& e = is_trial ? cmd_nte.entries[c->card_battle_table_seat_number] : cmd_final.entries[c->card_battle_table_seat_number]; + bool is_nte = (c->version() == Version::GC_EP3_NTE); + auto& e = is_nte ? cmd_nte.entries[c->card_battle_table_seat_number] : cmd_final.entries[c->card_battle_table_seat_number]; if (e.state == 0) { e.state = c->card_battle_table_seat_state; e.guild_card_number = c->license->serial_number; - auto& clients = is_trial ? clients_nte : clients_final; + auto& clients = is_nte ? clients_nte : clients_final; clients.emplace(c); } } diff --git a/system/client-functions/VersionDetectGC.ppc.s b/system/client-functions/VersionDetectGC.ppc.s index 83fbe0e2..7a045cbe 100644 --- a/system/client-functions/VersionDetectGC.ppc.s +++ b/system/client-functions/VersionDetectGC.ppc.s @@ -24,10 +24,10 @@ start: cmplwi r0, 0x47 # Check if high byte of game ID is 'G' beq not_trial cmplwi r0, 0x44 # Check if high byte of game ID is 'D' - beq is_trial + beq is_nte li r3, 0 blr -is_trial: +is_nte: li r3, 0x0054 b end_trial_check not_trial: