Commit 47840bc7 authored by wind2009's avatar wind2009

Merge branch 'new-fusion-Darklord' into 'master'

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

See merge request !44
parents 101089d7 48e04da5
--叛逆の堕天使 --叛逆の堕天使
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 end
local mg1=Duel.GetFusionMaterial(tp) local res_cell=Duel.GetLocationCountFromEx(tp,tp,c,TYPE_FUSION)
if mg1:IsContains(c) then mg1:RemoveCard(c) end --- 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
local res=Duel.IsExistingMatchingCard(c54527349.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) --- stage_x_operation omit as it is only called in operation
if not res then local fusion_effect=FusionSpell.CreateSummonEffect(e:GetHandler(),{
local ce=Duel.GetChainMaterial(tp) fusfilter=s.fusfilter,
if ce~=nil then matfilter=function(mc) return mc~=c end,
local fgroup=ce:GetTarget() extra_target=s.extra_target,
local mg2=fgroup(ce,e,tp) skip_location_count_check=(res_cell>0)
if mg2:IsContains(c) then mg2:RemoveCard(c) end })
local mf=ce:GetValue() if fusion_effect:GetTarget()(e,tp,nil,nil,nil,nil,nil,nil,0)==false then
res=Duel.IsExistingMatchingCard(c54527349.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf) return false
end
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 e:IsCostChecked() then
--- cost could be paid, location count check done there
local fusion_effect_no_location_count_check=FusionSpell.CreateSummonEffect(e:GetHandler(),{
fusfilter=s.fusfilter,
extra_target=s.extra_target,
skip_location_count_check=true
})
return fusion_effect_no_location_count_check:GetTarget()(e,tp,eg,ep,ev,re,r,rp,chk)
else
--- 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
function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then if chk==0 then
local chkf=tp return true
local mg1=Duel.GetFusionMaterial(tp)
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)
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 end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
local cat=e:GetCategory() local cat=e:GetCategory()
if e:IsHasType(EFFECT_TYPE_ACTIVATE) and label==100 and rec>0 then local rec=e:GetLabel()
e:SetCategory(bit.bor(cat,CATEGORY_RECOVER)) if e:IsCostChecked() and rec>0 then
e:SetCategory(cat|CATEGORY_RECOVER)
else else
e:SetCategory(bit.band(cat,bit.bnot(CATEGORY_RECOVER))) --- in case of copy, reset the label
e:SetLabel(0)
e:SetCategory(cat&(~CATEGORY_RECOVER))
end end
end end
function c54527349.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp --- @type FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION
local mg1=Duel.GetFusionMaterial(tp):Filter(c54527349.filter1,nil,e) function s.stage_x_operation(e,tc,tp,stage)
local sg1=Duel.GetMatchingGroup(c54527349.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) if stage==FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH then
local mg2=nil local rec=e:GetLabel()
local sg2=nil if rec>0 and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then
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
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
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=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
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
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
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