Commit 9f9bc48f authored by wind2009's avatar wind2009

Merge branch 'new-fusion-post-opponent' into 'master'

Add Defense of the Temple to new fusion + add post_select_mat_opponent_location to procedure

See merge request !50
parents 0b073d96 2ab2ad5f
...@@ -4,7 +4,8 @@ function s.initial_effect(c) ...@@ -4,7 +4,8 @@ function s.initial_effect(c)
--Activate --Activate
local e1=FusionSpell.CreateSummonEffect(c,{ local e1=FusionSpell.CreateSummonEffect(c,{
fusfilter=s.fusfilter, fusfilter=s.fusfilter,
pre_select_mat_opponent_location=LOCATION_MZONE, post_select_mat_opponent_location=LOCATION_MZONE,
fusion_spell_matfilter=s.fusion_spell_matfilter,
additional_fcheck=s.fcheck additional_fcheck=s.fcheck
}) })
e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH)
...@@ -16,6 +17,14 @@ function s.fusfilter(c) ...@@ -16,6 +17,14 @@ function s.fusfilter(c)
return c:IsRace(RACE_CYBERSE) return c:IsRace(RACE_CYBERSE)
end end
function s.fusion_spell_matfilter(c,e,tp)
--- if it comes from opponent, it must be a link monster
if c:IsControler(1-tp) and not c:IsType(TYPE_LINK) then
return false
end
return true
end
---@type FUSION_FGCHECK_FUNCTION ---@type FUSION_FGCHECK_FUNCTION
function s.fcheck(tp,mg,fc,mg_all) function s.fcheck(tp,mg,fc,mg_all)
-- Filter the group to get only the opponent’s Fusion Materials -- Filter the group to get only the opponent’s Fusion Materials
...@@ -25,12 +34,7 @@ function s.fcheck(tp,mg,fc,mg_all) ...@@ -25,12 +34,7 @@ function s.fcheck(tp,mg,fc,mg_all)
if #mg_opponent>1 then if #mg_opponent>1 then
return false return false
end end
-- Any opponent material used must be a LINK monster -- If using an opponent’s monster, you must also use at least one @イグニスター monster belongs to you
---@param c Card
if mg_opponent:IsExists(function(c) return not c:IsType(TYPE_LINK) end,1,nil) then
return false
end
-- If using an opponent’s monster, you must also use at least one “@Ignister” monster you control
---@param c Card ---@param c Card
if #mg_opponent>0 and not mg_all:IsExists(function(c) if #mg_opponent>0 and not mg_all:IsExists(function(c)
return c:IsControler(tp) and c:IsFusionSetCard(0x135) return c:IsControler(tp) and c:IsFusionSetCard(0x135)
......
...@@ -3,12 +3,11 @@ local s,id,o=GetID() ...@@ -3,12 +3,11 @@ local s,id,o=GetID()
function s.initial_effect(c) function s.initial_effect(c)
aux.AddCodeList(c,29762407,22082432) aux.AddCodeList(c,29762407,22082432)
--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) post_select_mat_opponent_location=LOCATION_MZONE,
e1:SetCode(EVENT_FREE_CHAIN) additional_fcheck=s.fcheck
e1:SetTarget(s.target) })
e1:SetOperation(s.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
--search --search
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
...@@ -23,93 +22,39 @@ function s.initial_effect(c) ...@@ -23,93 +22,39 @@ function s.initial_effect(c)
e2:SetOperation(s.thop) e2:SetOperation(s.thop)
c:RegisterEffect(e2) c:RegisterEffect(e2)
end end
function s.filter0(c)
return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToGrave() function s.fusfilter(c)
return c:IsAttribute(ATTRIBUTE_EARTH)
end end
function s.filter1(c,e)
return not c:IsImmuneToEffect(e) ---@type FUSION_FGCHECK_FUNCTION
end function s.fcheck(tp,mg,fc,mg_all)
function s.filter2(c,e,tp,m,f,chkf) -- Filter the group to get only the opponent’s Fusion Materials
if not (c:IsType(TYPE_FUSION) and c:IsAttribute(ATTRIBUTE_EARTH) and (not f or f(c)) ---@param c Card
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false)) then return false end local mg_opponent=mg:Filter(function(c) return c:IsControler(1-tp) end,nil)
aux.FCheckAdditional=s.fcheck -- If using an opponent’s monster, you must also use at least one monster mentioned "Temple of the Kings" you control
local res=c:CheckFusionMaterial(m,nil,chkf) ---@param c Card
aux.FCheckAdditional=nil if #mg_opponent>0 and not mg_all:IsExists(function(c)
return res return c:IsControler(tp) and aux.IsCodeListed(c,29762407)==true and c:IsOnField()
end end,1,nil) then
function s.ffilter(c,tp) return false
return aux.IsCodeListed(c,29762407) and c:IsControler(tp) and c:IsOnField()
end
function s.fcheck(tp,sg,fc)
return not sg:IsExists(Card.IsControler,1,nil,1-tp) or sg:IsExists(s.ffilter,1,nil,tp)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(s.filter0,tp,0,LOCATION_MZONE,nil)
mg1:Merge(mg2)
local res=Duel.IsExistingMatchingCard(s.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 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
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(s.filter0,tp,0,LOCATION_MZONE,nil):Filter(s.filter1,nil,e)
mg1:Merge(mg2)
local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,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(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,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 ce and not Duel.SelectYesNo(tp,ce:GetDescription())) then
aux.FCheckAdditional=tc.branded_fusion_check or s.fcheck
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
aux.FCheckAdditional=nil
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)
elseif ce then
local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end end
return true
end end
function s.thcon(e,tp,eg,ep,ev,re,r,rp,chk) function s.thcon(e,tp,eg,ep,ev,re,r,rp,chk)
return Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceupEx,Card.IsCode),tp,LOCATION_ONFIELD,0,1,nil,29762407) return Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceupEx,Card.IsCode),tp,LOCATION_ONFIELD,0,1,nil,29762407)
end end
function s.thfilter(c) function s.thfilter(c)
return c:IsCode(22082432) and c:IsAbleToHand() return c:IsCode(22082432) and c:IsAbleToHand()
end end
function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end end
function s.thop(e,tp,eg,ep,ev,re,r,rp) function s.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil) local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil)
......
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