Commit 01ecfa26 authored by salix5's avatar salix5

Card.IsCode()

parent 9784109d
......@@ -242,15 +242,14 @@ uint32 card::get_code() {
return code;
}
uint32 card::get_another_code() {
effect_set eset;
effect_set eset, eset2;
filter_effect(EFFECT_ADD_CODE, &eset);
if(!eset.size())
filter_effect(EFFECT_CHANGE_CODE, &eset2);
if(!eset.size() || eset2.size())
return 0;
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,12 +18,8 @@ int32 scriptlib::card_get_code(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->get_code());
uint32 otcode = pcard->get_another_code();
if(otcode) {
lua_pushinteger(L, otcode);
lua_pushinteger(L, pcard->get_another_code());
return 2;
}
return 1;
}
int32 scriptlib::card_get_origin_code(lua_State *L) {
check_param_count(L, 1);
......@@ -449,7 +445,8 @@ int32 scriptlib::card_is_code(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 tcode = lua_tointeger(L, 2);
if(pcard->get_code() == tcode || pcard->get_another_code() == tcode)
uint32 code2 = pcard->get_another_code()
if(pcard->get_code() == tcode || (code2 && code2 == tcode))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
......
......@@ -16,7 +16,7 @@ function c12247206.condition(e,tp,eg,ep,ev,re,r,rp)
end
function c12247206.nfilter(c,tc)
local code1,code2=tc:GetCode()
return c:IsCode(code1) or (code2 and c:IsCode(code2))
return c:IsCode(code1) or c:IsCode(code2)
end
function c12247206.target(e,tp,eg,ep,ev,re,r,rp,chk)
local tc=eg:GetFirst()
......
......@@ -10,38 +10,36 @@ function c75141056.initial_effect(c)
c:RegisterEffect(e1)
end
function c75141056.tgfilter(c)
return c:IsFaceup() and Duel.GetMatchingGroup(c75141056.cfilter,tp,LOCATION_DECK,0,nil,c:GetCode()):FilterCount(Card.IsAbleToGrave,nil)>0
return c:IsFaceup() and Duel.IsExistingMatchingCard(c75141056.cfilter,c:GetControler(),LOCATION_DECK,0,1,nil,c)
end
function c75141056.cfilter(c,code)
return c:IsSetCard(0x3008) and c:GetCode()~=code
function c75141056.cfilter(c,tc)
local code1,code2=tc:GetCode()
return c:IsSetCard(0x3008) and not c:IsCode(code1) and not c:IsCode(code2) and c:IsAbleToGrave()
end
function c75141056.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c:IsFaceup() end
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c75141056.tgfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c75141056.tgfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c75141056.tgfilter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c75141056.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
local g=Duel.GetMatchingGroup(c75141056.cfilter,tp,LOCATION_DECK,0,nil,tc:GetCode())
if g:GetCount()~=0 then
g=g:Filter(Card.IsAbleToGrave,nil)
if g:GetCount()==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
g=g:Select(tp,1,1,nil)
Duel.SendtoGrave(g,REASON_EFFECT)
local g=Duel.SelectMatchingCard(tp,c75141056.cfilter,tp,LOCATION_DECK,0,1,1,nil,tc)
if g:GetCount()>0 then
local gc=g:GetFirst()
if Duel.SendtoGrave(gc,REASON_EFFECT)~=0 and gc:IsLocation(LOCATION_GRAVE) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_CODE)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END)
e1:SetValue(g:GetFirst():GetCode())
e1:SetValue(gc:GetCode())
tc:RegisterEffect(e1)
else
end
elseif IsPlayerCanDiscardDeck(tp,1) then
local cg=Duel.GetFieldGroup(tp,LOCATION_DECK,0)
Duel.ConfirmCards(1-tp,cg)
Duel.ConfirmCards(tp,cg)
Duel.ShuffleDeck(tp)
end
end
end
......@@ -368,7 +368,7 @@ EFFECT_REVERSE_UPDATE =108 --倒置改变攻击力、防御力(天邪鬼)
EFFECT_SWAP_AD =109 --交换攻防
EFFECT_SWAP_BASE_AD =110 --交换原本攻防
EFFECT_ADD_CODE =113 --增加卡名
EFFECT_CHANGE_CODE =114 --改卡名
EFFECT_CHANGE_CODE =114 --改卡名
EFFECT_ADD_TYPE =115 --增加卡片种类(types)
EFFECT_REMOVE_TYPE =116 --删除卡片种类
EFFECT_CHANGE_TYPE =117 --改变卡片种类
......
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