Commit 48e04da5 authored by Vury Leo's avatar Vury Leo Committed by wind2009

Add 堕天使 to new fusion + add skip_location_count_check to new fusion

parent 101089d7
--叛逆の堕天使 --叛逆の堕天使
function c54527349.initial_effect(c) local s,id,o=GetID()
function s.initial_effect(c)
--activate --activate
local e1=Effect.CreateEffect(c) local e1=FusionSpell.CreateSummonEffect(c,{
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) fusfilter=s.fusfilter,
e1:SetType(EFFECT_TYPE_ACTIVATE) extra_target=s.extra_target,
e1:SetCode(EVENT_FREE_CHAIN) stage_x_operation=s.stage_x_operation
})
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCountLimit(1,54527349+EFFECT_COUNT_CODE_OATH) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
e1:SetCost(c54527349.cost) e1:SetTarget(s.target)
e1:SetTarget(c54527349.target) e1:SetCost(s.cost)
e1:SetOperation(c54527349.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c54527349.filter1(c,e)
return not c:IsImmuneToEffect(e) function s.fusfilter(c)
return c:IsAttribute(ATTRIBUTE_DARK)
end end
function c54527349.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsAttribute(ATTRIBUTE_DARK) and (not f or f(c)) --- @param c Card
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) function s.costfilter(c,e,tp)
end if not (c:IsFaceupEx() and c:IsSetCard(0xef) and c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost()) then
function c54527349.costfilter(c,e,tp) return false
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp)
if mg1:IsContains(c) then mg1:RemoveCard(c) end
local res=Duel.IsExistingMatchingCard(c54527349.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)
if mg2:IsContains(c) then mg2:RemoveCard(c) end
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c54527349.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end end
local res_cell=Duel.GetLocationCountFromEx(tp,tp,c,TYPE_FUSION)
--- Create a temp fusion effect that can not use candidate cost monster as material, if we have a slot on field, skip the location count check
--- stage_x_operation omit as it is only called in operation
local fusion_effect=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
matfilter=function(mc) return mc~=c end,
extra_target=s.extra_target,
skip_location_count_check=(res_cell>0)
})
if fusion_effect:GetTarget()(e,tp,nil,nil,nil,nil,nil,nil,0)==false then
return false
end end
return (c:IsFaceup() or c:IsLocation(LOCATION_HAND)) and c:IsSetCard(0xef) and c:IsType(TYPE_MONSTER) and c:IsAbleToGraveAsCost() and res return true
end end
function c54527349.cost(e,tp,eg,ep,ev,re,r,rp,chk)
e:SetLabel(100,0) function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c54527349.costfilter,tp,LOCATION_HAND+LOCATION_MZONE,0,1,nil,e,tp) end if chk==0 then return Duel.IsExistingMatchingCard(s.costfilter,tp,LOCATION_HAND+LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c54527349.costfilter,tp,LOCATION_HAND+LOCATION_MZONE,0,1,1,nil,e,tp) local g=Duel.SelectMatchingCard(tp,s.costfilter,tp,LOCATION_HAND+LOCATION_MZONE,0,1,1,nil,e,tp)
e:SetLabel(100,g:GetFirst():GetAttack()) e:SetLabel(g:GetFirst():GetAttack())
Duel.SendtoGrave(g,REASON_COST) Duel.SendtoGrave(g,REASON_COST)
end end
function c54527349.target(e,tp,eg,ep,ev,re,r,rp,chk)
local label,rec=e:GetLabel() function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then if e:IsCostChecked() then
local chkf=tp --- cost could be paid, location count check done there
local mg1=Duel.GetFusionMaterial(tp) local fusion_effect_no_location_count_check=FusionSpell.CreateSummonEffect(e:GetHandler(),{
local res=Duel.IsExistingMatchingCard(c54527349.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) fusfilter=s.fusfilter,
if not res then extra_target=s.extra_target,
local ce=Duel.GetChainMaterial(tp) skip_location_count_check=true
if ce~=nil then })
local fgroup=ce:GetTarget() return fusion_effect_no_location_count_check:GetTarget()(e,tp,eg,ep,ev,re,r,rp,chk)
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c54527349.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
e:SetLabel(0,0)
return label==100 or res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
local cat=e:GetCategory()
if e:IsHasType(EFFECT_TYPE_ACTIVATE) and label==100 and rec>0 then
e:SetCategory(bit.bor(cat,CATEGORY_RECOVER))
else else
e:SetCategory(bit.band(cat,bit.bnot(CATEGORY_RECOVER))) --- cost bypassed, location count check done here
local fusion_effect_with_location_count_check=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
extra_target=s.extra_target,
skip_location_count_check=false
})
return fusion_effect_with_location_count_check:GetTarget()(e,tp,eg,ep,ev,re,r,rp,chk)
end end
end end
function c54527349.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
local mg1=Duel.GetFusionMaterial(tp):Filter(c54527349.filter1,nil,e) if chk==0 then
local sg1=Duel.GetMatchingGroup(c54527349.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) return true
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(c54527349.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local cat=e:GetCategory()
local sg=sg1:Clone() local rec=e:GetLabel()
if sg2 then sg:Merge(sg2) end if e:IsCostChecked() and rec>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) e:SetCategory(cat|CATEGORY_RECOVER)
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=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf) --- in case of copy, reset the label
local fop=ce:GetOperation() e:SetLabel(0)
fop(ce,e,tp,tc,mat2) e:SetCategory(cat&(~CATEGORY_RECOVER))
end end
tc:CompleteProcedure() end
local label,rec=e:GetLabel()
if e:IsHasType(EFFECT_TYPE_ACTIVATE) and label==100 and rec>0 and Duel.SelectYesNo(tp,aux.Stringid(54527349,0)) then --- @type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
function s.stage_x_operation(e,tc,tp,stage)
if stage==FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH then
local rec=e:GetLabel()
if rec>0 and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then
Duel.BreakEffect() Duel.BreakEffect()
Duel.Recover(tp,rec,REASON_EFFECT) Duel.Recover(tp,rec,REASON_EFFECT)
e:SetLabel(0)
end end
end end
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