Commit 81aa6e14 authored by mercury233's avatar mercury233
parents ce1aedeb 35888392
...@@ -2198,6 +2198,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) { ...@@ -2198,6 +2198,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
return redirect; return redirect;
if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(current.controler, this)) if((redirect & LOCATION_REMOVED) && !is_affected_by_effect(EFFECT_CANNOT_REMOVE) && pduel->game_field->is_player_can_remove(current.controler, this))
return redirect; return redirect;
if((redirect & LOCATION_GRAVE) && !is_affected_by_effect(EFFECT_CANNOT_TO_GRAVE) && pduel->game_field->is_player_can_send_to_grave(current.controler, this))
return redirect;
} }
return 0; return 0;
} }
...@@ -3328,6 +3330,28 @@ int32 card::is_removeable_as_cost(uint8 playerid) { ...@@ -3328,6 +3330,28 @@ int32 card::is_removeable_as_cost(uint8 playerid) {
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
int32 card::is_attack_decreasable_as_cost(uint8 playerid, int32 val) {
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER))
return FALSE;
if(!(current.location & LOCATION_MZONE) || is_position(POS_FACEDOWN))
return FALSE;
if(is_affected_by_effect(EFFECT_SET_ATTACK_FINAL) || is_affected_by_effect(EFFECT_REVERSE_UPDATE))
return FALSE;
if(val && get_attack() < val)
return FALSE;
return TRUE;
}
int32 card::is_defense_decreasable_as_cost(uint8 playerid, int32 val) {
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER))
return FALSE;
if(!(current.location & LOCATION_MZONE) || is_position(POS_FACEDOWN) || (data.type & TYPE_LINK))
return FALSE;
if(is_affected_by_effect(EFFECT_SET_DEFENSE_FINAL) || is_affected_by_effect(EFFECT_REVERSE_UPDATE))
return FALSE;
if(val && get_defense() < val)
return FALSE;
return TRUE;
}
int32 card::is_releasable_by_summon(uint8 playerid, card *pcard) { int32 card::is_releasable_by_summon(uint8 playerid, card *pcard) {
if(is_status(STATUS_SUMMONING)) if(is_status(STATUS_SUMMONING))
return FALSE; return FALSE;
......
...@@ -318,6 +318,8 @@ public: ...@@ -318,6 +318,8 @@ public:
int32 is_destructable_by_effect(effect* peffect, uint8 playerid); int32 is_destructable_by_effect(effect* peffect, uint8 playerid);
int32 is_removeable(uint8 playerid); int32 is_removeable(uint8 playerid);
int32 is_removeable_as_cost(uint8 playerid); int32 is_removeable_as_cost(uint8 playerid);
int32 is_attack_decreasable_as_cost(uint8 playerid, int32 val);
int32 is_defense_decreasable_as_cost(uint8 playerid, int32 val);
int32 is_releasable_by_summon(uint8 playerid, card* pcard); int32 is_releasable_by_summon(uint8 playerid, card* pcard);
int32 is_releasable_by_nonsummon(uint8 playerid); int32 is_releasable_by_nonsummon(uint8 playerid);
int32 is_releasable_by_effect(uint8 playerid, effect* peffect); int32 is_releasable_by_effect(uint8 playerid, effect* peffect);
......
...@@ -205,6 +205,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -205,6 +205,8 @@ static const struct luaL_Reg cardlib[] = {
{ "IsAbleToDeckOrExtraAsCost", scriptlib::card_is_able_to_deck_or_extra_as_cost }, { "IsAbleToDeckOrExtraAsCost", scriptlib::card_is_able_to_deck_or_extra_as_cost },
{ "IsAbleToGraveAsCost", scriptlib::card_is_able_to_grave_as_cost }, { "IsAbleToGraveAsCost", scriptlib::card_is_able_to_grave_as_cost },
{ "IsAbleToRemoveAsCost", scriptlib::card_is_able_to_remove_as_cost }, { "IsAbleToRemoveAsCost", scriptlib::card_is_able_to_remove_as_cost },
{ "IsAbleToDecreaseAttackAsCost", scriptlib::card_is_able_to_decrease_attack_as_cost },
{ "IsAbleToDecreaseDefenseAsCost", scriptlib::card_is_able_to_decrease_defense_as_cost },
{ "IsReleasable", scriptlib::card_is_releasable }, { "IsReleasable", scriptlib::card_is_releasable },
{ "IsReleasableByEffect", scriptlib::card_is_releasable_by_effect }, { "IsReleasableByEffect", scriptlib::card_is_releasable_by_effect },
{ "IsDiscardable", scriptlib::card_is_discardable }, { "IsDiscardable", scriptlib::card_is_discardable },
......
...@@ -2130,6 +2130,34 @@ int32 scriptlib::card_is_able_to_remove_as_cost(lua_State *L) { ...@@ -2130,6 +2130,34 @@ int32 scriptlib::card_is_able_to_remove_as_cost(lua_State *L) {
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
return 1; return 1;
} }
int32 scriptlib::card_is_able_to_decrease_attack_as_cost(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 p = pcard->pduel->game_field->core.reason_player;
int32 val = 0;
if(lua_gettop(L) > 1)
val = lua_tointeger(L, 2);
if(pcard->is_attack_decreasable_as_cost(p, val))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_able_to_decrease_defense_as_cost(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 p = pcard->pduel->game_field->core.reason_player;
int32 val = 0;
if(lua_gettop(L) > 1)
val = lua_tointeger(L, 2);
if(pcard->is_defense_decreasable_as_cost(p, val))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_releasable(lua_State *L) { int32 scriptlib::card_is_releasable(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
......
...@@ -42,7 +42,7 @@ int32 scriptlib::effect_reset(lua_State *L) { ...@@ -42,7 +42,7 @@ int32 scriptlib::effect_reset(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);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->owner == 0) if(peffect->owner == 0 || peffect->handler == 0)
return 0; return 0;
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
peffect->pduel->game_field->remove_effect(peffect); peffect->pduel->game_field->remove_effect(peffect);
......
...@@ -207,6 +207,8 @@ public: ...@@ -207,6 +207,8 @@ public:
static int32 card_is_able_to_extra_as_cost(lua_State *L); static int32 card_is_able_to_extra_as_cost(lua_State *L);
static int32 card_is_able_to_deck_or_extra_as_cost(lua_State *L); static int32 card_is_able_to_deck_or_extra_as_cost(lua_State *L);
static int32 card_is_able_to_remove_as_cost(lua_State *L); static int32 card_is_able_to_remove_as_cost(lua_State *L);
static int32 card_is_able_to_decrease_attack_as_cost(lua_State *L);
static int32 card_is_able_to_decrease_defense_as_cost(lua_State *L);
static int32 card_is_releasable(lua_State *L); static int32 card_is_releasable(lua_State *L);
static int32 card_is_releasable_by_effect(lua_State *L); static int32 card_is_releasable_by_effect(lua_State *L);
static int32 card_is_discardable(lua_State *L); static int32 card_is_discardable(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