Commit b02703c0 authored by Vury Leo's avatar Vury Leo

Add 多層融合 to new fusion

parent cc23a09b
Pipeline #37080 failed with stages
in 3 minutes and 7 seconds
...@@ -13,7 +13,7 @@ function s.initial_effect(c) ...@@ -13,7 +13,7 @@ function s.initial_effect(c)
e1:SetValue(s.mtval) e1:SetValue(s.mtval)
e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_INHERIT end) e1:SetOperation(function() return FusionSpell.FUSION_OPERATION_INHERIT end)
-- as of 2025 May, there is no card can add LOCATION_MZONE base on material group. So we can just check pre_select_mat_location. -- as of 2025 May, there is no card can add LOCATION_MZONE base on material group. So we can just check pre_select_mat_location.
e1:SetLabel(0xff,LOCATION_MZONE) --- only avaliable when pre_select_mat_location contains LOCATION_MZONE, 1st number is limitaion of count materials, set 0xff as a placeholder e1:SetLabel(0,LOCATION_MZONE) --- only avaliable when pre_select_mat_location contains LOCATION_MZONE, 1st number is limitaion of count materials, set 0 as infinity
c:RegisterEffect(e1) c:RegisterEffect(e1)
--counter --counter
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
......
...@@ -2,121 +2,50 @@ ...@@ -2,121 +2,50 @@
local s,id,o=GetID() local s,id,o=GetID()
function s.initial_effect(c) function s.initial_effect(c)
--Activate --Activate
local e1=Effect.CreateEffect(c) local e1=FusionSpell.CreateSummonEffect(c,{
additional_fcheck=s.additional_fcheck,
additional_fgoalcheck=s.additional_fgoalcheck,
pre_select_mat_location=LOCATION_HAND|LOCATION_MZONE|LOCATION_EXTRA,
mat_operation_code_map={
{ [LOCATION_EXTRA|LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH },
{ [0xff] = FusionSpell.FUSION_OPERATION_GRAVE }
},
stage_x_operation=s.stage_x_operation
})
e1:SetDescription(aux.Stringid(id,0)) e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
s.fusion_effect=true
function s.fcheck1(ct) ---@type FUSION_FGCHECK_FUNCTION
return function(tp,sg,fc) function s.additional_fcheck(tp,mg,fc,all_mg)
if ct>0 and sg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)>ct then --- material from extra deck by this fusion spell can not exceed monster opponent controls
return false local count_from_extra=mg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)
end local monster_count_of_opponet=Duel.GetMatchingGroupCount(aux.TRUE,tp,0,LOCATION_MZONE,nil)
return true if count_from_extra>monster_count_of_opponet then
end return false
end
function s.fcheck2(tp,sg,fc)
return sg:GetCount()>=3
end
function s.filter0(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove()
end
function s.filter2(c,e,tp,m,f,chkf)
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)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e)
local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)
if ct>0 then
local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_EXTRA,0,nil)
if mg2:GetCount()>0 then
mg:Merge(mg2)
end
end
aux.FCheckAdditional=s.fcheck1(ct)
aux.FGoalCheckAdditional=s.fcheck2
local res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg,nil,chkf)
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end
end
return res
end end
return true
end end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp ---@type FUSION_FGCHECK_FUNCTION
local mg1=Duel.GetFusionMaterial(tp):Filter(aux.NOT(Card.IsImmuneToEffect),nil,e) function s.additional_fgoalcheck(tp,mg,fc,all_mg)
local ct=Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE) return all_mg:GetCount()>=3
if ct>0 then end
local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_EXTRA,0,nil)
if mg2:GetCount()>0 then ---@type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
mg1:Merge(mg2) function s.stage_x_operation(e,tc,tp,stage,mg_fuison_spell,mg_all)
end if stage==FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE then
end local exmat=mg_fuison_spell:Filter(Card.IsPreviousLocation,nil,LOCATION_EXTRA)
aux.FCheckAdditional=s.fcheck1(ct)
aux.FGoalCheckAdditional=s.fcheck2
local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
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 tc then
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or ce and not Duel.SelectYesNo(tp,ce:GetDescription())) then
aux.FCheckAdditional=s.fcheck1(ct)
aux.FGoalCheckAdditional=s.fcheck2
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
tc:SetMaterial(mat1)
local rg=mat1:Filter(Card.IsLocation,nil,LOCATION_EXTRA)
mat1:Sub(rg)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.Remove(rg,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummonStep(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
elseif ce then
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
local exmat=tc:GetMaterial():Filter(Card.IsPreviousLocation,nil,LOCATION_EXTRA)
if #exmat>0 then if #exmat>0 then
local dam=exmat:GetSum(Card.GetAttack) local dam=exmat:GetSum(Card.GetAttack)
local lp=Duel.GetLP(tp) if dam>0 then
if lp>=dam then local lp=Duel.GetLP(tp)
Duel.SetLP(tp,lp-dam) if lp>=dam then
else Duel.SetLP(tp,lp-dam)
Duel.SetLP(tp,0) else
Duel.SetLP(tp,0)
end
end end
end end
Duel.SpecialSummonComplete()
tc:CompleteProcedure()
end end
aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil
end end
This diff is collapsed.
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