clean up some is_nte flags in ep3 server

This commit is contained in:
Martin Michelsen
2024-03-01 19:51:47 -08:00
parent c7812bf764
commit 6eb896f83d
3 changed files with 21 additions and 21 deletions
+16 -17
View File
@@ -1422,15 +1422,14 @@ bool CardSpecial::evaluate_effect_arg2_condition(
attacker_card_ref = as.original_attacker_card_ref; attacker_card_ref = as.original_attacker_card_ref;
} }
bool is_nte = s->options.is_nte();
auto set_card = s->card_for_set_card_ref(set_card_ref); auto set_card = s->card_for_set_card_ref(set_card_ref);
bool set_card_has_ability_trap = bool set_card_has_ability_trap =
(!s->options.is_nte() && (!is_nte && set_card && this->card_has_condition_with_ref(set_card, ConditionType::ABILITY_TRAP, 0xFFFF, 0xFFFF));
set_card &&
this->card_has_condition_with_ref(set_card, ConditionType::ABILITY_TRAP, 0xFFFF, 0xFFFF));
switch (arg2_text[0]) { switch (arg2_text[0]) {
case 'C': case 'C':
if (s->options.is_nte()) { if (is_nte) {
return false; return false;
} }
card = s->card_for_set_card_ref(set_card_ref); card = s->card_for_set_card_ref(set_card_ref);
@@ -1532,16 +1531,16 @@ bool CardSpecial::evaluate_effect_arg2_condition(
uint16_t action_card_ref = as.action_card_refs[z]; uint16_t action_card_ref = as.action_card_refs[z];
if (action_card_ref != 0xFFFF) { if (action_card_ref != 0xFFFF) {
auto ce = s->definition_for_card_ref(action_card_ref); auto ce = s->definition_for_card_ref(action_card_ref);
if (card_class_is_tech_like(ce->def.card_class(), s->options.is_nte())) { if (card_class_is_tech_like(ce->def.card_class(), is_nte)) {
return true; return true;
} }
} }
} }
return false; return false;
case 0x04: // n04 case 0x04: // n04
return card->action_chain.check_flag(s->options.is_nte() ? 0x00000080 : 0x0001E000); return card->action_chain.check_flag(is_nte ? 0x00000080 : 0x0001E000);
case 0x05: // n05 case 0x05: // n05
return card->action_chain.check_flag(s->options.is_nte() ? 0x00000002 : 0x00001E00); return card->action_chain.check_flag(is_nte ? 0x00000002 : 0x00001E00);
case 0x06: // n06 case 0x06: // n06
return (card->get_definition()->def.card_class() == CardClass::NATIVE_CREATURE); return (card->get_definition()->def.card_class() == CardClass::NATIVE_CREATURE);
case 0x07: // n07 case 0x07: // n07
@@ -1559,9 +1558,8 @@ bool CardSpecial::evaluate_effect_arg2_condition(
case 0x0D: { // n13 case 0x0D: { // n13
auto ce = card->get_definition(); auto ce = card->get_definition();
return ((ce->def.card_class() == CardClass::GUARD_ITEM) || return ((ce->def.card_class() == CardClass::GUARD_ITEM) ||
(!s->options.is_nte() && (ce->def.card_class() == CardClass::MAG_ITEM)) || (!is_nte && (ce->def.card_class() == CardClass::MAG_ITEM)) ||
s->ruler_server->find_condition_on_card_ref( s->ruler_server->find_condition_on_card_ref(card->get_card_ref(), ConditionType::GUARD_CREATURE, 0, 0, 0));
card->get_card_ref(), ConditionType::GUARD_CREATURE, 0, 0, 0));
} }
case 0x0E: // n14 case 0x0E: // n14
return card->get_definition()->def.is_sc(); return card->get_definition()->def.is_sc();
@@ -1599,7 +1597,7 @@ bool CardSpecial::evaluate_effect_arg2_condition(
return s->ruler_server->find_condition_on_card_ref( return s->ruler_server->find_condition_on_card_ref(
card->get_card_ref(), ConditionType::FREEZE, 0, 0, 0); card->get_card_ref(), ConditionType::FREEZE, 0, 0, 0);
case 0x15: { // n21 case 0x15: { // n21
if (!s->options.is_nte()) { if (!is_nte) {
uint8_t client_id = client_id_for_card_ref(sc_card_ref); uint8_t client_id = client_id_for_card_ref(sc_card_ref);
if (client_id != 0xFF) { if (client_id != 0xFF) {
return card->action_chain.check_flag(0x00002000 << client_id); return card->action_chain.check_flag(0x00002000 << client_id);
@@ -1608,7 +1606,7 @@ bool CardSpecial::evaluate_effect_arg2_condition(
return false; return false;
} }
case 0x16: { // n22 case 0x16: { // n22
if (!s->options.is_nte()) { if (!is_nte) {
uint8_t client_id = client_id_for_card_ref(sc_card_ref); uint8_t client_id = client_id_for_card_ref(sc_card_ref);
if (client_id != 0xFF) { if (client_id != 0xFF) {
return card->action_chain.check_flag(0x00000200 << client_id); return card->action_chain.check_flag(0x00000200 << client_id);
@@ -1636,7 +1634,7 @@ bool CardSpecial::evaluate_effect_arg2_condition(
card, ConditionType::ANY, set_card_ref, ((v % 10) == 0) ? 0xFF : (v % 10)) != nullptr); card, ConditionType::ANY, set_card_ref, ((v % 10) == 0) ? 0xFF : (v % 10)) != nullptr);
} }
case 'r': case 'r':
return (!set_card_has_ability_trap || s->options.is_nte()) && (random_percent < atoi(arg2_text + 1)); return (!set_card_has_ability_trap || is_nte) && (random_percent < atoi(arg2_text + 1));
case 's': { case 's': {
auto ce = card->get_definition(); auto ce = card->get_definition();
return ((ce->def.self_cost >= arg2_text[1] - '0') && return ((ce->def.self_cost >= arg2_text[1] - '0') &&
@@ -1650,7 +1648,7 @@ bool CardSpecial::evaluate_effect_arg2_condition(
uint8_t v = atoi(arg2_text + 1); uint8_t v = atoi(arg2_text + 1);
// TODO: Figure out what this logic actually does and rename the variables // TODO: Figure out what this logic actually does and rename the variables
// or comment it appropriately. // or comment it appropriately.
if (s->options.is_nte()) { if (is_nte) {
return (v < set_card->unknown_a9); return (v < set_card->unknown_a9);
} else if (when == 4) { } else if (when == 4) {
uint32_t y = set_card->unknown_a9 & 0xFFFFFFFE; uint32_t y = set_card->unknown_a9 & 0xFFFFFFFE;
@@ -2483,7 +2481,7 @@ bool CardSpecial::execute_effect(
} else if (unknown_p7 & 0x20) { } else if (unknown_p7 & 0x20) {
card->action_metadata.attack_bonus = clamp<int16_t>( card->action_metadata.attack_bonus = clamp<int16_t>(
positive_expr_value + card->action_metadata.attack_bonus, -99, 99); card->action_metadata.attack_bonus + positive_expr_value, -99, 99);
} }
return true; return true;
@@ -4714,9 +4712,10 @@ void CardSpecial::move_phase_before_for_card(shared_ptr<Card> card) {
void CardSpecial::dice_phase_before_for_card(shared_ptr<Card> card) { void CardSpecial::dice_phase_before_for_card(shared_ptr<Card> card) {
auto s = this->server(); auto s = this->server();
bool is_nte = s->options.is_nte();
auto ps = card->player_state(); auto ps = card->player_state();
if (s->options.is_nte() && (!ps || !ps->is_team_turn())) { if (is_nte && (!ps || !ps->is_team_turn())) {
return; return;
} }
@@ -4733,7 +4732,7 @@ void CardSpecial::dice_phase_before_for_card(shared_ptr<Card> card) {
} }
} }
if (!s->options.is_nte()) { if (!is_nte) {
this->apply_defense_conditions(as, 0x46, card, 0x04); this->apply_defense_conditions(as, 0x46, card, 0x04);
this->evaluate_and_apply_effects(0x46, card->get_card_ref(), as, sc_card_ref); this->evaluate_and_apply_effects(0x46, card->get_card_ref(), as, sc_card_ref);
} }
+4 -3
View File
@@ -939,6 +939,7 @@ bool RulerServer::check_usability_or_condition_apply(
bool is_item_usability_check, bool is_item_usability_check,
AttackMedium attack_medium) const { AttackMedium attack_medium) const {
auto s = this->server(); auto s = this->server();
bool is_nte = s->options.is_nte();
auto log = s->log_stack(string_printf("check_usability_or_condition_apply(%02hhX, #%04hX, %02hhX, #%04hX, #%04hX, %02hhX, %s, %s): ", client_id1, card_id1, client_id2, card_id2, card_id3, def_effect_index, is_item_usability_check ? "true" : "false", name_for_enum(attack_medium))); auto log = s->log_stack(string_printf("check_usability_or_condition_apply(%02hhX, #%04hX, %02hhX, #%04hX, #%04hX, %02hhX, %s, %s): ", client_id1, card_id1, client_id2, card_id2, card_id3, def_effect_index, is_item_usability_check ? "true" : "false", name_for_enum(attack_medium)));
if (static_cast<uint8_t>(attack_medium) & 0x80) { if (static_cast<uint8_t>(attack_medium) & 0x80) {
@@ -952,7 +953,7 @@ bool RulerServer::check_usability_or_condition_apply(
log.debug("ce1 missing"); log.debug("ce1 missing");
return false; return false;
} }
if (!s->options.is_nte() && (ce1->def.type == CardType::ITEM) && this->card_id_is_boss_sc(card_id2)) { if (!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"); log.debug("ce1 is item and card_id2 is boss sc");
return false; return false;
} }
@@ -989,7 +990,7 @@ bool RulerServer::check_usability_or_condition_apply(
// second should not be given, so we'd return true if the criterion passes. If // 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 // neither of these cases apply, we should return false as a failsafe even if
// the criterion passes. NTE did not have such a check. // the criterion passes. NTE did not have such a check.
bool ret = s->options.is_nte() || (!(def_effect_index & 0x80) || (client_id1 == client_id2)) || (client_id2 == 0xFF); bool ret = is_nte || (!(def_effect_index & 0x80) || (client_id1 == client_id2)) || (client_id2 == 0xFF);
switch (criterion_code) { switch (criterion_code) {
case CriterionCode::NONE: case CriterionCode::NONE:
return ret; return ret;
@@ -1413,7 +1414,7 @@ uint16_t RulerServer::compute_attack_or_defense_costs(
return 99; return 99;
} }
total_cost += (ce->def.self_cost + cost_bias); total_cost += (ce->def.self_cost + cost_bias);
if (card_class_is_tech_like(ce->def.card_class(), s->options.is_nte())) { if (card_class_is_tech_like(ce->def.card_class(), is_nte)) {
total_cost += tech_cost_bias; total_cost += tech_cost_bias;
} }
total_ally_cost += ce->def.ally_cost; total_ally_cost += ce->def.ally_cost;
+1 -1
View File
@@ -1837,7 +1837,7 @@ void Server::on_server_data_input(shared_ptr<Client> sender_c, const string& dat
throw runtime_error("unknown CAx subsubcommand"); throw runtime_error("unknown CAx subsubcommand");
} }
if (this->options.is_nte() || !header.mask_key) { if ((sender_c->version() == Version::GC_EP3_NTE) || !header.mask_key) {
(this->*handler)(sender_c, data); (this->*handler)(sender_c, data);
} else { } else {
string unmasked_data = data; string unmasked_data = data;