Commit bfd70c74 authored by Vury Leo's avatar Vury Leo Committed by wind2009

Add 暗黒界の登極 to new fusion + add Discard operation to proc

parent cb01adad
--暗黒界の登極
function c65956182.initial_effect(c)
local s,id,o=GetID()
function s.initial_effect(c)
--fusion summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(65956182,0))
local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter,
pre_select_mat_location=s.pre_select_mat_location,
mat_operation_code_map={
{ [LOCATION_REMOVED]=FusionSpell.FUSION_OPERATION_GRAVE },
{ [LOCATION_HAND]=FusionSpell.FUSION_OPERATION_DISCARD },
{ [0xff]=FusionSpell.FUSION_OPERATION_BANISH }
},
extra_target=s.extra_target
})
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_REMOVE+CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_HANDES)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,65956182)
e1:SetCondition(c65956182.condition)
e1:SetTarget(c65956182.target)
e1:SetOperation(c65956182.activate)
e1:SetCountLimit(1,id)
e1:SetCondition(s.condition)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(65956182,1))
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TOHAND+CATEGORY_HANDES)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,65956183)
e2:SetTarget(c65956182.thtg)
e2:SetOperation(c65956182.thop)
e2:SetCountLimit(1,id+o)
e2:SetTarget(s.thtg)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
end
function c65956182.condition(e,tp,eg,ep,ev,re,r,rp)
function s.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()&(PHASE_MAIN1+PHASE_MAIN2)>0
end
function c65956182.filter1(c,e)
return c:IsAbleToRemove() and not c:IsImmuneToEffect(e) and c:IsLocation(LOCATION_ONFIELD)
function s.fusfilter(c)
return c:IsRace(RACE_FIEND)
end
function c65956182.filter2(c,e,tp,mg1,dm,f,chkf)
local mg=mg1:Clone()
if c:IsSetCard(0x6) then
mg:Merge(dm)
--- @type FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION
function s.pre_select_mat_location(tc,tp)
local location=LOCATION_MZONE|LOCATION_GRAVE
if tc:IsSetCard(0x6) then
location=location|LOCATION_HAND
end
return c:IsType(TYPE_FUSION) and c:IsRace(RACE_FIEND) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(mg,nil,chkf)
return location
end
function c65956182.filter3(c,e)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove() and not c:IsImmuneToEffect(e)
end
function c65956182.filter4(c,e)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsDiscardable() and not c:IsImmuneToEffect(e)
end
function c65956182.target(e,tp,eg,ep,ev,re,r,rp,chk)
function s.extra_target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c65956182.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(c65956182.filter3,tp,LOCATION_GRAVE,0,nil,e)
local dg=Duel.GetMatchingGroup(c65956182.filter4,tp,LOCATION_HAND,0,nil,e)
mg1:Merge(mg2)
local res=Duel.IsExistingMatchingCard(c65956182.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,dg,nil,chkf)
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(c65956182.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,dg,mf,chkf)
end
end
return res
return true
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_ONFIELD+LOCATION_GRAVE)
end
function c65956182.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c65956182.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(c65956182.filter3,tp,LOCATION_GRAVE,0,nil,e)
local dg=Duel.GetMatchingGroup(c65956182.filter4,tp,LOCATION_HAND,0,nil,e)
mg1:Merge(mg2)
local sg1=Duel.GetMatchingGroup(c65956182.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,dg,nil,chkf)
local mg3=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c65956182.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,dg,mf,chkf)
end
if #sg1>0 or (sg2~=nil and #sg2>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
if tc:IsSetCard(0x6) then mg1:Merge(dg) end
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
for gc in aux.Next(mat1) do
if gc:IsLocation(LOCATION_HAND) then
Duel.SendtoGrave(gc,REASON_EFFECT+REASON_DISCARD+REASON_FUSION+REASON_MATERIAL)
else
Duel.Remove(gc,POS_FACEUP,REASON_EFFECT+REASON_FUSION+REASON_MATERIAL)
end
end
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
function c65956182.thfilter(c)
function s.thfilter(c)
return c:IsDiscardable() and c:IsType(TYPE_MONSTER) and c:IsSetCard(0x6)
end
function c65956182.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToHand()
and Duel.IsExistingMatchingCard(c65956182.thfilter,tp,LOCATION_HAND,0,1,nil) end
and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,c,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1)
end
function c65956182.thop(e,tp,eg,ep,ev,re,r,rp)
function s.thop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and Duel.SendtoHand(c,nil,REASON_EFFECT)>0 then
Duel.ShuffleHand(tp)
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD)
Duel.DiscardHand(tp,c65956182.thfilter,1,1,REASON_EFFECT+REASON_DISCARD)
Duel.DiscardHand(tp,s.thfilter,1,1,REASON_EFFECT+REASON_DISCARD)
end
end
......@@ -2980,6 +2980,7 @@ FusionSpell.FUSION_OPERATION_BANISH_FACEDOWN=0x3
FusionSpell.FUSION_OPERATION_SHUFFLE=0x4
FusionSpell.FUSION_OPERATION_DECK_BOTTOM=0x5
FusionSpell.FUSION_OPERATION_DESTROY=0x6
FusionSpell.FUSION_OPERATION_DISCARD=0x7
---@return FUSION_OPERATION_FUNCTION
function FusionSpell.GetFusionOperationByCode(code,matlocation,fusion_spell_operation_code_map)
......@@ -2995,6 +2996,8 @@ function FusionSpell.GetFusionOperationByCode(code,matlocation,fusion_spell_oper
return FusionSpell.SendDeckBottomMaterial
elseif code==FusionSpell.FUSION_OPERATION_DESTROY then
return FusionSpell.DestroyMaterial
elseif code==FusionSpell.FUSION_OPERATION_DISCARD then
return FusionSpell.DiscardMaterial
elseif code&FusionSpell.FUSION_OPERATION_INHERIT==FusionSpell.FUSION_OPERATION_INHERIT then
local inhreit_as=code&(~FusionSpell.FUSION_OPERATION_INHERIT)&0xff --- 0xff is LOCATION_ALL
if inhreit_as~=0 then
......@@ -3025,6 +3028,8 @@ function FusionSpell.GetFusionFilterByCode(code,matlocation,fusion_spell_operati
return FusionSpell.SendDeckBottomMaterialFilter
elseif code==FusionSpell.FUSION_OPERATION_DESTROY then
return FusionSpell.DestroyMaterialFilter
elseif code==FusionSpell.FUSION_OPERATION_DISCARD then
return FusionSpell.DiscardMaterialFilter
elseif code&FusionSpell.FUSION_OPERATION_INHERIT==FusionSpell.FUSION_OPERATION_INHERIT then
local inhreit_as=code&(~FusionSpell.FUSION_OPERATION_INHERIT)&0xff --- 0xff is LOCATION_ALL
if inhreit_as~=0 then
......@@ -3044,16 +3049,6 @@ end
---@alias FUSION_OPERATION_FUNCTION fun(sg:Card|Group,tp:integer):integer
---@alias FUSION_FILTER_FUNCTION fun(c:Card,tp:integer?,e:Effect?):boolean
---@type FUSION_OPERATION_FUNCTION
function FusionSpell.DestroyMaterial(sg,tp)
return Duel.Destroy(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,nil,tp)
end
---@type FUSION_FILTER_FUNCTION
function FusionSpell.DestroyMaterialFilter(c,tp,e)
return c:IsDestructable(e)
end
---@type FUSION_OPERATION_FUNCTION
function FusionSpell.GraveMaterial(sg,tp)
return Duel.SendtoGrave(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,tp)
......@@ -3105,6 +3100,26 @@ function FusionSpell.SendDeckBottomMaterialFilter(c)
return c:IsAbleToDeck()
end
---@type FUSION_OPERATION_FUNCTION
function FusionSpell.DestroyMaterial(sg,tp)
return Duel.Destroy(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,nil,tp)
end
---@type FUSION_FILTER_FUNCTION
function FusionSpell.DestroyMaterialFilter(c,tp,e)
return c:IsDestructable(e)
end
---@type FUSION_OPERATION_FUNCTION
function FusionSpell.DiscardMaterial(sg,tp)
return Duel.SendtoGrave(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION+REASON_DISCARD,tp)
end
---@type FUSION_FILTER_FUNCTION
function FusionSpell.DiscardMaterialFilter(c)
return c:IsDiscardable(REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
end
--Returns a list of effect, if element is the EFFECT_EXTRA_FUSION_MATERIAL, stands for it can be included by that extra material effect.
--if element is true, stands for it can be included by the fusion effect itself.
---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials
......
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