Commit ff5479d5 authored by oilloillo's avatar oilloillo

fix not counting Duel.GetLocationCountFromEx

parent 6b61871e
Pipeline #8428 passed with stage
in 26 seconds
--水边的幻想 濑笈叶 --水边的幻想 濑笈叶
local M = c999013 local M = c999013
local Mid = 999013 local Mid = 999013
function M.initial_effect(c) function M.initial_effect(c)
--link summon --link summon
c:EnableReviveLimit() c:EnableReviveLimit()
Nef.AddLinkProcedureWithDesc(c, aux.FilterBoolFunction(Card.IsRace, RACE_PLANT), 2, 2, nil, aux.Stringid(Mid, 2)) Nef.AddLinkProcedureWithDesc(c, aux.FilterBoolFunction(Card.IsRace, RACE_PLANT), 2, 2, nil, aux.Stringid(Mid, 2))
--link summon custom --link summon custom
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetDescription(aux.Stringid(Mid, 0)) e1:SetDescription(aux.Stringid(Mid, 0))
e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA) e1:SetRange(LOCATION_EXTRA)
e1:SetCountLimit(1, Mid*10+1) e1:SetCountLimit(1, Mid*10+1)
e1:SetCondition(M.lkcon) e1:SetCondition(M.lkcon)
e1:SetOperation(M.lkop) e1:SetOperation(M.lkop)
e1:SetValue(SUMMON_TYPE_LINK) e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1) c:RegisterEffect(e1)
-- fusion -- fusion
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION) e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetDescription(aux.Stringid(Mid, 1)) e2:SetDescription(aux.Stringid(Mid, 1))
e2:SetRange(LOCATION_MZONE) e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1, Mid*10+2) e2:SetCountLimit(1, Mid*10+2)
e2:SetCost(M.spcost) e2:SetCost(M.spcost)
e2:SetTarget(M.sptg) e2:SetTarget(M.sptg)
e2:SetOperation(M.spop) e2:SetOperation(M.spop)
c:RegisterEffect(e2) c:RegisterEffect(e2)
end end
function M.CheckMaterialSingle(c, fc, mc) function M.CheckMaterialSingle(c, fc, mc)
local tp = fc:GetControler() local tp = fc:GetControler()
if not c:IsCanBeFusionMaterial(fc) then return false end if not c:IsCanBeFusionMaterial(fc) then return false end
local t = fc.hana_mat local t = fc.hana_mat
if not t then return false end if not t then return false end
for i, f in pairs(t) do for i, f in pairs(t) do
if f(c) then return true end if f(c) then return true end
end end
return false return false
end end
function M.fmatcheck(c, fc) function M.fmatcheck(c, fc)
return c:IsAbleToGrave() and M.CheckMaterialSingle(c, fc) return c:IsAbleToGrave() and M.CheckMaterialSingle(c, fc)
end end
function M.fmatcheck2(c, fc, mg) function M.fmatcheck2(c, fc, mg)
if not mg or mg:GetCount() == 0 then return false end if not mg or mg:GetCount() == 0 then return false end
return c:IsAbleToGrave() and M.CheckMaterialSingle(c, fc) return c:IsAbleToGrave() and M.CheckMaterialSingle(c, fc)
and mg:IsExists(M.gridcheck, 1, nil, fc, c) and mg:IsExists(M.gridcheck, 1, nil, fc, c)
end end
function M.gridcheck(c, fc, c2) function M.gridcheck(c, fc, c2)
local tp = fc:GetControler() local tp = fc:GetControler()
return Duel.GetLocationCountFromEx(tp, tp, Group.FromCards(c, c2), fc) > 0 return Duel.GetLocationCountFromEx(tp, tp, Group.FromCards(c, c2), fc) > 0
end end
function M.fusionfilter(c, tp) function M.fusionfilter(c, tp)
return c:IsType(TYPE_FUSION) and c:IsRace(RACE_PLANT) return c:IsType(TYPE_FUSION) and c:IsRace(RACE_PLANT)
and Duel.IsExistingMatchingCard(M.CheckMaterialSingle, tp, LOCATION_HAND+LOCATION_MZONE, 0, 1, nil, c) and Duel.IsExistingMatchingCard(M.CheckMaterialSingle, tp, LOCATION_HAND+LOCATION_MZONE, 0, 1, nil, c)
end end
--[[ --[[
fg:所有植物族融合怪兽 fg:所有植物族融合怪兽
]] ]]
function M.matfilter1(c, fg, tp) function M.matfilter1(c, fg, tp)
local g1 = Duel.GetMatchingGroup(M.fmatcheck, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, c) local g1 = Duel.GetMatchingGroup(M.fmatcheck, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, c)
return fg:IsExists(M.matfilter2, 1, c, g1, c:GetCode(), tp) return fg:IsExists(M.matfilter2, 1, c, g1, c:GetCode(), tp)
end end
--[[ --[[
g1: 第1只融合怪兽的所有可用素材组 g1: 第1只融合怪兽的所有可用素材组
code: 第1只融合怪兽的卡密 code: 第1只融合怪兽的卡密
]] ]]
function M.matfilter2(c, g1, code, tp) function M.matfilter2(c, g1, code, tp)
if c:IsCode(code) then return false end if c:IsCode(code) then return false end
local g2 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, c, g1) local g2 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, c, g1)
if g2:GetCount() == 0 then return false end if g2:GetCount() == 0 then return false end
g2:Merge(g1) g2:Merge(g1)
return g2:GetCount() > 1 return g2:GetCount() > 1 and Duel.GetLocationCountFromEx(tp, tp, g2, TYPE_FUSION) > 0
end end
function M.samefilter(c, g) function M.samefilter(c, g)
return g:IsContains(c) return g:IsContains(c)
end end
function M.lkcon(e, c) function M.lkcon(e, c)
if c == nil then return true end if c == nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp = c:GetControler() local tp = c:GetControler()
local mg = Duel.GetMatchingGroup(M.fusionfilter, tp, LOCATION_EXTRA, 0, nil, tp) local mg = Duel.GetMatchingGroup(M.fusionfilter, tp, LOCATION_EXTRA, 0, nil, tp)
return mg:IsExists(M.matfilter1, 1, nil, mg, tp) return mg:IsExists(M.matfilter1, 1, nil, mg, tp)
end end
function M.lkop(e,tp,eg,ep,ev,re,r,rp,c) function M.lkop(e,tp,eg,ep,ev,re,r,rp,c)
local mg = Duel.GetMatchingGroup(M.fusionfilter, tp, LOCATION_EXTRA, 0, nil, tp) local mg = Duel.GetMatchingGroup(M.fusionfilter, tp, LOCATION_EXTRA, 0, nil, tp)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM) Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
local fc1 = mg:FilterSelect(tp, M.matfilter1, 1, 1, nil, mg, tp):GetFirst() local fc1 = mg:FilterSelect(tp, M.matfilter1, 1, 1, nil, mg, tp):GetFirst()
local matg1 = Duel.GetMatchingGroup(M.fmatcheck, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc1) local matg1 = Duel.GetMatchingGroup(M.fmatcheck, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc1)
local fc2 = mg:FilterSelect(tp, M.matfilter2, 1, 1, fc1, matg1, fc1:GetCode(), tp):GetFirst() local fc2 = mg:FilterSelect(tp, M.matfilter2, 1, 1, fc1, matg1, fc1:GetCode(), tp):GetFirst()
local matg2 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc2, matg1) local matg2 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc2, matg1)
Duel.ConfirmCards(1-tp, Group.FromCards(fc1, fc2)) Duel.ConfirmCards(1-tp, Group.FromCards(fc1, fc2))
-- --
-- 排除原先matg1中的不可用素材 -- 排除原先matg1中的不可用素材
matg1 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc1, matg2) matg1 = Duel.GetMatchingGroup(M.fmatcheck2, tp, LOCATION_HAND+LOCATION_MZONE, 0, nil, fc1, matg2)
-- 对两组素材中共有的卡进行处理 -- 对两组素材中共有的卡进行处理
local same = matg1:Filter(M.samefilter, nil, matg2) local same = matg1:Filter(M.samefilter, nil, matg2)
if same:GetCount() == 1 then if same:GetCount() == 1 then
same = same:GetFirst() same = same:GetFirst()
if matg2:GetCount() == 1 then if matg2:GetCount() == 1 then
matg1:RemoveCard(same) matg1:RemoveCard(same)
elseif matg1:GetCount() == 1 then elseif matg1:GetCount() == 1 then
matg2:RemoveCard(same) matg2:RemoveCard(same)
end end
end end
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_LMATERIAL) Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_LMATERIAL)
local dis1 = matg1:Select(tp, 1, 1, nil) local dis1 = matg1:Select(tp, 1, 1, nil)
local dis2 = matg2:FilterSelect(tp, M.fmatcheck2, 1, 1, dis1:GetFirst(), fc2, dis1) local dis2 = matg2:FilterSelect(tp, M.fmatcheck2, 1, 1, dis1:GetFirst(), fc2, dis1)
-- --
dis1:Merge(dis2) dis1:Merge(dis2)
c:SetMaterial(dis1) c:SetMaterial(dis1)
Duel.SendtoGrave(dis1, REASON_MATERIAL+REASON_LINK) Duel.SendtoGrave(dis1, REASON_MATERIAL+REASON_LINK)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL) e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetReset(RESET_EVENT+0xfe0000+RESET_PHASE+PHASE_END) e1:SetReset(RESET_EVENT+0xfe0000+RESET_PHASE+PHASE_END)
e1:SetValue(1) e1:SetValue(1)
c:RegisterEffect(e1, true) c:RegisterEffect(e1, true)
end end
-- --
function M.spcost(e,tp,eg,ep,ev,re,r,rp,chk) function M.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk == 0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil) end if chk == 0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, nil) end
Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST) Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
end end
function M.spfilter1(c,e,tp,m,f,chkf) function M.spfilter1(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c)) 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 c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false) and c:CheckFusionMaterial(m, nil, chkf)
end end
function M.spfilter2(c, e, tp, m, f, chkf, this_card) function M.spfilter2(c, e, tp, m, f, chkf, this_card)
return c:IsType(TYPE_FUSION) and c:IsRace(RACE_PLANT) and (not f or f(c)) return c:IsType(TYPE_FUSION) and c:IsRace(RACE_PLANT) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false) and c:CheckFusionMaterial(m, this_card, chkf) and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false) and c:CheckFusionMaterial(m, this_card, chkf)
end end
function M.mfilter1(c, e) function M.mfilter1(c, e)
return c:IsType(TYPE_MONSTER) and c:IsLocation(LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD) return c:IsType(TYPE_MONSTER) and c:IsLocation(LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD)
and c:IsAbleToDeck() and not c:IsImmuneToEffect(e) and c:IsCanBeFusionMaterial() and c:IsAbleToDeck() and not c:IsImmuneToEffect(e) and c:IsCanBeFusionMaterial()
end end
function M.sptg(e,tp,eg,ep,ev,re,r,rp,chk) function M.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk == 0 then if chk == 0 then
local chkf = nil local chkf = nil
local mg = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD, 0, nil, TYPE_MONSTER) local mg = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD, 0, nil, TYPE_MONSTER)
local mg1 = mg:Filter(M.mfilter1, nil, e) local mg1 = mg:Filter(M.mfilter1, nil, e)
local res = Duel.IsExistingMatchingCard(M.spfilter1, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg1, nil, chkf) local res = Duel.IsExistingMatchingCard(M.spfilter1, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg1, nil, chkf)
if res then return true end if res then return true end
local c = e:GetHandler() local c = e:GetHandler()
local mg2 = Duel.GetMatchingGroup(M.mfilter1, tp, 0, LOCATION_GRAVE+LOCATION_ONFIELD, nil, e) local mg2 = Duel.GetMatchingGroup(M.mfilter1, tp, 0, LOCATION_GRAVE+LOCATION_ONFIELD, nil, e)
mg2:AddCard(c) mg2:AddCard(c)
res = Duel.IsExistingMatchingCard(M.spfilter2, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg2, nil, chkf, c) res = Duel.IsExistingMatchingCard(M.spfilter2, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg2, nil, chkf, c)
if not res then if not res then
local ce = Duel.GetChainMaterial(tp) local ce = Duel.GetChainMaterial(tp)
if ce ~= nil then if ce ~= nil then
local fgroup = ce:GetTarget() local fgroup = ce:GetTarget()
local mg3 = fgroup(ce, e, tp) local mg3 = fgroup(ce, e, tp)
local mf = ce:GetValue() local mf = ce:GetValue()
res = Duel.IsExistingMatchingCard(M.spfilter1, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg3, mf, chkf) res = Duel.IsExistingMatchingCard(M.spfilter1, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, mg3, mf, chkf)
end end
end end
return res return res
end end
Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA) Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
end end
function M.spop(e,tp,eg,ep,ev,re,r,rp) function M.spop(e,tp,eg,ep,ev,re,r,rp)
local chkf = nil local chkf = nil
local mg = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD, 0, nil, TYPE_MONSTER) local mg = Duel.GetMatchingGroup(Card.IsType, tp, LOCATION_HAND+LOCATION_GRAVE+LOCATION_ONFIELD, 0, nil, TYPE_MONSTER)
local mg1 = mg:Filter(M.mfilter1, nil, e) local mg1 = mg:Filter(M.mfilter1, nil, e)
local sg1 = Duel.GetMatchingGroup(M.spfilter1, tp, LOCATION_EXTRA, 0, nil, e, tp, mg1, nil, chkf) local sg1 = Duel.GetMatchingGroup(M.spfilter1, tp, LOCATION_EXTRA, 0, nil, e, tp, mg1, nil, chkf)
-- --
local c = e:GetHandler() local c = e:GetHandler()
local mg2 = Duel.GetMatchingGroup(M.mfilter1, tp, 0, LOCATION_GRAVE+LOCATION_ONFIELD, nil, e) local mg2 = Duel.GetMatchingGroup(M.mfilter1, tp, 0, LOCATION_GRAVE+LOCATION_ONFIELD, nil, e)
mg2:AddCard(c) mg2:AddCard(c)
local sg2 = Duel.GetMatchingGroup(M.spfilter2, tp, LOCATION_EXTRA, 0, nil, e, tp, mg2, nil, chkf, c) local sg2 = Duel.GetMatchingGroup(M.spfilter2, tp, LOCATION_EXTRA, 0, nil, e, tp, mg2, nil, chkf, c)
-- --
sg1:Merge(sg2) sg1:Merge(sg2)
-- --
local mg3 = nil local mg3 = nil
local sg3 = nil local sg3 = nil
local ce = Duel.GetChainMaterial(tp) local ce = Duel.GetChainMaterial(tp)
if ce ~= nil then if ce ~= nil then
local fgroup = ce:GetTarget() local fgroup = ce:GetTarget()
mg3 = fgroup(ce,e,tp) mg3 = fgroup(ce,e,tp)
local mf = ce:GetValue() local mf = ce:GetValue()
sg3 = Duel.GetMatchingGroup(M.spfilter1, tp, LOCATION_EXTRA, 0, nil, e, tp, mg3, mf, chkf) sg3 = Duel.GetMatchingGroup(M.spfilter1, tp, LOCATION_EXTRA, 0, nil, e, tp, mg3, mf, chkf)
end end
if sg1:GetCount() > 0 or (sg3 ~= nil and sg3:GetCount() > 0) then if sg1:GetCount() > 0 or (sg3 ~= nil and sg3:GetCount() > 0) then
local sg = sg1:Clone() local sg = sg1:Clone()
if sg3 then sg:Merge(sg3) end if sg3 then sg:Merge(sg3) end
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON) Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
local tg = sg:Select(tp, 1, 1, nil) local tg = sg:Select(tp, 1, 1, nil)
local tc = tg:GetFirst() local tc = tg:GetFirst()
if sg1:IsContains(tc) and (sg3 == nil or not sg3:IsContains(tc) or not Duel.SelectYesNo(tp, ce:GetDescription())) then if sg1:IsContains(tc) and (sg3 == nil or not sg3:IsContains(tc) or not Duel.SelectYesNo(tp, ce:GetDescription())) then
if tc:IsRace(RACE_PLANT) and sg2:IsContains(tc) and Duel.SelectYesNo(tp, aux.Stringid(Mid, 3)) then if tc:IsRace(RACE_PLANT) and sg2:IsContains(tc) and Duel.SelectYesNo(tp, aux.Stringid(Mid, 3)) then
local mat1 = Duel.SelectFusionMaterial(tp, tc, mg2, c, chkf) local mat1 = Duel.SelectFusionMaterial(tp, tc, mg2, c, chkf)
tc:SetMaterial(mat1) tc:SetMaterial(mat1)
Duel.ConfirmCards(1-tp, mat1) Duel.ConfirmCards(1-tp, mat1)
Duel.SendtoDeck(mat1, nil, 2, REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.SendtoDeck(mat1, nil, 2, REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
else else
local mat2 = Duel.SelectFusionMaterial(tp, tc, mg1, nil, chkf) local mat2 = Duel.SelectFusionMaterial(tp, tc, mg1, nil, chkf)
tc:SetMaterial(mat2) tc:SetMaterial(mat2)
Duel.ConfirmCards(1-tp, mat2) Duel.ConfirmCards(1-tp, mat2)
Duel.SendtoDeck(mat2, nil, 2, REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.SendtoDeck(mat2, nil, 2, REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
end end
Duel.BreakEffect() Duel.BreakEffect()
Duel.SpecialSummon(tc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP) Duel.SpecialSummon(tc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP)
else else
local mat = Duel.SelectFusionMaterial(tp, tc, mg3, nil, chkf) local mat = Duel.SelectFusionMaterial(tp, tc, mg3, nil, chkf)
local fop = ce:GetOperation() local fop = ce:GetOperation()
fop(ce, e, tp, tc, mat) fop(ce, e, tp, tc, mat)
end end
tc:CompleteProcedure() tc:CompleteProcedure()
end end
end end
\ No newline at end of file
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