Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Duel.GetSZoneCount #1280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions c11136371.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ function c11136371.cfilter(c)
return c:GetSequence()<5 and c:IsAbleToGraveAsCost()
end
function c11136371.plcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c11136371.cfilter,tp,LOCATION_SZONE,0,1,e:GetHandler()) end
e:SetLabel(1)
local g=Duel.GetMatchingGroup(c11136371.cfilter,tp,LOCATION_SZONE,0,e:GetHandler())
if chk==0 then return g:GetCount()>0 and Duel.GetSZoneCount(tp,g)>0 end
Duel.SendtoGrave(g,REASON_COST)
end
function c11136371.plfilter(c)
return c:IsSetCard(0x1034) and c:IsType(TYPE_MONSTER) and not c:IsForbidden()
end
function c11136371.pltg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c11136371.plfilter,tp,LOCATION_GRAVE,0,1,nil) end
local res=e:GetLabel()==1 or Duel.GetLocationCount(tp,LOCATION_SZONE)>0
if chk==0 then
e:SetLabel(0)
return res and Duel.IsExistingMatchingCard(c11136371.plfilter,tp,LOCATION_GRAVE,0,1,nil)
end
Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,nil,1,tp,LOCATION_GRAVE)
end
function c11136371.plop(e,tp,eg,ep,ev,re,r,rp)
Expand Down
12 changes: 5 additions & 7 deletions c18716735.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ function c18716735.initial_effect(c)
c:RegisterEffect(e2)
end
function c18716735.desfilter(c,tp)
if c:IsFacedown() then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft==0 and c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5 then
return Duel.IsExistingMatchingCard(c18716735.filter,tp,LOCATION_DECK,0,1,nil,true)
else
return Duel.IsExistingMatchingCard(c18716735.filter,tp,LOCATION_DECK,0,1,nil,false)
end
return c:IsFaceup() and (Duel.IsExistingMatchingCard(c18716735.filter2,tp,LOCATION_DECK,0,1,nil)
or (Duel.GetSZoneCount(tp,c)>0 and Duel.IsExistingMatchingCard(c18716735.filter,tp,LOCATION_DECK,0,1,nil,true)))
end
function c18716735.filter2(c)
return c18716735.filter(c,false) and c:IsType(TYPE_FIELD)
end
function c18716735.filter(c,ignore)
return c:IsSetCard(0xe1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable(ignore)
Expand Down
10 changes: 5 additions & 5 deletions c27873305.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ function c27873305.condition(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return (Duel.GetAttacker()==c or Duel.GetAttackTarget()==c)
end
function c27873305.thfilter(c)
return c:IsFaceup() and c:IsSetCard(0xaf,0xae) and c:IsAbleToHand()
function c27873305.thfilter(c,tp)
return c:IsFaceup() and c:IsSetCard(0xaf,0xae) and c:IsAbleToHand() and Duel.GetSZoneCount(tp,c)>0
end
function c27873305.eqfilter(c)
return c:IsFaceup() and c:IsAbleToChangeControler()
end
function c27873305.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(tp) and c27873305.thfilter(chkc) and chkc~=e:GetHandler() end
if chk==0 then return Duel.IsExistingTarget(c27873305.thfilter,tp,LOCATION_ONFIELD,0,1,e:GetHandler())
if chkc then return chkc:IsOnField() and chkc:IsControler(tp) and c27873305.thfilter(chkc,tp) and chkc~=e:GetHandler() end
if chk==0 then return Duel.IsExistingTarget(c27873305.thfilter,tp,LOCATION_ONFIELD,0,1,e:GetHandler(),tp)
and Duel.IsExistingMatchingCard(c27873305.eqfilter,tp,0,LOCATION_MZONE,1,e:GetHandler():GetBattleTarget()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g1=Duel.SelectTarget(tp,c27873305.thfilter,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler())
local g1=Duel.SelectTarget(tp,c27873305.thfilter,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler(),tp)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g1,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,1-tp,LOCATION_MZONE)
end
Expand Down
27 changes: 6 additions & 21 deletions c29223325.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,18 @@ end
function c29223325.filter(c)
return c:IsSetCard(0x97) and c:IsType(TYPE_MONSTER) and c:IsSSetable(true)
end
function c29223325.desfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c29223325.desfilter2(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:GetSequence()<5
function c29223325.desfilter(c,tp,ft)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and Duel.GetSZoneCount(tp,c)>ft
end
function c29223325.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and c29223325.desfilter(chkc) and chkc~=e:GetHandler() end
if chkc then return chkc:IsOnField() and c29223325.desfilter(chkc,tp,0) and chkc~=e:GetHandler() end
if chk==0 then
if not Duel.IsExistingMatchingCard(c29223325.filter,tp,LOCATION_DECK,0,1,nil) then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if e:GetHandler():IsLocation(LOCATION_HAND) then ft=ft-1 end
if ft<0 then return false
elseif ft>0 then
return Duel.IsExistingTarget(c29223325.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler())
else
return Duel.IsExistingTarget(c29223325.desfilter2,tp,LOCATION_ONFIELD,0,1,e:GetHandler())
end
local ft=e:GetHandler():IsLocation(LOCATION_HAND) and 1 or 0
return Duel.IsExistingTarget(c29223325.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,e:GetHandler(),tp,ft)
end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
local g=nil
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
if ft>0 then
g=Duel.SelectTarget(tp,c29223325.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler())
else
g=Duel.SelectTarget(tp,c29223325.desfilter2,tp,LOCATION_ONFIELD,0,1,1,e:GetHandler())
end
local g=Duel.SelectTarget(tp,c29223325.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,e:GetHandler(),tp,0)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c29223325.activate(e,tp,eg,ep,ev,re,r,rp)
Expand Down
13 changes: 8 additions & 5 deletions c30929786.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ end
function c30929786.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x7c) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToGraveAsCost()
end
function c30929786.cfilter2(c,tp)
return c30929786.cfilter(c) and (Duel.IsExistingMatchingCard(c30929786.filter2,tp,LOCATION_DECK,0,1,nil) or Duel.GetSZoneCount(tp,c)>0)
end
function c30929786.setcost(e,tp,eg,ep,ev,re,r,rp,chk)
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if Duel.IsExistingMatchingCard(c30929786.filter2,tp,LOCATION_DECK,0,1,nil) then ft=ft+1 end
if chk==0 then return Duel.IsExistingMatchingCard(c30929786.cfilter,tp,LOCATION_ONFIELD,0,1,nil)
or (Duel.IsPlayerAffectedByEffect(tp,46241344) and ft>0) end
if chk==0 then return Duel.IsExistingMatchingCard(c30929786.cfilter2,tp,LOCATION_ONFIELD,0,1,nil,tp)
or (Duel.IsPlayerAffectedByEffect(tp,46241344) and (Duel.IsExistingMatchingCard(c30929786.filter2,tp,LOCATION_DECK,0,1,nil) or ft>0)) end
if Duel.IsExistingMatchingCard(c30929786.cfilter,tp,LOCATION_ONFIELD,0,1,nil)
and (not Duel.IsPlayerAffectedByEffect(tp,46241344) or ft<=0 or not Duel.SelectYesNo(tp,aux.Stringid(46241344,0))) then
and (not Duel.IsPlayerAffectedByEffect(tp,46241344) or not Duel.IsExistingMatchingCard(c30929786.filter2,tp,LOCATION_DECK,0,1,nil)
or ft<=0 or not Duel.SelectYesNo(tp,aux.Stringid(46241344,0))) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c30929786.cfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
local g=Duel.SelectMatchingCard(tp,c30929786.cfilter2,tp,LOCATION_ONFIELD,0,1,1,nil,tp)
Duel.SendtoGrave(g,REASON_COST)
end
end
Expand Down
12 changes: 5 additions & 7 deletions c33256280.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ function c33256280.initial_effect(c)
c:RegisterEffect(e1)
end
function c33256280.desfilter(c,tp)
if c:IsFacedown() then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft==0 and c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5 then
return Duel.IsExistingMatchingCard(c33256280.filter,tp,LOCATION_DECK,0,1,nil,true)
else
return Duel.IsExistingMatchingCard(c33256280.filter,tp,LOCATION_DECK,0,1,nil,false)
end
return c:IsFaceup() and (Duel.IsExistingMatchingCard(c33256280.filter2,tp,LOCATION_DECK,0,1,nil)
or (Duel.GetSZoneCount(tp,c)>0 and Duel.IsExistingMatchingCard(c33256280.filter,tp,LOCATION_DECK,0,1,nil,true)))
end
function c33256280.filter2(c)
return c33256280.filter(c,false) and c:IsType(TYPE_FIELD)
end
function c33256280.filter(c,ignore)
return c:IsSetCard(0xe1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable(ignore)
Expand Down
6 changes: 2 additions & 4 deletions c40771118.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ function c40771118.plfilter(c,tp,mc)
if not c:IsCode(31893528,67287533,94772232,30170981) then return false end
if Duel.IsPlayerAffectedByEffect(tp,16625614) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,c:GetCode(),0,0x11,0,0,1,RACE_FIEND,ATTRIBUTE_DARK,POS_FACEUP,tp,181) then return true end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if mc:IsLocation(LOCATION_SZONE) then ft=ft+1 end
return ft>0 and not c:IsForbidden()
return Duel.GetSZoneCount(tp,mc)>0 and not c:IsForbidden()
end
function c40771118.pltg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c40771118.plfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,1,nil,tp,e:GetHandler()) end
end
function c40771118.plop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(40771118,2))
local g=Duel.SelectMatchingCard(tp,c40771118.plfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil,tp,c)
local g=Duel.SelectMatchingCard(tp,c40771118.plfilter,tp,LOCATION_HAND+LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil,tp,nil)
local tc=g:GetFirst()
if tc and Duel.IsPlayerAffectedByEffect(tp,16625614) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsPlayerCanSpecialSummonMonster(tp,tc:GetCode(),0,0x11,0,0,1,RACE_FIEND,ATTRIBUTE_DARK,POS_FACEUP,tp,181)
Expand Down
2 changes: 1 addition & 1 deletion c47408488.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
function c47408488.pltg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local ct=e:GetHandler():GetCounter(0x6)
return ct>0 and Duel.GetLocationCount(tp,LOCATION_SZONE)>=-1+ct
return ct>0 and Duel.GetSZoneCount(tp,e:GetHandler())>=ct
and Duel.IsExistingMatchingCard(c47408488.plfilter,tp,LOCATION_DECK,0,ct,nil)
end
end
Expand Down
3 changes: 1 addition & 2 deletions c54895237.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function c54895237.initial_effect(c)
c:RegisterEffect(e3)
end
function c54895237.gspcfilter(c,tp)
return c:IsFaceup() and c:IsType(TYPE_CONTINUOUS) and c:IsAbleToGraveAsCost()
return c:IsFaceup() and c:IsType(TYPE_CONTINUOUS) and c:IsAbleToGraveAsCost() and Duel.GetSZoneCount(tp,c)>0
and Duel.IsExistingMatchingCard(c54895237.gspfilter,tp,LOCATION_HAND,0,1,nil,c,tp)
end
function c54895237.gspfilter(c,cc,tp)
Expand All @@ -47,7 +47,6 @@ end
function c54895237.gsptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.GetLocationCount(tp,LOCATION_SZONE)>-1
and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0)
end
Expand Down
12 changes: 5 additions & 7 deletions c60473572.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ function c60473572.initial_effect(c)
c:RegisterEffect(e1)
end
function c60473572.desfilter(c,tp)
if c:IsFacedown() then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft==0 and c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5 then
return Duel.IsExistingMatchingCard(c60473572.filter,tp,LOCATION_DECK,0,1,nil,true)
else
return Duel.IsExistingMatchingCard(c60473572.filter,tp,LOCATION_DECK,0,1,nil,false)
end
return c:IsFaceup() and (Duel.IsExistingMatchingCard(c60473572.filter2,tp,LOCATION_DECK,0,1,nil)
or (Duel.GetSZoneCount(tp,c)>0 and Duel.IsExistingMatchingCard(c60473572.filter,tp,LOCATION_DECK,0,1,nil,true)))
end
function c60473572.filter2(c)
return c60473572.filter(c,false) and c:IsType(TYPE_FIELD)
end
function c60473572.filter(c,ignore)
return c:IsSetCard(0xe1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable(ignore)
Expand Down
12 changes: 5 additions & 7 deletions c69351984.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ function c69351984.initial_effect(c)
c:RegisterEffect(e1)
end
function c69351984.desfilter(c,tp)
if c:IsFacedown() then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft==0 and c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5 then
return Duel.IsExistingMatchingCard(c69351984.filter,tp,LOCATION_DECK,0,1,nil,true)
else
return Duel.IsExistingMatchingCard(c69351984.filter,tp,LOCATION_DECK,0,1,nil,false)
end
return c:IsFaceup() and (Duel.IsExistingMatchingCard(c69351984.filter2,tp,LOCATION_DECK,0,1,nil)
or (Duel.GetSZoneCount(tp,c)>0 and Duel.IsExistingMatchingCard(c69351984.filter,tp,LOCATION_DECK,0,1,nil,true)))
end
function c69351984.filter2(c)
return c69351984.filter(c,false) and c:IsType(TYPE_FIELD)
end
function c69351984.filter(c,ignore)
return c:IsSetCard(0xe1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable(ignore)
Expand Down
12 changes: 5 additions & 7 deletions c7868571.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ function c7868571.initial_effect(c)
c:RegisterEffect(e1)
end
function c7868571.desfilter(c,tp)
if c:IsFacedown() then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_SZONE)
if ft==0 and c:IsLocation(LOCATION_SZONE) and c:GetSequence()<5 then
return Duel.IsExistingMatchingCard(c7868571.filter,tp,LOCATION_DECK,0,1,nil,true)
else
return Duel.IsExistingMatchingCard(c7868571.filter,tp,LOCATION_DECK,0,1,nil,false)
end
return c:IsFaceup() and (Duel.IsExistingMatchingCard(c7868571.filter2,tp,LOCATION_DECK,0,1,nil)
or (Duel.GetSZoneCount(tp,c)>0 and Duel.IsExistingMatchingCard(c7868571.filter,tp,LOCATION_DECK,0,1,nil,true)))
end
function c7868571.filter2(c)
return c7868571.filter(c,false) and c:IsType(TYPE_FIELD)
end
function c7868571.filter(c,ignore)
return c:IsSetCard(0xe1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable(ignore)
Expand Down
4 changes: 2 additions & 2 deletions c91299846.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function c91299846.initial_effect(c)
c:RegisterEffect(e3)
end
function c91299846.cfilter(c,tp)
return c:IsFaceup() and c:IsType(TYPE_CONTINUOUS) and c:IsAbleToGraveAsCost()
return c:IsFaceup() and c:IsType(TYPE_CONTINUOUS) and c:IsAbleToGraveAsCost() and Duel.GetSZoneCount(tp,c)>0
and Duel.IsExistingMatchingCard(c91299846.tffilter,tp,LOCATION_DECK,0,1,nil,c,tp)
end
function c91299846.tffilter(c,cc,tp)
Expand All @@ -44,7 +44,7 @@ function c91299846.tfcost(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.SendtoGrave(g,REASON_COST)
end
function c91299846.tftg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>-1 end
if chk==0 then return true end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function c91299846.tfop(e,tp,eg,ep,ev,re,r,rp)
Expand Down