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() { ...@@ -440,6 +440,11 @@ uint32 card::get_synchro_type() {
return data.type; return data.type;
return get_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. // 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. // Asuumption: we can only change the atk/def of cards in LOCATION_MZONE.
int32 card::get_base_attack() { int32 card::get_base_attack() {
...@@ -3421,3 +3426,15 @@ int32 card::is_can_be_xyz_material(card* scard) { ...@@ -3421,3 +3426,15 @@ int32 card::is_can_be_xyz_material(card* scard) {
return FALSE; return FALSE;
return TRUE; 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: ...@@ -179,6 +179,7 @@ public:
uint32 get_type(); uint32 get_type();
uint32 get_fusion_type(); uint32 get_fusion_type();
uint32 get_synchro_type(); uint32 get_synchro_type();
uint32 get_link_type();
int32 get_base_attack(); int32 get_base_attack();
int32 get_attack(); int32 get_attack();
int32 get_base_defense(); int32 get_base_defense();
...@@ -310,6 +311,7 @@ public: ...@@ -310,6 +311,7 @@ public:
int32 is_can_be_synchro_material(card* scard, card* tuner = 0); int32 is_can_be_synchro_material(card* scard, card* tuner = 0);
int32 is_can_be_ritual_material(card* scard); int32 is_can_be_ritual_material(card* scard);
int32 is_can_be_xyz_material(card* scard); int32 is_can_be_xyz_material(card* scard);
int32 is_can_be_link_material(card* scard);
}; };
//Locations //Locations
......
...@@ -357,6 +357,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -357,6 +357,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_CANNOT_BE_SYNCHRO_MATERIAL 236 #define EFFECT_CANNOT_BE_SYNCHRO_MATERIAL 236
#define EFFECT_SYNCHRO_MATERIAL_CUSTOM 237 #define EFFECT_SYNCHRO_MATERIAL_CUSTOM 237
#define EFFECT_CANNOT_BE_XYZ_MATERIAL 238 #define EFFECT_CANNOT_BE_XYZ_MATERIAL 238
#define EFFECT_CANNOT_BE_LINK_MATERIAL 239
#define EFFECT_SYNCHRO_LEVEL 240 #define EFFECT_SYNCHRO_LEVEL 240
#define EFFECT_RITUAL_LEVEL 241 #define EFFECT_RITUAL_LEVEL 241
#define EFFECT_XYZ_LEVEL 242 #define EFFECT_XYZ_LEVEL 242
......
...@@ -29,6 +29,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -29,6 +29,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetOriginalType", scriptlib::card_get_origin_type }, { "GetOriginalType", scriptlib::card_get_origin_type },
{ "GetFusionType", scriptlib::card_get_fusion_type }, { "GetFusionType", scriptlib::card_get_fusion_type },
{ "GetSynchroType", scriptlib::card_get_synchro_type }, { "GetSynchroType", scriptlib::card_get_synchro_type },
{ "GetLinkType", scriptlib::card_get_link_type },
{ "GetLevel", scriptlib::card_get_level }, { "GetLevel", scriptlib::card_get_level },
{ "GetRank", scriptlib::card_get_rank }, { "GetRank", scriptlib::card_get_rank },
{ "GetLink", scriptlib::card_get_link }, { "GetLink", scriptlib::card_get_link },
...@@ -91,6 +92,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -91,6 +92,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsType", scriptlib::card_is_type }, { "IsType", scriptlib::card_is_type },
{ "IsFusionType", scriptlib::card_is_fusion_type }, { "IsFusionType", scriptlib::card_is_fusion_type },
{ "IsSynchroType", scriptlib::card_is_synchro_type }, { "IsSynchroType", scriptlib::card_is_synchro_type },
{ "IsLinkType", scriptlib::card_is_link_type },
{ "IsRace", scriptlib::card_is_race }, { "IsRace", scriptlib::card_is_race },
{ "IsAttribute", scriptlib::card_is_attribute }, { "IsAttribute", scriptlib::card_is_attribute },
{ "IsFusionAttribute", scriptlib::card_is_fusion_attribute }, { "IsFusionAttribute", scriptlib::card_is_fusion_attribute },
...@@ -218,6 +220,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -218,6 +220,7 @@ static const struct luaL_Reg cardlib[] = {
{ "IsCanBeSynchroMaterial", scriptlib::card_is_can_be_synchro_material }, { "IsCanBeSynchroMaterial", scriptlib::card_is_can_be_synchro_material },
{ "IsCanBeRitualMaterial", scriptlib::card_is_can_be_ritual_material }, { "IsCanBeRitualMaterial", scriptlib::card_is_can_be_ritual_material },
{ "IsCanBeXyzMaterial", scriptlib::card_is_can_be_xyz_material }, { "IsCanBeXyzMaterial", scriptlib::card_is_can_be_xyz_material },
{ "IsCanBeLinkMaterial", scriptlib::card_is_can_be_link_material },
{ "CheckFusionMaterial", scriptlib::card_check_fusion_material }, { "CheckFusionMaterial", scriptlib::card_check_fusion_material },
{ "CheckFusionSubstitute", scriptlib::card_check_fusion_substitute }, { "CheckFusionSubstitute", scriptlib::card_check_fusion_substitute },
{ "IsImmuneToEffect", scriptlib::card_is_immune_to_effect }, { "IsImmuneToEffect", scriptlib::card_is_immune_to_effect },
......
...@@ -168,6 +168,13 @@ int32 scriptlib::card_get_synchro_type(lua_State *L) { ...@@ -168,6 +168,13 @@ int32 scriptlib::card_get_synchro_type(lua_State *L) {
lua_pushinteger(L, pcard->get_synchro_type()); lua_pushinteger(L, pcard->get_synchro_type());
return 1; 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) { int32 scriptlib::card_get_level(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);
...@@ -668,6 +675,17 @@ int32 scriptlib::card_is_synchro_type(lua_State *L) { ...@@ -668,6 +675,17 @@ int32 scriptlib::card_is_synchro_type(lua_State *L) {
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
return 1; 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) { int32 scriptlib::card_is_race(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -2177,6 +2195,18 @@ int32 scriptlib::card_is_can_be_xyz_material(lua_State *L) { ...@@ -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)); lua_pushboolean(L, pcard->is_can_be_xyz_material(scard));
return 1; 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) { int32 scriptlib::card_check_fusion_material(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);
......
...@@ -31,6 +31,7 @@ public: ...@@ -31,6 +31,7 @@ public:
static int32 card_get_origin_type(lua_State *L); static int32 card_get_origin_type(lua_State *L);
static int32 card_get_fusion_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_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_level(lua_State *L);
static int32 card_get_rank(lua_State *L); static int32 card_get_rank(lua_State *L);
static int32 card_get_link(lua_State *L); static int32 card_get_link(lua_State *L);
...@@ -93,6 +94,7 @@ public: ...@@ -93,6 +94,7 @@ public:
static int32 card_is_type(lua_State *L); static int32 card_is_type(lua_State *L);
static int32 card_is_fusion_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_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_race(lua_State *L);
static int32 card_is_attribute(lua_State *L); static int32 card_is_attribute(lua_State *L);
static int32 card_is_fusion_attribute(lua_State *L); static int32 card_is_fusion_attribute(lua_State *L);
...@@ -220,6 +222,7 @@ public: ...@@ -220,6 +222,7 @@ public:
static int32 card_is_can_be_synchro_material(lua_State *L); 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_ritual_material(lua_State *L);
static int32 card_is_can_be_xyz_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_material(lua_State *L);
static int32 card_check_fusion_substitute(lua_State *L); static int32 card_check_fusion_substitute(lua_State *L);
static int32 card_is_immune_to_effect(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