Commit 81cb5b31 authored by salix5's avatar salix5

GetOriginalCodeRule()

my opinion:
always treated as x: datas.alias=x in cards.cdb
also always treated as x: EFFECT_ADD_CODE in script
parent 73126474
......@@ -213,6 +213,7 @@ uint32 card::get_info_location() {
return c + (l << 8) + (s << 16) + (ss << 24);
}
}
// get the current code
uint32 card::get_code() {
if(assume_type == ASSUME_CODE)
return assume_value;
......@@ -241,6 +242,7 @@ uint32 card::get_code() {
}
return code;
}
// get the current second-code
uint32 card::get_another_code() {
if(is_affected_by_effect(EFFECT_CHANGE_CODE))
return 0;
......@@ -251,8 +253,6 @@ uint32 card::get_another_code() {
uint32 otcode = eset.get_last()->get_value(this);
if(get_code() != otcode)
return otcode;
if(data.alias == otcode)
return data.code;
return 0;
}
int32 card::is_set_card(uint32 set_code) {
......
......@@ -18,6 +18,7 @@
static const struct luaL_Reg cardlib[] = {
{ "GetCode", scriptlib::card_get_code },
{ "GetOriginalCode", scriptlib::card_get_origin_code },
{ "GetOriginalCodeRule", scriptlib::card_get_origin_code_rule },
{ "IsSetCard", scriptlib::card_is_set_card },
{ "GetType", scriptlib::card_get_type },
{ "GetOriginalType", scriptlib::card_get_origin_type },
......
......@@ -25,6 +25,8 @@ int32 scriptlib::card_get_code(lua_State *L) {
}
return 1;
}
// GetOriginalCode(): get the original code printed on card
// return: 1 int
int32 scriptlib::card_get_origin_code(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
......@@ -39,6 +41,26 @@ int32 scriptlib::card_get_origin_code(lua_State *L) {
lua_pushinteger(L, pcard->data.code);
return 1;
}
// GetOriginalCodeRule(): get the original code in duel (can be different from printed code)
// return: 1-2 int
int32 scriptlib::card_get_origin_code_rule(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->data.alias)
lua_pushinteger(L, pcard->data.alias);
else {
lua_pushinteger(L, pcard->data.code);
effect_set eset;
pcard->filter_effect(EFFECT_ADD_CODE, &eset);
if(eset.size()) {
uint32 otcode = eset.get_last()->get_value(pcard);
lua_pushinteger(L, otcode);
return 2;
}
}
return 1;
}
int32 scriptlib::card_is_set_card(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
......
......@@ -20,6 +20,7 @@ public:
//card lib
static int32 card_get_code(lua_State *L);
static int32 card_get_origin_code(lua_State *L);
static int32 card_get_origin_code_rule(lua_State *L);
static int32 card_is_set_card(lua_State *L);
static int32 card_get_type(lua_State *L);
static int32 card_get_origin_type(lua_State *L);
......
......@@ -24,7 +24,8 @@ function c10000040.initial_effect(c)
c:RegisterEffect(e3)
end
function c10000040.spfilter(c,code)
return c:GetOriginalCode()==code
local code1,code2=c:GetOriginalCodeRule()
return code1==code or code2==code
end
function c10000040.spcon(e,c)
if c==nil then return true end
......
......@@ -12,8 +12,8 @@ function c40854824.initial_effect(c)
Duel.AddCustomActivityCounter(40854824,ACTIVITY_CHAIN,c40854824.chainfilter)
end
function c40854824.chainfilter(re,tp,cid)
local code=re:GetHandler():GetOriginalCode()
return not (re:IsActiveType(TYPE_MONSTER) and (code==79407975 or code==79856792))
local code1,code2=re:GetHandler():GetOriginalCodeRule()
return not (re:IsActiveType(TYPE_MONSTER) and (code1==79407975 or code1==79856792 or code2==79407975 or code2==79856792))
end
function c40854824.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCustomActivityCount(40854824,tp,ACTIVITY_CHAIN)~=0
......
......@@ -11,7 +11,8 @@ function c75190122.initial_effect(c)
c:RegisterEffect(e1)
end
function c75190122.cfilter(c,code)
return c:IsFaceup() and c:GetOriginalCode()==code
local code1,code2=c:GetOriginalCodeRule()
return c:IsFaceup() and (code1==code or code2==code)
end
function c75190122.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c75190122.cfilter,tp,LOCATION_MZONE,0,1,nil,46986414)
......
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