Commit a68af2c2 authored by nekrozar's avatar nekrozar Committed by mercury233

add Card.IsCanBeLinkMaterial, Card.GetLinkType and Card.IsLinkType (#98)

parent d7c5bec5
......@@ -440,6 +440,11 @@ uint32 card::get_synchro_type() {
return data.type;
return get_type();
}
uint32 card::get_link_type() {
if(current.location == LOCATION_SZONE && (data.type & TYPE_MONSTER))
return data.type;
return get_type();
}
// Atk and def are sepcial cases since text atk/def ? are involved.
// Asuumption: we can only change the atk/def of cards in LOCATION_MZONE.
int32 card::get_base_attack() {
......@@ -3421,3 +3426,15 @@ int32 card::is_can_be_xyz_material(card* scard) {
return FALSE;
return TRUE;
}
int32 card::is_can_be_link_material(card* scard) {
if(!(get_link_type() & TYPE_MONSTER))
return FALSE;
if(is_status(STATUS_FORBIDDEN))
return FALSE;
effect_set eset;
filter_effect(EFFECT_CANNOT_BE_LINK_MATERIAL, &eset);
for(int32 i = 0; i < eset.size(); ++i)
if(eset[i]->get_value(scard))
return FALSE;
return TRUE;
}
......@@ -179,6 +179,7 @@ public:
uint32 get_type();
uint32 get_fusion_type();
uint32 get_synchro_type();
uint32 get_link_type();
int32 get_base_attack();
int32 get_attack();
int32 get_base_defense();
......@@ -310,6 +311,7 @@ public:
int32 is_can_be_synchro_material(card* scard, card* tuner = 0);
int32 is_can_be_ritual_material(card* scard);
int32 is_can_be_xyz_material(card* scard);
int32 is_can_be_link_material(card* scard);
};
//Locations
......
......@@ -357,6 +357,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_CANNOT_BE_SYNCHRO_MATERIAL 236
#define EFFECT_SYNCHRO_MATERIAL_CUSTOM 237
#define EFFECT_CANNOT_BE_XYZ_MATERIAL 238
#define EFFECT_CANNOT_BE_LINK_MATERIAL 239
#define EFFECT_SYNCHRO_LEVEL 240
#define EFFECT_RITUAL_LEVEL 241
#define EFFECT_XYZ_LEVEL 242
......
......@@ -29,6 +29,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetOriginalType", scriptlib::card_get_origin_type },
{ "GetFusionType", scriptlib::card_get_fusion_type },
{ "GetSynchroType", scriptlib::card_get_synchro_type },
{ "GetLinkType", scriptlib::card_get_link_type },
{ "GetLevel", scriptlib::card_get_level },
{ "GetRank", scriptlib::card_get_rank },
{ "GetLink", scriptlib::card_get_link },
......@@ -91,6 +92,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsType", scriptlib::card_is_type },
{ "IsFusionType", scriptlib::card_is_fusion_type },
{ "IsSynchroType", scriptlib::card_is_synchro_type },
{ "IsLinkType", scriptlib::card_is_link_type },
{ "IsRace", scriptlib::card_is_race },
{ "IsAttribute", scriptlib::card_is_attribute },
{ "IsFusionAttribute", scriptlib::card_is_fusion_attribute },
......@@ -218,6 +220,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsCanBeSynchroMaterial", scriptlib::card_is_can_be_synchro_material },
{ "IsCanBeRitualMaterial", scriptlib::card_is_can_be_ritual_material },
{ "IsCanBeXyzMaterial", scriptlib::card_is_can_be_xyz_material },
{ "IsCanBeLinkMaterial", scriptlib::card_is_can_be_link_material },
{ "CheckFusionMaterial", scriptlib::card_check_fusion_material },
{ "CheckFusionSubstitute", scriptlib::card_check_fusion_substitute },
{ "IsImmuneToEffect", scriptlib::card_is_immune_to_effect },
......
......@@ -168,6 +168,13 @@ int32 scriptlib::card_get_synchro_type(lua_State *L) {
lua_pushinteger(L, pcard->get_synchro_type());
return 1;
}
int32 scriptlib::card_get_link_type(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->get_link_type());
return 1;
}
int32 scriptlib::card_get_level(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
......@@ -668,6 +675,17 @@ int32 scriptlib::card_is_synchro_type(lua_State *L) {
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_link_type(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 ttype = lua_tointeger(L, 2);
if(pcard->get_link_type() & ttype)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_race(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
......@@ -2177,6 +2195,18 @@ int32 scriptlib::card_is_can_be_xyz_material(lua_State *L) {
lua_pushboolean(L, pcard->is_can_be_xyz_material(scard));
return 1;
}
int32 scriptlib::card_is_can_be_link_material(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
card* scard = 0;
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2)) {
check_param(L, PARAM_TYPE_CARD, 2);
scard = *(card**) lua_touserdata(L, 2);
}
lua_pushboolean(L, pcard->is_can_be_link_material(scard));
return 1;
}
int32 scriptlib::card_check_fusion_material(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
......
......@@ -31,6 +31,7 @@ public:
static int32 card_get_origin_type(lua_State *L);
static int32 card_get_fusion_type(lua_State *L);
static int32 card_get_synchro_type(lua_State *L);
static int32 card_get_link_type(lua_State *L);
static int32 card_get_level(lua_State *L);
static int32 card_get_rank(lua_State *L);
static int32 card_get_link(lua_State *L);
......@@ -93,6 +94,7 @@ public:
static int32 card_is_type(lua_State *L);
static int32 card_is_fusion_type(lua_State *L);
static int32 card_is_synchro_type(lua_State *L);
static int32 card_is_link_type(lua_State *L);
static int32 card_is_race(lua_State *L);
static int32 card_is_attribute(lua_State *L);
static int32 card_is_fusion_attribute(lua_State *L);
......@@ -220,6 +222,7 @@ public:
static int32 card_is_can_be_synchro_material(lua_State *L);
static int32 card_is_can_be_ritual_material(lua_State *L);
static int32 card_is_can_be_xyz_material(lua_State *L);
static int32 card_is_can_be_link_material(lua_State *L);
static int32 card_check_fusion_material(lua_State *L);
static int32 card_check_fusion_substitute(lua_State *L);
static int32 card_is_immune_to_effect(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