more ep3 debugging
This commit is contained in:
+13
-15
@@ -1219,7 +1219,9 @@ void Card::move_phase_before() {
|
||||
}
|
||||
|
||||
void Card::unknown_80236374(shared_ptr<Card> other_card, const ActionState* as) {
|
||||
auto log = this->server()->log_stack(string_printf("unknown_80236374(@%04hX #%04hX, @%04hX #%04hX): ", this->get_card_ref(), this->get_card_id(), other_card->get_card_ref(), other_card->get_card_id()));
|
||||
auto s = this->server();
|
||||
auto log = s->log_stack(string_printf("unknown_80236374(@%04hX #%04hX, @%04hX #%04hX): ", this->get_card_ref(), this->get_card_id(), other_card->get_card_ref(), other_card->get_card_id()));
|
||||
|
||||
auto check_card = [&](shared_ptr<Card> card) -> void {
|
||||
if (card) {
|
||||
if (!card->unknown_80236554(other_card, as)) {
|
||||
@@ -1231,25 +1233,21 @@ void Card::unknown_80236374(shared_ptr<Card> other_card, const ActionState* as)
|
||||
};
|
||||
|
||||
for (size_t client_id = 0; client_id < 4; client_id++) {
|
||||
auto ps = this->server()->player_states[client_id];
|
||||
if (ps) {
|
||||
if (this->server()->get_current_team_turn2() != ps->get_team_id()) {
|
||||
check_card(ps->get_sc_card());
|
||||
for (size_t set_index = 0; set_index < 8; set_index++) {
|
||||
check_card(ps->get_set_card(set_index));
|
||||
}
|
||||
auto ps = s->player_states[client_id];
|
||||
if (ps && (s->get_current_team_turn2() != ps->get_team_id())) {
|
||||
check_card(ps->get_sc_card());
|
||||
for (size_t set_index = 0; set_index < 8; set_index++) {
|
||||
check_card(ps->get_set_card(set_index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t client_id = 0; client_id < 4; client_id++) {
|
||||
auto ps = this->server()->player_states[client_id];
|
||||
if (ps) {
|
||||
if (this->server()->get_current_team_turn2() == ps->get_team_id()) {
|
||||
check_card(ps->get_sc_card());
|
||||
for (size_t set_index = 0; set_index < 8; set_index++) {
|
||||
check_card(ps->get_set_card(set_index));
|
||||
}
|
||||
auto ps = s->player_states[client_id];
|
||||
if (ps && (s->get_current_team_turn2() == ps->get_team_id())) {
|
||||
check_card(ps->get_sc_card());
|
||||
for (size_t set_index = 0; set_index < 8; set_index++) {
|
||||
check_card(ps->get_set_card(set_index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,8 +252,7 @@ void CardSpecial::apply_action_conditions(
|
||||
temp_as = *as;
|
||||
}
|
||||
} else {
|
||||
temp_as = this->create_defense_state_for_card_pair_action_chains(
|
||||
attacker_card, defender_card);
|
||||
temp_as = this->create_defense_state_for_card_pair_action_chains(attacker_card, defender_card);
|
||||
}
|
||||
|
||||
this->apply_defense_conditions(temp_as, when, defender_card, flags);
|
||||
@@ -422,8 +421,7 @@ bool CardSpecial::apply_defense_conditions(
|
||||
shared_ptr<Card> defender_card,
|
||||
uint32_t flags) {
|
||||
for (size_t z = 0; z < 9; z++) {
|
||||
this->apply_defense_condition(
|
||||
when, &defender_card->action_chain.conditions[z], z, as, defender_card, flags, 0);
|
||||
this->apply_defense_condition(when, &defender_card->action_chain.conditions[z], z, as, defender_card, flags, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+11
-11
@@ -736,23 +736,23 @@ string name_for_rank(CardRank rank) {
|
||||
}
|
||||
}
|
||||
|
||||
string name_for_target_mode(TargetMode target_mode) {
|
||||
const char* name_for_target_mode(TargetMode target_mode) {
|
||||
static const vector<const char*> names({
|
||||
"NONE",
|
||||
"SINGLE",
|
||||
"MULTI",
|
||||
"SINGLE_RANGE",
|
||||
"MULTI_RANGE",
|
||||
"SELF",
|
||||
"TEAM",
|
||||
"EVERYONE",
|
||||
"MULTI_RANGE_ALLIES",
|
||||
"ALL_ALLIES",
|
||||
"ALL",
|
||||
"MULTI-ALLY",
|
||||
"ALL-ALLY",
|
||||
"ALL-ATTACK",
|
||||
"OWN-FCS",
|
||||
"OWN_FCS",
|
||||
});
|
||||
try {
|
||||
return names.at(static_cast<uint8_t>(target_mode));
|
||||
} catch (const out_of_range&) {
|
||||
return string_printf("(%02hhX)", static_cast<uint8_t>(target_mode));
|
||||
return "__UNKNOWN__";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ string CardDefinition::str(bool single_line, const TextSet* text_archive) const
|
||||
string criterion_str = name_for_enum(this->usable_criterion);
|
||||
string card_class_str = name_for_enum(this->card_class());
|
||||
string rank_str = name_for_rank(this->rank);
|
||||
string target_mode_str = name_for_target_mode(this->target_mode);
|
||||
const char* target_mode_str = name_for_target_mode(this->target_mode);
|
||||
string assist_turns_str = string_for_assist_turns(this->assist_turns);
|
||||
string hp_str = this->hp.str();
|
||||
string ap_str = this->ap.str();
|
||||
@@ -937,7 +937,7 @@ string CardDefinition::str(bool single_line, const TextSet* text_archive) const
|
||||
criterion_str.c_str(),
|
||||
rank_str.c_str(),
|
||||
cost_str.c_str(),
|
||||
target_mode_str.c_str(),
|
||||
target_mode_str,
|
||||
range_str.c_str(),
|
||||
assist_turns_str.c_str(),
|
||||
this->cannot_move ? "true" : "false",
|
||||
@@ -1004,7 +1004,7 @@ Card: %04" PRIX32 " \"%s\"\n\
|
||||
criterion_str.c_str(),
|
||||
rank_str.c_str(),
|
||||
cost_str.c_str(),
|
||||
target_mode_str.c_str(),
|
||||
target_mode_str,
|
||||
range_str.c_str(),
|
||||
assist_turns_str.c_str(),
|
||||
this->cannot_move ? "cannot" : "can",
|
||||
|
||||
@@ -173,7 +173,7 @@ enum class TargetMode : uint8_t {
|
||||
OWN_FCS = 0x09, // e.g. Traitor
|
||||
};
|
||||
|
||||
std::string name_for_target_mode(TargetMode target_mode);
|
||||
const char* name_for_target_mode(TargetMode target_mode);
|
||||
|
||||
enum class ConditionType : uint8_t {
|
||||
NONE = 0x00,
|
||||
|
||||
@@ -1472,7 +1472,7 @@ bool RulerServer::compute_effective_range_and_target_mode_for_attack(
|
||||
uint16_t* out_orig_card_ref) const {
|
||||
auto s = this->server();
|
||||
bool is_nte = s->options.is_nte();
|
||||
auto log = s->log_stack("compute_effective_range_and_target_mode_for_attack");
|
||||
auto log = s->log_stack("compute_effective_range_and_target_mode_for_attack: ");
|
||||
|
||||
size_t z;
|
||||
for (z = 0; (z < 8) && (pa.action_card_refs[z] != 0xFFFF); z++) {
|
||||
@@ -1505,17 +1505,17 @@ 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)) {
|
||||
string target_mode_name = name_for_target_mode(target_mode);
|
||||
const char* target_mode_name = name_for_target_mode(target_mode);
|
||||
log.debug("attacker card ref @%04hX has fixed range; target mode is %s (%hhu)",
|
||||
pa.attacker_card_ref.load(), target_mode_name.c_str(), static_cast<uint8_t>(target_mode));
|
||||
pa.attacker_card_ref.load(), target_mode_name, static_cast<uint8_t>(target_mode));
|
||||
card_id = this->card_id_for_card_ref(pa.attacker_card_ref);
|
||||
if (!is_nte) {
|
||||
auto sc_ce = this->definition_for_card_id(card_id);
|
||||
if (sc_ce && (static_cast<uint8_t>(target_mode) < 6)) {
|
||||
target_mode = sc_ce->def.target_mode;
|
||||
string target_mode_name = name_for_target_mode(target_mode);
|
||||
const char* target_mode_name = name_for_target_mode(target_mode);
|
||||
log.debug("sc_ce overrides target mode with %s (%hhu)",
|
||||
target_mode_name.c_str(), static_cast<uint8_t>(target_mode));
|
||||
target_mode_name, static_cast<uint8_t>(target_mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2059,21 +2059,27 @@ shared_ptr<const CardIndex::CardEntry> RulerServer::definition_for_card_id(uint3
|
||||
|
||||
uint32_t RulerServer::get_card_id_with_effective_range(
|
||||
uint16_t card_ref, uint16_t card_id_override, TargetMode* out_target_mode) const {
|
||||
auto log = this->server()->log_stack(string_printf("get_card_id_with_effective_range(@%04hX, #%04hX): ", card_ref, card_id_override));
|
||||
|
||||
uint16_t card_id = (card_id_override == 0xFFFF)
|
||||
? this->card_id_for_card_ref(card_ref)
|
||||
: card_id_override;
|
||||
log.debug("card_id=#%04hX", card_id);
|
||||
|
||||
if (card_id != 0xFFFF) {
|
||||
auto ce = this->definition_for_card_id(card_id);
|
||||
uint8_t client_id = client_id_for_card_ref(card_ref);
|
||||
if ((client_id != 0xFF) && ce) {
|
||||
TargetMode effective_target_mode = ce->def.target_mode;
|
||||
log.debug("ce valid for #%04hX with effective target mode %s", card_id, name_for_target_mode(effective_target_mode));
|
||||
|
||||
if (this->card_ref_or_sc_has_fixed_range(card_ref)) {
|
||||
// Undo the override that may have been passed in
|
||||
auto ce = this->definition_for_card_id(this->card_id_for_card_ref(card_ref));
|
||||
if (ce && (static_cast<uint8_t>(effective_target_mode) < 6)) {
|
||||
effective_target_mode = ce->def.target_mode;
|
||||
log.debug("@%04hX has FIXED_RANGE", card_ref);
|
||||
auto orig_ce = this->definition_for_card_id(this->card_id_for_card_ref(card_ref));
|
||||
if (orig_ce && (static_cast<uint8_t>(effective_target_mode) < 6)) {
|
||||
log.debug("ce valid for #%04hX with effective target mode %s; overriding to %s", card_id, name_for_target_mode(effective_target_mode), name_for_target_mode(orig_ce->def.target_mode));
|
||||
effective_target_mode = orig_ce->def.target_mode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2082,14 +2088,17 @@ uint32_t RulerServer::get_card_id_with_effective_range(
|
||||
auto eff = this->assist_server->get_active_assist_by_index(z);
|
||||
if (eff == AssistEffect::SIMPLE) {
|
||||
card_id = this->card_id_for_card_ref(card_ref);
|
||||
log.debug("SIMPLE assist effect is active; using #%04hX for range", card_id);
|
||||
} else if (eff == AssistEffect::HEAVY_FOG) {
|
||||
card_id = 0xFFFE;
|
||||
log.debug("HEAVY_FOG assist effect is active; limiting range to one tile in front");
|
||||
}
|
||||
}
|
||||
|
||||
if (out_target_mode) {
|
||||
*out_target_mode = effective_target_mode;
|
||||
}
|
||||
log.debug("results: card_id=#%04hX, target_mode=%s", card_id, name_for_target_mode(effective_target_mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user