Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more chain info options #153

Merged
merged 5 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ void chain::set_triggering_state(card* pcard) {
}
triggering_sequence = pcard->current.sequence;
triggering_position = pcard->current.position;
triggering_status = pcard->status;
triggering_summon_type = pcard->summon.type & 0xff00ffff;
triggering_summon_location = pcard->summon.location;
triggering_summon_proc_complete = pcard->is_status(STATUS_PROC_COMPLETE);
triggering_state.code = pcard->get_code();
triggering_state.code2 = pcard->get_another_code();
triggering_state.level = pcard->get_level();
Expand All @@ -44,6 +48,10 @@ void chain::set_triggering_state(card* pcard) {
triggering_state.race = pcard->get_race();
triggering_state.attack = pcard->get_attack();
triggering_state.defense = pcard->get_defense();
//For the triggering archetypes:
auto& setcode = triggering_state.setcodes;
setcode.clear();
pcard->get_set_card(setcode);
}
bool tevent::operator< (const tevent& v) const {
return std::memcmp(this, &v, sizeof(tevent)) < 0;
Expand Down
9 changes: 9 additions & 0 deletions field.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ struct chain {
uint16_t triggering_location;
uint32_t triggering_sequence;
uint8_t triggering_position;
uint32_t triggering_status{};
uint32_t triggering_summon_type{};
uint8_t triggering_summon_location{};
bool triggering_summon_proc_complete{}; //properly summoned or not
card_state triggering_state;
effect* triggering_effect;
group* target_cards;
Expand Down Expand Up @@ -734,6 +738,11 @@ enum class CHAININFO : uint16_t {
TRIGGERING_RACE,
TRIGGERING_ATTACK,
TRIGGERING_DEFENSE,
TRIGGERING_STATUS,
TRIGGERING_SUMMON_LOCATION,
TRIGGERING_SUMMON_TYPE,
TRIGGERING_SUMMON_PROC_COMPLETE,
TRIGGERING_SETCODES,
};

//Timing
Expand Down
29 changes: 25 additions & 4 deletions libduel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,11 +1925,9 @@ LUA_STATIC_FUNCTION(GetChainInfo) {
lua_pushinteger(L, 0);
else
lua_pushinteger(L, 1);
}
else if(ch->triggering_location & LOCATION_FZONE) {
} else if(ch->triggering_location & LOCATION_FZONE) {
lua_pushinteger(L, 0);
}
else if(ch->triggering_location & LOCATION_EMZONE) {
} else if(ch->triggering_location & LOCATION_EMZONE) {
lua_pushinteger(L, ch->triggering_sequence - 5);
} else
lua_pushinteger(L, ch->triggering_sequence);
Expand Down Expand Up @@ -1990,6 +1988,29 @@ LUA_STATIC_FUNCTION(GetChainInfo) {
case CHAININFO::EXTTYPE:
lua_pushinteger(L, ch->triggering_effect->card_type);
break;
case CHAININFO::TRIGGERING_STATUS:
lua_pushinteger(L, ch->triggering_status);
break;
case CHAININFO::TRIGGERING_SUMMON_LOCATION:
lua_pushinteger(L, ch->triggering_summon_location);
break;
case CHAININFO::TRIGGERING_SUMMON_TYPE:
lua_pushinteger(L, ch->triggering_summon_type);
break;
case CHAININFO::TRIGGERING_SUMMON_PROC_COMPLETE:
lua_pushboolean(L, ch->triggering_summon_proc_complete);
break;
case CHAININFO::TRIGGERING_SETCODES: {
const auto& setcodes = ch->triggering_state.setcodes;
lua_createtable(L, setcodes.size(), 0);
int i = 1;
for(const auto& setcode : setcodes) {
lua_pushinteger(L, i++);
lua_pushinteger(L, setcode);
lua_settable(L, -3);
}
break;
}
default:
lua_error(L, "Passed invalid CHAININFO flag.");
}
Expand Down
Loading