Commit 1c7549e8 authored by Chrono-Genex's avatar Chrono-Genex Committed by GitHub

fix & update Effect.IsCostChecked (#460)

parent 0eec9ae4
...@@ -412,7 +412,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev ...@@ -412,7 +412,7 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev
} }
} }
if(!neglect_cost && !(type & EFFECT_TYPE_CONTINUOUS)) { if(!neglect_cost && !(type & EFFECT_TYPE_CONTINUOUS)) {
cost_checked = TRUE; reason_effect->cost_checked = TRUE;
if(cost) { if(cost) {
pduel->lua->add_param(reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(playerid, PARAM_TYPE_INT); pduel->lua->add_param(playerid, PARAM_TYPE_INT);
...@@ -424,10 +424,12 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev ...@@ -424,10 +424,12 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev
pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT); pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT);
pduel->lua->add_param((ptr)0, PARAM_TYPE_INT); pduel->lua->add_param((ptr)0, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(cost, 9)) { if(!pduel->lua->check_condition(cost, 9)) {
cost_checked = FALSE; reason_effect->cost_checked = FALSE;
return FALSE; return FALSE;
} }
} }
} else {
reason_effect->cost_checked = FALSE;
} }
if(!neglect_target && target) { if(!neglect_target && target) {
pduel->lua->add_param(reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(reason_effect, PARAM_TYPE_EFFECT);
...@@ -440,11 +442,11 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev ...@@ -440,11 +442,11 @@ int32 effect::is_activate_ready(effect* reason_effect, uint8 playerid, const tev
pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT); pduel->lua->add_param(e.reason_player, PARAM_TYPE_INT);
pduel->lua->add_param((ptr)0, PARAM_TYPE_INT); pduel->lua->add_param((ptr)0, PARAM_TYPE_INT);
if(!pduel->lua->check_condition(target, 9)) { if(!pduel->lua->check_condition(target, 9)) {
cost_checked = FALSE; reason_effect->cost_checked = FALSE;
return FALSE; return FALSE;
} }
} }
cost_checked = FALSE; reason_effect->cost_checked = FALSE;
return TRUE; return TRUE;
} }
int32 effect::is_activate_ready(uint8 playerid, const tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) { int32 effect::is_activate_ready(uint8 playerid, const tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target) {
......
...@@ -526,6 +526,14 @@ int32 scriptlib::effect_is_cost_checked(lua_State *L) { ...@@ -526,6 +526,14 @@ int32 scriptlib::effect_is_cost_checked(lua_State *L) {
lua_pushboolean(L, peffect->cost_checked); lua_pushboolean(L, peffect->cost_checked);
return 1; return 1;
} }
int32 scriptlib::effect_set_cost_check(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint8 cost_check = lua_toboolean(L, 2);
peffect->cost_checked = cost_check;
return 0;
}
int32 scriptlib::effect_get_activate_location(lua_State *L) { int32 scriptlib::effect_get_activate_location(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
...@@ -618,6 +626,7 @@ static const struct luaL_Reg effectlib[] = { ...@@ -618,6 +626,7 @@ static const struct luaL_Reg effectlib[] = {
{ "IsActivatable", scriptlib::effect_is_activatable }, { "IsActivatable", scriptlib::effect_is_activatable },
{ "IsActivated", scriptlib::effect_is_activated }, { "IsActivated", scriptlib::effect_is_activated },
{ "IsCostChecked", scriptlib::effect_is_cost_checked }, { "IsCostChecked", scriptlib::effect_is_cost_checked },
{ "SetCostCheck", scriptlib::effect_set_cost_check },
{ "GetActivateLocation", scriptlib::effect_get_activate_location }, { "GetActivateLocation", scriptlib::effect_get_activate_location },
{ "GetActivateSequence", scriptlib::effect_get_activate_sequence }, { "GetActivateSequence", scriptlib::effect_get_activate_sequence },
{ "CheckCountLimit", scriptlib::effect_check_count_limit }, { "CheckCountLimit", scriptlib::effect_check_count_limit },
......
...@@ -4147,6 +4147,7 @@ int32 field::add_chain(uint16 step) { ...@@ -4147,6 +4147,7 @@ int32 field::add_chain(uint16 step) {
case 5: { case 5: {
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 = TRUE;
if(peffect->cost) { if(peffect->cost) {
core.sub_solving_event.push_back(clit.evt); core.sub_solving_event.push_back(clit.evt);
add_process(PROCESSOR_EXECUTE_COST, 0, peffect, 0, clit.triggering_player, 0); add_process(PROCESSOR_EXECUTE_COST, 0, peffect, 0, clit.triggering_player, 0);
...@@ -4166,6 +4167,7 @@ int32 field::add_chain(uint16 step) { ...@@ -4166,6 +4167,7 @@ int32 field::add_chain(uint16 step) {
break_effect(); break_effect();
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;
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
if(clit.target_cards && clit.target_cards->container.size()) { if(clit.target_cards && clit.target_cards->container.size()) {
if(peffect->is_flag(EFFECT_FLAG_CARD_TARGET)) { if(peffect->is_flag(EFFECT_FLAG_CARD_TARGET)) {
......
...@@ -333,6 +333,7 @@ public: ...@@ -333,6 +333,7 @@ public:
static int32 effect_is_activatable(lua_State *L); static int32 effect_is_activatable(lua_State *L);
static int32 effect_is_activated(lua_State *L); static int32 effect_is_activated(lua_State *L);
static int32 effect_is_cost_checked(lua_State *L); static int32 effect_is_cost_checked(lua_State *L);
static int32 effect_set_cost_check(lua_State *L);
static int32 effect_get_activate_location(lua_State *L); static int32 effect_get_activate_location(lua_State *L);
static int32 effect_get_activate_sequence(lua_State *L); static int32 effect_get_activate_sequence(lua_State *L);
static int32 effect_check_count_limit(lua_State *L); static int32 effect_check_count_limit(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