Commit f1698667 authored by EerieCode's avatar EerieCode Committed by mercury233

add function aux.checksamecolumn (#888)

parent 73dc6e16
...@@ -52,10 +52,6 @@ function c3784434.atkcon(e) ...@@ -52,10 +52,6 @@ function c3784434.atkcon(e)
local c=e:GetHandler() local c=e:GetHandler()
local at=Duel.GetAttackTarget() local at=Duel.GetAttackTarget()
if (ph==PHASE_DAMAGE or ph==PHASE_DAMAGE_CAL) and Duel.GetAttacker()==c and at then if (ph==PHASE_DAMAGE or ph==PHASE_DAMAGE_CAL) and Duel.GetAttacker()==c and at then
local s1=c:GetSequence() return aux.checksamecolumn(c,at)
local s2=at:GetSequence()
if s1==5 then s1=1 elseif s1==6 then s1=3 end
if s2==5 then s2=1 elseif s2==6 then s2=3 end
return s1+s2==4
else return false end else return false end
end end
...@@ -55,19 +55,14 @@ function c39188539.seqop(e,tp,eg,ep,ev,re,r,rp) ...@@ -55,19 +55,14 @@ function c39188539.seqop(e,tp,eg,ep,ev,re,r,rp)
Duel.MoveSequence(c,nseq) Duel.MoveSequence(c,nseq)
end end
end end
function c39188539.filter(c,s1) function c39188539.filter(c,sc)
if not c:IsAbleToHand() then return false end return aux.checksamecolumn(c,sc) and c:IsAbleToHand()
local s2=c:GetSequence()
if c:IsLocation(LOCATION_SZONE) and s2>=5 then return false end
if s1==5 then s1=1 elseif s1==6 then s1=3 end
if s2==5 then s2=1 elseif s2==6 then s2=3 end
return s1+s2==4
end end
function c39188539.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c39188539.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and c39188539.filter(chkc,e:GetHandler():GetSequence()) end if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and c39188539.filter(chkc,e:GetHandler()) end
if chk==0 then return Duel.IsExistingTarget(c39188539.filter,tp,0,LOCATION_ONFIELD,1,nil,e:GetHandler():GetSequence()) end if chk==0 then return Duel.IsExistingTarget(c39188539.filter,tp,0,LOCATION_ONFIELD,1,nil,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,c39188539.filter,tp,0,LOCATION_ONFIELD,1,1,nil,e:GetHandler():GetSequence()) local g=Duel.SelectTarget(tp,c39188539.filter,tp,0,LOCATION_ONFIELD,1,1,nil,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end end
function c39188539.thop(e,tp,eg,ep,ev,re,r,rp) function c39188539.thop(e,tp,eg,ep,ev,re,r,rp)
......
...@@ -44,14 +44,7 @@ function c76573247.seqop(e,tp,eg,ep,ev,re,r,rp) ...@@ -44,14 +44,7 @@ function c76573247.seqop(e,tp,eg,ep,ev,re,r,rp)
Duel.MoveSequence(c,nseq) Duel.MoveSequence(c,nseq)
end end
end end
function c76573247.filter(c,s1)
local s2=c:GetSequence()
if c:IsLocation(LOCATION_SZONE) and s2>=5 then return false end
if s1==5 then s1=1 elseif s1==6 then s1=3 end
if s2==5 then s2=1 elseif s2==6 then s2=3 end
return s1+s2==4
end
function c76573247.dircon(e) function c76573247.dircon(e)
local tp=e:GetHandlerPlayer() local tp=e:GetHandlerPlayer()
return not Duel.IsExistingMatchingCard(c76573247.filter,tp,0,LOCATION_ONFIELD,1,nil,e:GetHandler():GetSequence()) return not Duel.IsExistingMatchingCard(aux.checksamecolumn,tp,0,LOCATION_ONFIELD,1,nil,e:GetHandler())
end end
...@@ -12,33 +12,19 @@ function c99788587.initial_effect(c) ...@@ -12,33 +12,19 @@ function c99788587.initial_effect(c)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c99788587.condition(e,tp,eg,ep,ev,re,r,rp) function c99788587.condition(e,tp,eg,ep,ev,re,r,rp)
local seq=e:GetHandler():GetSequence() local c=e:GetHandler()
return e:GetHandler():IsFacedown() return Duel.GetMatchingGroupCount(aux.checksamecolumn,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,true)==3
and Duel.GetFieldCard(tp,LOCATION_MZONE,seq)
and Duel.GetFieldCard(tp,LOCATION_SZONE,seq)
and Duel.GetFieldCard(1-tp,LOCATION_MZONE,4-seq)
and Duel.GetFieldCard(1-tp,LOCATION_SZONE,4-seq)
end end
function c99788587.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c99788587.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return true end if chk==0 then return true end
local seq=e:GetHandler():GetSequence() local c=e:GetHandler()
local g=Group.CreateGroup() local g=Duel.GetMatchingGroup(aux.checksamecolumn,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,true)
g:AddCard(Duel.GetFieldCard(tp,LOCATION_MZONE,seq))
g:AddCard(Duel.GetFieldCard(tp,LOCATION_SZONE,seq))
g:AddCard(Duel.GetFieldCard(1-tp,LOCATION_MZONE,4-seq))
g:AddCard(Duel.GetFieldCard(1-tp,LOCATION_SZONE,4-seq))
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end end
function c99788587.activate(e,tp,eg,ep,ev,re,r,rp) function c99788587.activate(e,tp,eg,ep,ev,re,r,rp)
local seq=e:GetHandler():GetSequence() local c=e:GetHandler()
local g=Group.CreateGroup() local g=Duel.GetMatchingGroup(aux.checksamecolumn,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,true)
local tc=Duel.GetFieldCard(tp,LOCATION_MZONE,seq) if g:GetCount()>0 then
if tc then g:AddCard(tc) end
tc=Duel.GetFieldCard(tp,LOCATION_SZONE,seq)
if tc then g:AddCard(tc) end
tc=Duel.GetFieldCard(1-tp,LOCATION_MZONE,4-seq)
if tc then g:AddCard(tc) end
tc=Duel.GetFieldCard(1-tp,LOCATION_SZONE,4-seq)
if tc then g:AddCard(tc) end
Duel.Destroy(g,REASON_EFFECT) Duel.Destroy(g,REASON_EFFECT)
end
end end
...@@ -1369,3 +1369,26 @@ function Auxiliary.bfgcost(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -1369,3 +1369,26 @@ function Auxiliary.bfgcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end end
--Checks whether 2 cards are on the same column
--skip_ex is optional, indicates whether the Extra Monster Zone should be ignored (used in Blasting Fuse)
function Auxiliary.checksamecolumn(c1,c2,skip_ex)
if not c1 or not c1:IsOnField() or not c2 or not c2:IsOnField() then return false end
if c1==c2 then return false end
local s1=c1:GetSequence()
local s2=c2:GetSequence()
if (c1:IsLocation(LOCATION_SZONE) and s1>=5)
or (c2:IsLocation(LOCATION_SZONE) and s2>=5) then return false end
if c1:GetControler()==c2:GetControler() then
if skip_ex then
return s2==s1
else
return s2==s1 or (s1==1 and s2==5) or (s1==3 and s2==6)
end
else
if skip_ex then
return s2==4-s1
else
return s2==4-s1 or (s1==1 and s2==6) or (s1==3 and s2==5)
end
end
end
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