Commit 27ffa9d1 authored by Vury Leo's avatar Vury Leo

fix 融合解除

parent c198a77a
--融合解除 --融合解除
function c95286165.initial_effect(c) local s,id,o=GetID()
function s.initial_effect(c)
--Activate --Activate
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOEXTRA+CATEGORY_SPECIAL_SUMMON+CATEGORY_GRAVE_SPSUMMON) e1:SetCategory(CATEGORY_TOEXTRA+CATEGORY_SPECIAL_SUMMON+CATEGORY_GRAVE_SPSUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN) e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c95286165.target) e1:SetTarget(s.target)
e1:SetOperation(c95286165.activate) e1:SetOperation(s.activate)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c95286165.filter(c) function s.filter(c)
return c:IsFaceup() and c:IsType(TYPE_FUSION) and c:IsAbleToExtra() return c:IsFaceup() and c:IsType(TYPE_FUSION) and c:IsAbleToExtra()
end end
function c95286165.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c95286165.filter(chkc) end if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c95286165.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c95286165.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) local g=Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOEXTRA,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOEXTRA,g,1,0,0)
end end
function c95286165.mgfilter(c,e,tp,fusc,mg) function s.mgfilter(c,e,tp,fusc)
return c:IsControler(tp) and c:IsLocation(LOCATION_GRAVE) return c:IsControler(tp) and c:IsLocation(LOCATION_GRAVE)
and c:GetReason()&(REASON_FUSION+REASON_MATERIAL)==(REASON_FUSION+REASON_MATERIAL) and c:GetReasonCard()==fusc and c:GetReason()&(REASON_FUSION+REASON_MATERIAL)==(REASON_FUSION+REASON_MATERIAL) and c:GetReasonCard()==fusc
and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and fusc:CheckFusionMaterial(mg,c,PLAYER_NONE,true)
end end
function c95286165.activate(e,tp,eg,ep,ev,re,r,rp) function s.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if not (tc:IsRelateToEffect(e) and tc:IsFaceup()) then return end if not (tc:IsRelateToEffect(e) and tc:IsFaceup()) then return end
local mg=tc:GetMaterial() local mg=tc:GetMaterial()
...@@ -35,8 +35,9 @@ function c95286165.activate(e,tp,eg,ep,ev,re,r,rp) ...@@ -35,8 +35,9 @@ function c95286165.activate(e,tp,eg,ep,ev,re,r,rp)
and tc:IsSummonType(SUMMON_TYPE_FUSION) and tc:IsSummonType(SUMMON_TYPE_FUSION)
and ct>0 and ct<=Duel.GetLocationCount(tp,LOCATION_MZONE) and ct>0 and ct<=Duel.GetLocationCount(tp,LOCATION_MZONE)
and (not Duel.IsPlayerAffectedByEffect(tp,59822133) or ct==1) and (not Duel.IsPlayerAffectedByEffect(tp,59822133) or ct==1)
and mg:FilterCount(aux.NecroValleyFilter(c95286165.mgfilter),nil,e,tp,tc,mg)==ct and mg:FilterCount(aux.NecroValleyFilter(s.mgfilter),nil,e,tp,tc)==ct
and Duel.SelectYesNo(tp,aux.Stringid(95286165,0)) then and Fusion.CheckFusionMaterial(tc,mg,nil,PLAYER_NONE,{allow_extras=false,slots_only=true})
and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then
Duel.BreakEffect() Duel.BreakEffect()
Duel.SpecialSummon(mg,0,tp,tp,false,false,POS_FACEUP) Duel.SpecialSummon(mg,0,tp,tp,false,false,POS_FACEUP)
end end
......
...@@ -2946,7 +2946,7 @@ function FusionSpell.SummonTargetFilter( ...@@ -2946,7 +2946,7 @@ function FusionSpell.SummonTargetFilter(
Fusion.LockedCodes=locked_codes Fusion.LockedCodes=locked_codes
end end
local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check)
local res=c:CheckFusionMaterial(mg,gc(e),chkf) local res=Fusion.CheckFusionMaterial(c,mg,gc(e),chkf)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil aux.FGoalCheckAdditional=nil
Fusion.LockedCodes=nil Fusion.LockedCodes=nil
...@@ -3032,7 +3032,7 @@ function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additio ...@@ -3032,7 +3032,7 @@ function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additio
Fusion.LockedCodes=locked_codes Fusion.LockedCodes=locked_codes
end end
local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check)
local res=c:CheckFusionMaterial(mg,gc(e),chkf) local res=Fusion.CheckFusionMaterial(c,mg,gc(e),chkf)
aux.FCheckAdditional=nil aux.FCheckAdditional=nil
aux.FGoalCheckAdditional=nil aux.FGoalCheckAdditional=nil
Fusion.LockedCodes=nil Fusion.LockedCodes=nil
...@@ -3464,12 +3464,13 @@ function Fusion.AddFusionProcedure(c, opts) ...@@ -3464,12 +3464,13 @@ function Fusion.AddFusionProcedure(c, opts)
end end
--=== Effect registration ===-- --=== Effect registration ===--
local e = Effect.CreateEffect(c) local e=Effect.CreateEffect(c)
e:SetType(EFFECT_TYPE_SINGLE) e:SetType(EFFECT_TYPE_SINGLE)
e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e:SetCode(EFFECT_FUSION_MATERIAL) e:SetCode(EFFECT_FUSION_MATERIAL)
e:SetCondition(Fusion.FusionCondition(c,patterns)) e:SetCondition(Fusion.FusionCondition(c,patterns))
e:SetOperation(Fusion.FusionOperation(c,patterns)) e:SetOperation(Fusion.FusionOperation(c,patterns))
e:SetRange(LOCATION_EXTRA)
e:SetDescription(1379) e:SetDescription(1379)
c:RegisterEffect(e) c:RegisterEffect(e)
end end
...@@ -4373,14 +4374,14 @@ function Fusion.BuildPatterns(opts) ...@@ -4373,14 +4374,14 @@ function Fusion.BuildPatterns(opts)
for _, v in ipairs(opts.variants) do for _, v in ipairs(opts.variants) do
table.insert(patterns,{ table.insert(patterns,{
slots=v.slots, slots=v.slots,
matfilter=v.matfilter, matfilter=v.matfilter or aux.TRUE,
fgoalcheck=v.fgoalcheck or aux.TRUE, fgoalcheck=v.fgoalcheck or aux.TRUE,
}) })
end end
else else
table.insert(patterns,{ table.insert(patterns,{
slots=opts.slots, slots=opts.slots,
matfilter=opts.matfilter, matfilter=opts.matfilter or aux.TRUE,
fgoalcheck=opts.fgoalcheck or aux.TRUE, fgoalcheck=opts.fgoalcheck or aux.TRUE,
}) })
end end
...@@ -4389,7 +4390,7 @@ end ...@@ -4389,7 +4390,7 @@ end
-- Helper: combine multiple patterns into one condition function -- Helper: combine multiple patterns into one condition function
function Fusion.MultiCondition(tc,patterns) function Fusion.MultiCondition(tc,patterns)
return function(e,g,gc,chkf,selected,allow_extras) return function(e,g,gc,chkf,selected,allow_extras,slots_only)
if not g then return false end if not g then return false end
local locked=Fusion.LockedCodes local locked=Fusion.LockedCodes
for _,pat in ipairs(patterns) do for _,pat in ipairs(patterns) do
...@@ -4404,10 +4405,17 @@ function Fusion.MultiCondition(tc,patterns) ...@@ -4404,10 +4405,17 @@ function Fusion.MultiCondition(tc,patterns)
end end
end end
if ok then if ok then
if not slots_only then
local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,selected) local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,selected)
if cond(e,g,gc,chkf,allow_extras) then if cond(e,g,gc,chkf,allow_extras) then
return true return true
end end
else
local cond=Fusion.BasicCondition(tc,pat.slots,aux.TRUE,aux.TRUE,selected)
if cond(e,g,gc,chkf,allow_extras) then
return true
end
end
end end
end end
return false return false
...@@ -4474,7 +4482,7 @@ function Fusion.MultiOperation(tc,patterns) ...@@ -4474,7 +4482,7 @@ function Fusion.MultiOperation(tc,patterns)
end end
while true do while true do
local finishable=sg:GetCount()>=min_req and cond(e,sg,gc,chkf,false--[[allow_extras]]) local finishable=sg:GetCount()>=min_req and cond(e,sg,gc,chkf,selected,false--[[allow_extras]])
local addable=Group.CreateGroup() local addable=Group.CreateGroup()
-- check fcheck on the *current* sg -- check fcheck on the *current* sg
...@@ -4555,13 +4563,16 @@ end ...@@ -4555,13 +4563,16 @@ end
--- @param tc Card --- @param tc Card
--- @param patterns table[] --- @param patterns table[]
function Fusion.FusionCondition(tc,patterns) function Fusion.FusionCondition(tc,patterns)
return function(e,g,gc,chkf,opts) return function(e,g,gc,chkf,opts,not_core)
--- to bypass core check showing up in Card.IsHasEffect, we need this hack, used in Fusion.CheckFusionMaterial
if not_core==nil then return true end
if not g then return false end if not g then return false end
opts=opts or {} opts=opts or {}
local allow_extras=true local allow_extras=true
if opts.allow_extras==false then if opts.allow_extras==false then
allow_extras=false allow_extras=false
end end
local slots_only=opts.slots_only or false
-- build your seed group -- build your seed group
local selected=Group.CreateGroup() local selected=Group.CreateGroup()
if gc then selected:AddCard(gc) end if gc then selected:AddCard(gc) end
...@@ -4592,7 +4603,7 @@ function Fusion.FusionCondition(tc,patterns) ...@@ -4592,7 +4603,7 @@ function Fusion.FusionCondition(tc,patterns)
end end
else else
-- attempt "strict mode" -- attempt "strict mode"
if Fusion.MultiCondition(tc,patterns)(e,g,gc,chkf,allow_extras) then if Fusion.MultiCondition(tc,patterns)(e,g,gc,chkf,selected,allow_extras,slots_only) then
return true return true
end end
end end
...@@ -4600,7 +4611,6 @@ function Fusion.FusionCondition(tc,patterns) ...@@ -4600,7 +4611,6 @@ function Fusion.FusionCondition(tc,patterns)
end end
end end
function Fusion.FusionOperation(c,patterns) function Fusion.FusionOperation(c,patterns)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkf) return function(e,tp,eg,ep,ev,re,r,rp,gc,chkf)
-- build selected = {gc} -- build selected = {gc}
...@@ -4613,3 +4623,15 @@ function Fusion.FusionOperation(c,patterns) ...@@ -4613,3 +4623,15 @@ function Fusion.FusionOperation(c,patterns)
return Fusion.MultiOperation(c,patterns)(e,tp,eg,ep,ev,re,r,rp,gc,chkf,selected) return Fusion.MultiOperation(c,patterns)(e,tp,eg,ep,ev,re,r,rp,gc,chkf,selected)
end end
end end
--- shadowing Card.CheckFusionMaterial as it core does not pass all param back to lua
function Fusion.CheckFusionMaterial(tc,mg,gc,chkf,opts)
opts=opts or {}
local effs={tc:IsHasEffect(EFFECT_FUSION_MATERIAL,tc:GetOwner())}
for _,eff in ipairs(effs) do
if eff:GetCondition()(eff,mg,gc,chkf,opts,true) then
return true
end
end
return false
end
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