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

add Card.IsAbleToEquip, fix CardCheckEquipTarget #211

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3571,6 +3571,17 @@ int32 card::is_control_can_be_changed(int32 ignore_mzone, uint32 zone) {
return FALSE;
return TRUE;
}
int32 card::is_capable_equip(uint8 playerid, int32 ignore_szone) {
if(is_status(STATUS_FORBIDDEN))
return FALSE;
if(current.controler != playerid && is_affected_by_effect(EFFECT_CANNOT_CHANGE_CONTROL))
return FALSE;
if(!ignore_szone && pduel->game_field->get_useable_count(this, playerid, LOCATION_SZONE, playerid, LOCATION_REASON_TOFIELD) <= 0)
return FALSE;
if(pduel->game_field->check_unique_onfield(this, current.controler, LOCATION_MZONE))
return FALSE;
return TRUE;
}
int32 card::is_capable_be_battle_target(card* pcard) {
if(is_affected_by_effect(EFFECT_CANNOT_BE_BATTLE_TARGET, pcard))
return FALSE;
Expand Down
1 change: 1 addition & 0 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class card {
int32 is_capable_turn_set(uint8 playerid);
int32 is_capable_change_control();
int32 is_control_can_be_changed(int32 ignore_mzone, uint32 zone);
int32 is_capable_equip(uint8 playerid, int32 ignore_szone);
int32 is_capable_be_battle_target(card* pcard);
int32 is_capable_be_effect_target(effect* peffect, uint8 playerid);
int32 is_can_be_fusion_material(card* fcard);
Expand Down
1 change: 1 addition & 0 deletions interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsForbidden", scriptlib::card_is_forbidden },
{ "IsAbleToChangeControler", scriptlib::card_is_able_to_change_controler },
{ "IsControlerCanBeChanged", scriptlib::card_is_controler_can_be_changed },
{ "IsAbleToEquip", scriptlib::card_is_able_to_equip },
{ "AddCounter", scriptlib::card_add_counter },
{ "RemoveCounter", scriptlib::card_remove_counter },
{ "GetCounter", scriptlib::card_get_counter },
Expand Down
24 changes: 23 additions & 1 deletion libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,13 @@ int32 scriptlib::card_check_equip_target(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 2);
card* pcard = *(card**) lua_touserdata(L, 1);
card* target = *(card**) lua_touserdata(L, 2);
if(pcard->is_affected_by_effect(EFFECT_EQUIP_LIMIT, target)
uint32 playerid = pcard->current.controler;
if(lua_gettop(L) >= 3)
playerid = lua_tointeger(L, 3);
int32 ign = FALSE;
if(lua_gettop(L) >= 4)
ign = lua_toboolean(L, 4);
if(pcard->is_capable_equip(playerid, ign) && pcard->is_affected_by_effect(EFFECT_EQUIP_LIMIT, target)
&& ((!pcard->is_affected_by_effect(EFFECT_OLDUNION_STATUS) || target->get_union_count() == 0)
&& (!pcard->is_affected_by_effect(EFFECT_UNION_STATUS) || target->get_old_union_count() == 0)))
lua_pushboolean(L, 1);
Expand Down Expand Up @@ -2458,6 +2464,22 @@ int32 scriptlib::card_is_controler_can_be_changed(lua_State *L) {
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_able_to_equip(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 playerid = pcard->current.controler;
if(lua_gettop(L) >= 2)
playerid = lua_tointeger(L, 2);
int32 ign = FALSE;
if(lua_gettop(L) >= 3)
ign = lua_toboolean(L, 3);
if(pcard->is_capable_equip(playerid, ign))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_add_counter(lua_State *L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
Expand Down
1 change: 1 addition & 0 deletions scriptlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class scriptlib {
static int32 card_is_forbidden(lua_State *L);
static int32 card_is_able_to_change_controler(lua_State *L);
static int32 card_is_controler_can_be_changed(lua_State *L);
static int32 card_is_able_to_equip(lua_State *L);
static int32 card_add_counter(lua_State *L);
static int32 card_remove_counter(lua_State *L);
static int32 card_get_counter(lua_State *L);
Expand Down