Commit c16bf662 authored by nanahira's avatar nanahira

mzonecount

parent d51f2061
......@@ -84,19 +84,17 @@ function cm.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.SelectMatchingCard(tp,cm.costfilter,tp,LOCATION_MZONE,0,1,1,e:GetHandler())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function cm.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
function cm.filter(c,e,tp,ec)
return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetMZoneCount(tp,ec,tp)>0
end
function cm.costfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsLevelBelow(4) and c:IsAbleToRemoveAsCost()
end
function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local ft=e:GetLabel() or 0
local ec=e:GetLabel()==1 and e:GetHandler() or nil
e:SetLabel(0)
local ct=-ft
return Duel.GetMZoneCount(tp)>ct
and Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_DECK,0,1,nil,e,tp)
and Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_DECK,0,1,nil,e,tp,ec)
end
e:SetLabel(0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
......@@ -104,7 +102,7 @@ end
function cm.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetMZoneCount(tp)<=0 or not e:GetHandler():IsRelateToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp,nil)
local tc=g:GetFirst()
if tc and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then
local e1=Effect.CreateEffect(e:GetHandler())
......
......@@ -46,17 +46,7 @@ function cm.filter(c,e,tp,m,ft)
if c.mat_filter then
mg=mg:Filter(c.mat_filter,nil)
end
if ft>0 then
return mg:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c)
else
return ft>-1 and mg:IsExists(cm.mfilterf,1,nil,tp,mg,c)
end
end
function cm.mfilterf(c,tp,mg,rc)
if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5 then
Duel.SetSelectedCard(c)
return mg:CheckWithSumEqual(Card.GetRitualLevel,rc:GetLevel(),0,99,rc)
else return false end
return Senya.CheckRitualMaterial(c,mg,tp,c:GetLevel())
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
......@@ -82,20 +72,7 @@ function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if tc.mat_filter then
mg=mg:Filter(tc.mat_filter,nil)
end
local mat=nil
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:FilterSelect(tp,cm.mfilterf,1,1,nil,tp,mg,tc)
Duel.SetSelectedCard(mat)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat2=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),0,99,tc)
mat:Merge(mat2)
end
tc:SetMaterial(mat)
Duel.ReleaseRitualMaterial(mat)
local mat=Senya.CheckRitualMaterial(tc,mg,tp,tc:GetLevel())
end
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP)
......
--White Lotus
local m=37564328
local cm=_G["c"..m]
local coroutine=require("coroutine")
xpcall(function() require("expansions/script/c37564765") end,function() require("script/c37564765") end)
function cm.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,m+EFFECT_COUNT_CODE_DUEL)
e1:SetTarget(cm.target)
e1:SetOperation(cm.activate)
c:RegisterEffect(e1)
end
function cm.filter2(c,e,tp,m,f,chkf,sgf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) and not (sgf and sgf:IsContains(c))
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=PLAYER_NONE
local mg1=Senya.GetFusionMaterial(tp)
local res=Duel.IsExistingMatchingCard(cm.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(cm.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,0,tp,LOCATION_EXTRA)
end
function cm.ffilter(c,tp)
return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE)
end
function cm.nfilter(c,g,t)
if g and g:IsContains(c) then return false end
if t then
for cc,g1 in pairs(t) do
if g1:IsContains(c) then return false end
end
end
return true
end
function cm.fieldcheck(tp,mgf,sgf,co)
local ft=Duel.GetMZoneCount(tp)-sgf:GetCount()+mgf:FilterCount(cm.ffilter,nil,tp)
for fc,mg in pairs(co) do
ft=ft+mg:FilterCount(cm.ffilter,nil,tp)
end
return ft>0 and PLAYER_NONE or tp
end
function cm.fselect(tp,fc,mg,mgf,sgf,co)
local f=Duel.GetLocationCountFromEx
Duel.GetLocationCountFromEx=cm.fcheck(f,mgf,sgf,co)
local g=Duel.SelectFusionMaterial(tp,fc,mg,nil,PLAYER_NONE)
Duel.GetLocationCountFromEx=f
return g
end
function cm.fcheck(f,mgf,sgf,co)
return function(p1,p2,g,fc)
local tg=g:Clone()
tg:Merge(mgf)
for fc,mg in pairs(co) do
tg:Merge(mg)
end
return f(p1,p2,tg,fc)-sgf:GetCount()
end
end
function cm.activate(e,tp,eg,ep,ev,re,r,rp)
local mgf=Group.CreateGroup()
local sgf=Group.CreateGroup()
local co={}
local crt={}
local mg1=Senya.GetFusionMaterial(tp,nil,nil,cm.nfilter,nil,e,mgf,co)
local sg1=Duel.GetMatchingGroup(cm.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,PLAYER_NONE,sgf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp):Filter(cm.nfilter,nil,mgf,co)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(cm.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,PLAYER_NONE,sgf,co)
end
local check=true
while (sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0)) and (check or (not Duel.IsPlayerAffectedByEffect(tp,59822133) and Duel.SelectYesNo(tp,210))) do
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=cm.fselect(tp,tc,mg,mgf,sgf,co)
tc:SetMaterial(mat1)
mgf:Merge(mat1)
sgf:AddCard(tc)
else
local mat2=cm.fselect(tp,tc,mg,mgf,sgf,co)
sgf:AddCard(tc)
local fop=ce:GetOperation()
co[tc]=mat2
crt[tc]=coroutine.create(cm.crop(fop,ce,e,tp,tc,mat2))
end
mg1=Senya.GetFusionMaterial(tp,nil,nil,cm.nfilter,nil,e,mgf,co)
sg1=Duel.GetMatchingGroup(cm.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,PLAYER_NONE,sgf)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp):Filter(cm.nfilter,nil,mgf,co)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(cm.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,PLAYER_NONE,sgf)
end
check=false
end
if sgf:GetCount()>0 then
Duel.SendtoGrave(mgf,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
local f1=Duel.SpecialSummon
local f2=Duel.SpecialSummonStep
local f3=Duel.SpecialSummonComplete
local f4=Duel.BreakEffect
local f5=Card.CompleteProcedure
Duel.SpecialSummon=cm.stop
Duel.SpecialSummonStep=cm.stop
Duel.SpecialSummonComplete=aux.NULL
Duel.BreakEffect=aux.NULL
Card.CompleteProcedure=aux.NULL
for i,cr in pairs(crt) do
coroutine.resume(cr)
end
f4()
f1(sgf,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
Duel.SpecialSummon=aux.NULL
Duel.SpecialSummonStep=aux.NULL
for sc in aux.Next(sgf) do
f5(sc)
end
for i,cr in pairs(crt) do
coroutine.resume(cr)
end
Duel.SpecialSummon=f1
Duel.SpecialSummonStep=f2
Duel.SpecialSummonComplete=f3
Duel.BreakEffect=f4
Card.CompleteProcedure=f5
end
end
function cm.stop()
coroutine.yield()
end
function cm.crop(fop,ce,e,tp,tc,mat)
return function()
fop(ce,e,tp,tc,mat)
end
end
\ No newline at end of file
......@@ -75,12 +75,13 @@ function cm.mtop(e,tp,eg,ep,ev,re,r,rp)
Duel.Overlay(c,g)
end
end
function cm.filter1(c,e,tp,og,ft)
function cm.filter1(c,e,tp,og)
if ft==0 and c:GetSequence()>4 then return false end
return c:IsFaceup() and Duel.IsExistingTarget(cm.filter2,tp,0,LOCATION_MZONE,1,nil,e,tp,og,c)
end
function cm.filter2(c,e,tp,og,mc)
return c:IsFaceup() and c:IsAbleToChangeControler() and og:IsExists(cm.filter3,1,nil,e,tp,Group.FromCards(c,mc))
local g=Group.FromCards(c,mc)
return c:IsFaceup() and c:IsAbleToChangeControler() and og:IsExists(cm.filter3,1,nil,e,tp,g) and Duel.GetMZoneCount(tp,g,tp)>0
end
function cm.filter3(c,e,tp,mg)
return c:IsType(TYPE_FUSION) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,true) and Senya.CheckFusionMaterialExact(c,mg,PLAYER_NONE)
......@@ -88,9 +89,8 @@ end
function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
local og=e:GetHandler():GetOverlayGroup()
local ft=Duel.GetMZoneCount(tp)
if chkc then return false end
if chk==0 then return ft>=-1 and Duel.IsExistingTarget(cm.filter1,tp,LOCATION_MZONE,0,1,c,e,tp,og,ft) end
if chk==0 then return Duel.IsExistingTarget(cm.filter1,tp,LOCATION_MZONE,0,1,c,e,tp,og) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local g1=Duel.SelectTarget(tp,cm.filter1,tp,LOCATION_MZONE,0,1,1,c,e,tp,og,ft)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
......@@ -107,11 +107,9 @@ function cm.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) or c:IsFacedown() or c:IsControler(1-tp) then return end
local og=e:GetHandler():GetOverlayGroup()
local ft=Duel.GetMZoneCount(tp)
if ft<0 then return end
local mg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
if mg:IsExists(cm.counterfilter,1,nil,e) then return end
if ft==0 and not mg:IsExists(cm.checklocationfilter,1,nil,tp) then return end
if Duel.GetMZoneCount(tp,mg,tp)<=0 then return end
local fg=og:Filter(cm.filter3,nil,e,tp,mg)
if fg:GetCount()>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
......
......@@ -52,18 +52,18 @@ end
function cm.spfilter(c)
return Senya.check_set_prism(c) and (c:IsAbleToHandAsCost() or c:IsAbleToExtraAsCost())
end
function cm.spgcheck(g,ft)
return g:FilterCount(function(c) return c:GetSequence()<4 end,nil)+ft>0
function cm.spgcheck(g,tp)
return Duel.GetMZoneCount(tp,g,tp)>0
end
function cm.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
local mg=Duel.GetMatchingGroup(cm.spfilter,tp,LOCATION_MZONE,0,nil)
return Senya.CheckGroup(mg,cm.spgcheck,nil,3,3,Duel.GetMZoneCount(tp))
return Senya.CheckGroup(mg,cm.spgcheck,nil,3,3,tp)
end
function cm.spop(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(cm.spfilter,tp,LOCATION_MZONE,0,nil)
local g=Senya.SelectGroup(tp,HINTMSG_RTOHAND,mg,cm.spgcheck,nil,3,3,Duel.GetMZoneCount(tp))
local g=Senya.SelectGroup(tp,HINTMSG_RTOHAND,mg,cm.spgcheck,nil,3,3,tp)
c:SetMaterial(g)
Duel.SendtoHand(g,nil,REASON_COST+REASON_FUSION+REASON_MATERIAL)
end
......
......@@ -28,17 +28,19 @@ function cm.initial_effect(c)
e1:SetValue(1)
c:RegisterEffect(e1)
end
function cm.sfilter(c,e,tp,z)
if z then
return c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,tp,z)
else
function cm.sfilter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
end
function cm.thgcheck(g,tp,z)
return Duel.GetMZoneCount(tp,g,tp,LOCATION_REASON_TOFIELD,z)>0
end
function cm.tdtg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=e:GetHandler():GetLinkedGroup()
local g=e:GetHandler():GetLinkedGroup():Filter(Card.IsAbleToHand,nil)
local z=e:GetHandler():GetLinkedZone()
if chk==0 then return z~=0 and Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,z)>-1 and g:IsExists(Card.IsAbleToHand,1,nil) and Duel.IsExistingMatchingCard(cm.sfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end
local sg=Duel.GetMatchingGroup(cm.sfilter,tp,LOCATION_HAND,0,nil,e,tp)
local ct=sg:GetCount()
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ct=math.min(ct,1) end
if chk==0 then return z~=0 and ct>0 and Senya.CheckGroup(g,cm.thgcheck,nil,1,ct,tp,z) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,g:GetCount(),tp,LOCATION_HAND)
end
......@@ -48,17 +50,18 @@ function cm.tdop(e,tp,eg,ep,ev,re,r,rp)
local sg=Duel.GetMatchingGroup(cm.sfilter,tp,LOCATION_HAND,0,nil,e,tp)
local tg=e:GetHandler():GetLinkedGroup():Filter(Card.IsAbleToHand,nil)
local ct=sg:GetCount()
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ct=1 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g1=tg:Select(tp,1,ct,nil)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ct=math.min(ct,1) end
local g1=Senya.SelectGroup(tp,HINTMSG_RTOHAND,g,cm.thgcheck,nil,1,ct,tp,z)
local rct=Duel.SendtoHand(g1,nil,REASON_EFFECT)
local tsg=Duel.GetMatchingGroup(cm.sfilter,tp,LOCATION_HAND,0,nil,e,tp,z)
if math.min(tsg:GetCount(),rct)==0 or Duel.GetLocationCount(tp,LOCATION_MZONE,tp,LOCATION_REASON_TOFIELD,z)<=0 then return end
local tsg=Duel.GetMatchingGroup(cm.sfilter,tp,LOCATION_HAND,0,nil,e,tp)
local minct=math.min(tsg:GetCount(),rct)
minct=math.min(minct,Duel.GetMZoneCount(tp,nil,tp,LOCATION_REASON_TOFIELD,z))
if minct<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g2=tsg:Select(tp,1,rct,nil)
local g2=tsg:Select(tp,1,minct,nil)
local sct=Duel.SpecialSummon(g2,0,tp,tp,false,false,POS_FACEUP,z)
local og=Duel.GetOperatedGroup()
if og:FilterCount(Senya.check_set_prism,nil)>1 then
if og:FilterCount(Senya.check_set_prism,nil)==2 then
local rg=Duel.GetMatchingGroup(Card.IsAbleToDeck,tp,0,LOCATION_ONFIELD,nil)
if rg:GetCount()>0 and Duel.SelectYesNo(tp,m*16+1) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
......
......@@ -33,7 +33,7 @@ function cm.sfilter(c,e,tp,g)
end
function cm.scheck(g,c,tp)
if c:IsLocation(LOCATION_EXTRA) then return Duel.GetLocationCountFromEx(tp,tp,g,c)>0 end
return Duel.GetMZoneCount(tp)+g:GetCount()>0
return Duel.GetMZoneCount(tp,g,tp)>0
end
function cm.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetMatchingGroup(cm.rfilter,tp,LOCATION_MZONE,0,e:GetHandler())
......
......@@ -27,21 +27,21 @@ function cm.spcon(e,c)
if c==nil then return true end
return Duel.GetFieldGroupCount(c:GetControler(),LOCATION_MZONE,0)==0 and Duel.GetMZoneCount(c:GetControler())>0
end
function cm.filter(c,e,tp)
function cm.filter(c,e,tp,ec)
return c:IsCode(37564765) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsHasEffect(EFFECT_NECRO_VALLEY)
and Duel.GetMZoneCount(tp,ec,tp)>0
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
local l=e:GetLabel()
e:SetLabel(0)
local mft=0
if l==1 and e:GetHandler():GetSequence()<5 then mft=-1 end
if chk==0 then return Duel.GetMZoneCount(tp)>mft and Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp) end
local ec=l==1 and e:GetHandler() or nil
if chk==0 then return Duel.GetMZoneCount(tp)>mft and Duel.IsExistingMatchingCard(cm.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp,ec) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_DECK+LOCATION_GRAVE)
end
function cm.operation(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetMZoneCount(tp)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,e,tp)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,e,tp,nil)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
......
......@@ -94,7 +94,7 @@ function cm.activate(e,tp,eg,ep,ev,re,r,rp)
end
end
function cm.f2(c,e,tp,tc)
return c.Senya_desc_with_nanahira and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationFromEx(tp,tp,Group.FromCards(tc),c)>0
return c.Senya_desc_with_nanahira and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.GetLocationFromEx(tp,tp,tc,c)>0
end
function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local te=e:GetLabelObject()
......@@ -102,9 +102,6 @@ function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if not te then return false end
local tc=te:GetLabelObject()
if not tc or tc:GetFlagEffect(m)==0 or not tc:IsAbleToExtra() then return false end
local ft=0
if tc:IsControler(tp) then ft=-1 end
if Duel.GetMZoneCount(tp)<=ft then return false end
if not Duel.IsExistingMatchingCard(cm.f2,tp,LOCATION_EXTRA,0,1,tc,e,tp,tc) then return false end
return tc==Duel.GetAttacker() or tc==Duel.GetAttackTarget()
end
......
......@@ -9,38 +9,7 @@ aux.BeginPuzzle=aux.TRUE
cm.delay=0x14000
cm.fix=0x40400
cm.m=37564765
--supporting mr3
if not Duel.GetLocationCountFromEx then
cm.master_rule_3_flag=true
Card.IsSynchroType=Card.IsFusionType
Card.IsXyzType=Card.IsFusionType
Card.IsLinkType=Card.IsFusionType
Duel.FilterPlayerEffect=Duel.IsPlayerAffectedByEffect
TYPE_LINK=bit.lshift(TYPE_SPSUMMON,1)
SUMMON_TYPE_LINK=0x4c000000
EFFECT_CANNOT_BE_LINK_MATERIAL=0
function Duel.GetLocationCountFromEx(tp,p,sg,c)
local ft=Duel.GetMZoneCount(tp)
if sg then ft=ft+sg:FilterCount(aux.FConditionCheckF,nil,tp) end
return ft
end
function Duel.GetUsableMZoneCount(tp)
return Duel.GetMZoneCount(tp)
end
local pz=LOCATION_PZONE
LOCATION_PZONE=LOCATION_SZONE
local effect_set_range=Effect.SetRange
function Effect.SetRange(e,r)
local r=r
if e:GetOwner():IsType(TYPE_PENDULUM) and r==LOCATION_SZONE then
r=pz
end
return effect_set_range(e,r)
end
function Card.IsSummonType(c,t)
return bit.band(c:GetSummonType(),t)==t
end
end
function cm.DescriptionInNanahira(id)
id=id or 0
return 37564765*16+id
......@@ -308,7 +277,11 @@ function cm.OverlayGroup(c,g,xm,nchk)
Duel.Overlay(c,tg)
end
function cm.CheckFieldFilter(g,tp,c,f,...)
if c:IsLocation(LOCATION_EXTRA) then
return Duel.GetLocationCountFromEx(tp,tp,g,c)>0 and (not f or f(g,...))
else
return Duel.GetMZoneCount(tp,g,tp)>0 and (not f or f(g,...))
end
end
--xyz summon of prim
function cm.AddXyzProcedureRank(c,rk,f,minct,maxct,xm,...)
......@@ -772,9 +745,8 @@ function cm.PrismCommonEffect(c,tg,op,istg,ctg)
end
return e1
end
function cm.PrismSpsummonFilter(c,ft)
if ft==0 and c:GetSequence()>4 then return false end
return c:IsAbleToHand() and cm.CheckPrism(c) and c:IsFaceup()
function cm.PrismSpsummonFilter(c,tp)
return c:IsAbleToHand() and cm.CheckPrism(c) and c:IsFaceup() and Duel.GetMZoneCount(tp,c,tp)>0
end
function cm.PrismSpsummonCost(cd)
return function(e,tp,eg,ep,ev,re,r,rp,chk)
......@@ -784,12 +756,10 @@ return function(e,tp,eg,ep,ev,re,r,rp,chk)
end
end
function cm.PrismSpsummonTarget(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local ft=Duel.GetMZoneCount(tp)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and cm.PrismSpsummonFilter(chkc,ft) end
if chk==0 then return ft>-1
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.IsExistingTarget(cm.PrismSpsummonFilter,tp,LOCATION_MZONE,0,1,nil,ft) end
if chkc then return chkc:IsLocation(LOCATION_MZONE) and cm.PrismSpsummonFilter(chkc,tp) end
if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.IsExistingTarget(cm.PrismSpsummonFilter,tp,LOCATION_MZONE,0,1,nil,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,cm.PrismSpsummonFilter,tp,LOCATION_MZONE,0,1,1,nil,ft)
local g=Duel.SelectTarget(tp,cm.PrismSpsummonFilter,tp,LOCATION_MZONE,0,1,1,nil,tp)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,tp,LOCATION_MZONE)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
......@@ -934,19 +904,16 @@ function cm.PrismAdvanceCommonEffect(c,fr)
end
return e1
end
function cm.PrismProcFilter(c,ft)
if ft==0 and c:GetSequence()>4 then return false end
return cm.CheckPrism(c)
function cm.PrismProcFilter(c,tp)
return cm.CheckPrism(c) and Duel.GetMZoneCount(tp,c,tp)>0
end
function cm.PrismProcCondition(e,c)
if c==nil then return true end
local tp=c:GetControler()
local ft=Duel.GetMZoneCount(tp)
return ft>-1 and Duel.CheckReleaseGroup(tp,cm.PrismProcFilter,1,nil,ft)
return Duel.CheckReleaseGroup(tp,cm.PrismProcFilter,1,nil,tp)
end
function cm.PrismProcOperation(e,tp,eg,ep,ev,re,r,rp,c)
local ft=Duel.GetMZoneCount(tp)
local g=Duel.SelectReleaseGroup(tp,cm.PrismProcFilter,1,1,nil,ft)
local g=Duel.SelectReleaseGroup(tp,cm.PrismProcFilter,1,1,nil,tp)
Duel.Release(g,REASON_COST)
end
--prism xyz multi-count xyz proc
......@@ -2429,13 +2396,10 @@ function cm.CheckPendulum(c)
local tp=c:GetControler()
return cm.GetPendulumCard(tp,0)==c or cm.GetPendulumCard(tp,1)==c
end
function cm.CheckMFilter(c)
return c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5 and c:IsControler(tp)
end
function cm.CheckSummonLocation(c,tp,g)
local g=g or Group.CreateGroup()
if c:IsLocation(LOCATION_EXTRA) then return Duel.GetLocationCountFromEx(tp,tp,g,c)>0 end
return Duel.GetMZoneCount(tp)+g:FilterCount(cm.CheckMFilter,nil)>0
return Duel.GetMZoneCount(tp,g,tp)>0
end
function cm.AND(...)
local t={...}
......@@ -2550,3 +2514,16 @@ function cm.DFCBackSideCommonEffect(c)
end)
c:RegisterEffect(e2)
end
--for ritual update
function cm.CheckRitualMaterialGoal(g,c,tp,lv,f)
local ct=g:GetCount()
return cm.CheckSummonLocation(c,tp,g) and g:CheckWithSumEqual(f,lv,ct,ct,c)
end
function cm.CheckRitualMaterial(c,g,tp,lv,f)
local f=f or Card.GetRitualLevel
return cm.CheckGroup(g,cm.CheckRitualMaterialGoal,nil,1,99,c,tp,lv,f)
end
function cm.SelectRitualMaterial(c,g,tp,lv,f)
local f=f or Card.GetRitualLevel
return cm.SelectGroup(tp,HINTMSG_RELEASE,g,cm.CheckRitualMaterialGoal,nil,1,99,c,tp,lv,f)
end
\ No newline at end of file
......@@ -80,15 +80,13 @@ function cm.cost(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.Release(c,REASON_COST)
end
function cm.sfilter(c,e,tp)
return c:IsType(TYPE_FUSION) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial()
return c:IsType(TYPE_FUSION) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial() and Duel.GetLocationCountFromEx(tp,tp,e:GetHandler(),c)>0
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetMZoneCount(tp)>-1
and Duel.IsExistingMatchingCard(cm.sfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end
if chk==0 then return Duel.IsExistingMatchingCard(cm.sfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetMZoneCount(tp)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,cm.sfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp)
local tc=g:GetFirst()
......
......@@ -33,7 +33,7 @@ function cm.battlecheck(c,tp)
end
function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
if rp==tp or eg:GetCount()~=1 or Duel.GetMZoneCount(tp)<=0 then return false end
if rp==tp or eg:GetCount()~= then return false end
local tc=eg:GetFirst()
if not Senya.check_set_3L(tc) or not tc:IsType(TYPE_MONSTER) or not tc:IsLocation(LOCATION_GRAVE) or not tc:IsAbleToRemove() or not cm.battlecheck(tc,tp) then return false end
local mg=Duel.GetMatchingGroup(cm.mfilter,tp,LOCATION_DECK,0,nil)
......@@ -44,7 +44,7 @@ function cm.destg(e,tp,eg,ep,ev,re,r,rp,chk)
end
function cm.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
if Duel.GetMZoneCount(tp)<=0 or not tc:IsRelateToEffect(e) or not tc:IsAbleToRemove() or tc:IsImmuneToEffect(e) then return end
if not tc:IsRelateToEffect(e) or not tc:IsAbleToRemove() or tc:IsImmuneToEffect(e) then return end
local mg=Duel.GetMatchingGroup(cm.mfilter,tp,LOCATION_DECK,0,nil,e)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,cm.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,mg,tc)
......
......@@ -21,17 +21,7 @@ function cm.filter(c,e,tp,m1,m2,ft)
if c.mat_filter then
mg=mg:Filter(c.mat_filter,nil)
end
if ft>0 then
return mg:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c)
else
return ft>-1 and mg:IsExists(cm.mfilterf,1,nil,tp,mg,c)
end
end
function cm.mfilterf(c,tp,mg,rc)
if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5 then
Duel.SetSelectedCard(c)
return mg:CheckWithSumEqual(Card.GetRitualLevel,rc:GetLevel(),0,99,rc)
else return false end
return Senya.CheckRitualMaterial(c,mg,tp,c:GetLevel())
end
function cm.mfilter(c)
return c:GetLevel()>0 and Senya.check_set_sayuri(c) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove()
......@@ -64,18 +54,7 @@ function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if tc.mat_filter then
mg=mg:Filter(tc.mat_filter,nil)
end
local mat=nil
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:FilterSelect(tp,cm.mfilterf,1,1,nil,tp,mg,tc)
Duel.SetSelectedCard(mat)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat2=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),0,99,tc)
mat:Merge(mat2)
end
local mat=mat=Senya.CheckRitualMaterial(tc,mg,tp,tc:GetLevel())
tc:SetMaterial(mat)
Senya.SayuriCheckTrigger(tc,e,tp,eg,ep,ev,re,r,rp)
Duel.ReleaseRitualMaterial(mat)
......
......@@ -20,17 +20,7 @@ function cm.filter(c,e,tp,mg,ft)
if c.mat_filter then
mg=mg:Filter(c.mat_filter,nil)
end
if ft>0 then
return mg:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c)
else
return ft>-1 and mg:IsExists(cm.mfilterf,1,nil,tp,mg,c)
end
end
function cm.mfilterf(c,tp,mg,rc)
if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5 then
Duel.SetSelectedCard(c)
return mg:CheckWithSumEqual(Card.GetRitualLevel,rc:GetLevel(),0,99,rc)
else return false end
return Senya.CheckRitualMaterial(c,mg,tp,c:GetLevel())
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
......@@ -57,18 +47,7 @@ function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if tc.mat_filter then
mg=mg:Filter(tc.mat_filter,nil)
end
local mat=nil
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:FilterSelect(tp,cm.mfilterf,1,1,nil,tp,mg,tc)
Duel.SetSelectedCard(mat)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat2=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),0,99,tc)
mat:Merge(mat2)
end
local mat=mat=Senya.CheckRitualMaterial(tc,mg,tp,tc:GetLevel())
tc:SetMaterial(mat)
Senya.SayuriCheckTrigger(tc,e,tp,eg,ep,ev,re,r,rp)
Duel.ReleaseRitualMaterial(mat)
......
--graze
--alice
xpcall(function() require("expansions/script/c37564765") end,function() require("script/c37564765") end)
local m,cm=Senya.SayuriSpellPreload(37564903)
function cm.initial_effect(c)
......@@ -20,17 +20,7 @@ function cm.filter(c,e,tp,mg,ft)
if c.mat_filter then
mg=mg:Filter(c.mat_filter,nil)
end
if ft>0 then
return mg:CheckWithSumEqual(Card.GetRitualLevel,c:GetLevel(),1,99,c)
else
return ft>-1 and mg:IsExists(cm.mfilterf,1,nil,tp,mg,c)
end
end
function cm.mfilterf(c,tp,mg,rc)
if c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:GetSequence()<5 then
Duel.SetSelectedCard(c)
return mg:CheckWithSumEqual(Card.GetRitualLevel,rc:GetLevel(),0,99,rc)
else return false end
return Senya.CheckRitualMaterial(c,mg,tp,c:GetLevel())
end
function cm.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
......@@ -57,18 +47,7 @@ function cm.activate(e,tp,eg,ep,ev,re,r,rp)
if tc.mat_filter then
mg=mg:Filter(tc.mat_filter,nil)
end
local mat=nil
if ft>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),1,99,tc)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
mat=mg:FilterSelect(tp,cm.mfilterf,1,1,nil,tp,mg,tc)
Duel.SetSelectedCard(mat)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE)
local mat2=mg:SelectWithSumEqual(tp,Card.GetRitualLevel,tc:GetLevel(),0,99,tc)
mat:Merge(mat2)
end
local mat=mat=Senya.CheckRitualMaterial(tc,mg,tp,tc:GetLevel())
tc:SetMaterial(mat)
Senya.SayuriCheckTrigger(tc,e,tp,eg,ep,ev,re,r,rp)
Duel.ReleaseRitualMaterial(mat)
......
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