Commit 311b7c3f authored by Chen Bill's avatar Chen Bill Committed by GitHub

add Duel.GetReadyChain (#519)

parent 39fb7c86
...@@ -298,6 +298,7 @@ struct processor { ...@@ -298,6 +298,7 @@ struct processor {
uint8 dice_result[5]{ 0 }; uint8 dice_result[5]{ 0 };
uint8 coin_result[MAX_COIN_COUNT]{ 0 }; uint8 coin_result[MAX_COIN_COUNT]{ 0 };
int32 coin_count{ 0 }; int32 coin_count{ 0 };
bool is_target_ready{ false };
uint8 to_bp{ FALSE }; uint8 to_bp{ FALSE };
uint8 to_m2{ FALSE }; uint8 to_m2{ FALSE };
......
...@@ -2121,6 +2121,15 @@ int32 scriptlib::duel_get_current_chain(lua_State *L) { ...@@ -2121,6 +2121,15 @@ int32 scriptlib::duel_get_current_chain(lua_State *L) {
lua_pushinteger(L, pduel->game_field->core.current_chain.size()); lua_pushinteger(L, pduel->game_field->core.current_chain.size());
return 1; return 1;
} }
int32 scriptlib::duel_get_ready_chain(lua_State* L) {
duel* pduel = interpreter::get_duel_info(L);
int32 size = (int32)pduel->game_field->core.current_chain.size();
if (size && !pduel->game_field->core.is_target_ready) {
--size;
}
lua_pushinteger(L, size);
return 1;
}
int32 scriptlib::duel_get_chain_info(lua_State *L) { int32 scriptlib::duel_get_chain_info(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
uint32 c = (uint32)lua_tointeger(L, 1); uint32 c = (uint32)lua_tointeger(L, 1);
...@@ -4780,6 +4789,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -4780,6 +4789,7 @@ static const struct luaL_Reg duellib[] = {
{ "GetFieldCard", scriptlib::duel_get_field_card }, { "GetFieldCard", scriptlib::duel_get_field_card },
{ "CheckLocation", scriptlib::duel_check_location }, { "CheckLocation", scriptlib::duel_check_location },
{ "GetCurrentChain", scriptlib::duel_get_current_chain }, { "GetCurrentChain", scriptlib::duel_get_current_chain },
{ "GetReadyChain", scriptlib::duel_get_ready_chain },
{ "GetChainInfo", scriptlib::duel_get_chain_info }, { "GetChainInfo", scriptlib::duel_get_chain_info },
{ "GetChainEvent", scriptlib::duel_get_chain_event }, { "GetChainEvent", scriptlib::duel_get_chain_event },
{ "GetFirstTarget", scriptlib::duel_get_first_target }, { "GetFirstTarget", scriptlib::duel_get_first_target },
......
...@@ -4071,6 +4071,7 @@ int32 field::add_chain(uint16 step) { ...@@ -4071,6 +4071,7 @@ int32 field::add_chain(uint16 step) {
if(phandler->current.location == LOCATION_HAND) if(phandler->current.location == LOCATION_HAND)
clit.flag |= CHAIN_HAND_EFFECT; clit.flag |= CHAIN_HAND_EFFECT;
core.current_chain.push_back(clit); core.current_chain.push_back(clit);
core.is_target_ready = false;
check_chain_counter(peffect, clit.triggering_player, clit.chain_count); check_chain_counter(peffect, clit.triggering_player, clit.chain_count);
// triggered events which are not caused by event create relation with the handler // triggered events which are not caused by event create relation with the handler
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY) if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
...@@ -4173,6 +4174,7 @@ int32 field::add_chain(uint16 step) { ...@@ -4173,6 +4174,7 @@ int32 field::add_chain(uint16 step) {
} }
case 7: { case 7: {
break_effect(); break_effect();
core.is_target_ready = true;
auto& clit = core.current_chain.back(); auto& clit = core.current_chain.back();
effect* peffect = clit.triggering_effect; effect* peffect = clit.triggering_effect;
peffect->cost_checked = FALSE; peffect->cost_checked = FALSE;
......
...@@ -486,6 +486,7 @@ public: ...@@ -486,6 +486,7 @@ public:
static int32 duel_get_field_card(lua_State *L); static int32 duel_get_field_card(lua_State *L);
static int32 duel_check_location(lua_State *L); static int32 duel_check_location(lua_State *L);
static int32 duel_get_current_chain(lua_State *L); static int32 duel_get_current_chain(lua_State *L);
static int32 duel_get_ready_chain(lua_State* L);
static int32 duel_get_chain_info(lua_State *L); static int32 duel_get_chain_info(lua_State *L);
static int32 duel_get_chain_event(lua_State *L); static int32 duel_get_chain_event(lua_State *L);
static int32 duel_get_first_target(lua_State *L); static int32 duel_get_first_target(lua_State *L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment