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
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOEXTRA+CATEGORY_SPECIAL_SUMMON+CATEGORY_GRAVE_SPSUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c95286165.target)
e1:SetOperation(c95286165.activate)
e1:SetTarget(s.target)
e1:SetOperation(s.activate)
c:RegisterEffect(e1)
end
function c95286165.filter(c)
function s.filter(c)
return c:IsFaceup() and c:IsType(TYPE_FUSION) and c:IsAbleToExtra()
end
function c95286165.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 chk==0 then return Duel.IsExistingTarget(c95286165.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc) 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)
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)
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)
and c:GetReason()&(REASON_FUSION+REASON_MATERIAL)==(REASON_FUSION+REASON_MATERIAL) and c:GetReasonCard()==fusc
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and fusc:CheckFusionMaterial(mg,c,PLAYER_NONE,true)
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()
if not (tc:IsRelateToEffect(e) and tc:IsFaceup()) then return end
local mg=tc:GetMaterial()
......@@ -35,8 +35,9 @@ function c95286165.activate(e,tp,eg,ep,ev,re,r,rp)
and tc:IsSummonType(SUMMON_TYPE_FUSION)
and ct>0 and ct<=Duel.GetLocationCount(tp,LOCATION_MZONE)
and (not Duel.IsPlayerAffectedByEffect(tp,59822133) or ct==1)
and mg:FilterCount(aux.NecroValleyFilter(c95286165.mgfilter),nil,e,tp,tc,mg)==ct
and Duel.SelectYesNo(tp,aux.Stringid(95286165,0)) then
and mg:FilterCount(aux.NecroValleyFilter(s.mgfilter),nil,e,tp,tc)==ct
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.SpecialSummon(mg,0,tp,tp,false,false,POS_FACEUP)
end
......
......@@ -2946,7 +2946,7 @@ function FusionSpell.SummonTargetFilter(
Fusion.LockedCodes=locked_codes
end
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.FGoalCheckAdditional=nil
Fusion.LockedCodes=nil
......@@ -3032,7 +3032,7 @@ function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additio
Fusion.LockedCodes=locked_codes
end
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.FGoalCheckAdditional=nil
Fusion.LockedCodes=nil
......@@ -3464,12 +3464,13 @@ function Fusion.AddFusionProcedure(c, opts)
end
--=== Effect registration ===--
local e = Effect.CreateEffect(c)
local e=Effect.CreateEffect(c)
e:SetType(EFFECT_TYPE_SINGLE)
e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e:SetCode(EFFECT_FUSION_MATERIAL)
e:SetCondition(Fusion.FusionCondition(c,patterns))
e:SetOperation(Fusion.FusionOperation(c,patterns))
e:SetRange(LOCATION_EXTRA)
e:SetDescription(1379)
c:RegisterEffect(e)
end
......@@ -4373,14 +4374,14 @@ function Fusion.BuildPatterns(opts)
for _, v in ipairs(opts.variants) do
table.insert(patterns,{
slots=v.slots,
matfilter=v.matfilter,
matfilter=v.matfilter or aux.TRUE,
fgoalcheck=v.fgoalcheck or aux.TRUE,
})
end
else
table.insert(patterns,{
slots=opts.slots,
matfilter=opts.matfilter,
matfilter=opts.matfilter or aux.TRUE,
fgoalcheck=opts.fgoalcheck or aux.TRUE,
})
end
......@@ -4389,7 +4390,7 @@ end
-- Helper: combine multiple patterns into one condition function
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
local locked=Fusion.LockedCodes
for _,pat in ipairs(patterns) do
......@@ -4404,9 +4405,16 @@ function Fusion.MultiCondition(tc,patterns)
end
end
if ok then
local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,selected)
if cond(e,g,gc,chkf,allow_extras) then
return true
if not slots_only then
local cond=Fusion.BasicCondition(tc,pat.slots,pat.matfilter,pat.fgoalcheck,selected)
if cond(e,g,gc,chkf,allow_extras) then
return true
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
......@@ -4474,7 +4482,7 @@ function Fusion.MultiOperation(tc,patterns)
end
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()
-- check fcheck on the *current* sg
......@@ -4555,13 +4563,16 @@ end
--- @param tc Card
--- @param patterns table[]
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
opts=opts or {}
local allow_extras=true
if opts.allow_extras==false then
allow_extras=false
end
local slots_only=opts.slots_only or false
-- build your seed group
local selected=Group.CreateGroup()
if gc then selected:AddCard(gc) end
......@@ -4592,7 +4603,7 @@ function Fusion.FusionCondition(tc,patterns)
end
else
-- 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
end
end
......@@ -4600,7 +4611,6 @@ function Fusion.FusionCondition(tc,patterns)
end
end
function Fusion.FusionOperation(c,patterns)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkf)
-- build selected = {gc}
......@@ -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)
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