Commit 673accbe authored by mercury233's avatar mercury233 Committed by GitHub

xyz summon using alter mat can be canceled (#2044)

parent 45f4ef3e
......@@ -686,7 +686,8 @@ function Auxiliary.TuneMagicianCheckAdditionalX(ecode)
end
end
function Auxiliary.XyzAlterFilter(c,alterf,xyzc,e,tp,alterop)
return alterf(c) and c:IsCanBeXyzMaterial(xyzc) and Duel.GetLocationCountFromEx(tp,tp,c,xyzc)>0 and Auxiliary.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) and (not alterop or alterop(e,tp,0,c))
return alterf(c) and c:IsCanBeXyzMaterial(xyzc) and Duel.GetLocationCountFromEx(tp,tp,c,xyzc)>0
and Auxiliary.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) and (not alterop or alterop(e,tp,0,c))
end
--Xyz monster, lv k*n
function Auxiliary.AddXyzProcedure(c,f,lv,ct,alterf,alterdesc,maxct,alterop)
......@@ -816,14 +817,19 @@ function Auxiliary.XyzTargetAlter(f,lv,minc,maxc,alterf,alterdesc,alterop)
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop)
local b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
local b2=(not min or min<=1) and mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,alterop)
local b2=(not min or min<=1) and #altg>0
local g=nil
local cancel=Duel.IsSummonCancelable()
if b2 and (not b1 or Duel.SelectYesNo(tp,alterdesc)) then
e:SetLabel(1)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
g=mg:FilterSelect(tp,Auxiliary.XyzAlterFilter,1,1,nil,alterf,c,e,tp,alterop)
if alterop then alterop(e,tp,1,g:GetFirst()) end
local tc=altg:SelectUnselect(nil,tp,false,cancel,1,1)
if tc then
g=Group.FromCards(tc)
if alterop then alterop(e,tp,1,tc) end
end
else
e:SetLabel(0)
g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc,og)
......@@ -1003,7 +1009,7 @@ function Auxiliary.XyzLevelFreeConditionAlter(f,gf,minct,maxct,alterf,alterdesc,
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop):Filter(Auxiliary.MustMaterialCheck,nil,tp,EFFECT_MUST_BE_XMATERIAL)
local altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop)
if (not min or min<=1) and altg:GetCount()>0 then
return true
end
......@@ -1042,21 +1048,25 @@ function Auxiliary.XyzLevelFreeTargetAlter(f,gf,minct,maxct,alterf,alterdesc,alt
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
local sg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL)
local altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop)
local mg2=mg:Filter(Auxiliary.XyzLevelFreeFilter,nil,c,f)
Duel.SetSelectedCard(sg)
local b1=mg2:CheckSubGroup(Auxiliary.XyzLevelFreeGoal,minc,maxc,tp,c,gf)
local b2=(not min or min<=1) and mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,alterop)
local b2=(not min or min<=1) and #altg>0
local g=nil
local cancel=Duel.IsSummonCancelable()
if b2 and (not b1 or Duel.SelectYesNo(tp,alterdesc)) then
e:SetLabel(1)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
g=mg:FilterSelect(tp,Auxiliary.XyzAlterFilter,1,1,nil,alterf,c,e,tp,alterop)
if alterop then alterop(e,tp,1,g:GetFirst()) end
local tc=altg:SelectUnselect(nil,tp,false,cancel,1,1)
if tc then
g=Group.FromCards(tc)
if alterop then alterop(e,tp,1,tc) end
end
else
e:SetLabel(0)
Duel.SetSelectedCard(sg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local cancel=Duel.IsSummonCancelable()
Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
g=mg2:SelectSubGroup(tp,Auxiliary.XyzLevelFreeGoal,cancel,minc,maxc,tp,c,gf)
Auxiliary.GCheckAdditional=nil
......
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