Commit 209c6457 authored by mercury233's avatar mercury233

add EFFECT_TREAT_AS_2_XMATERIAL

parent 1afd1fca
--紋章獣グリフォン
--not fully implemented
local s,id,o=GetID()
function s.initial_effect(c)
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e0:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EVENT_ADJUST)
e0:SetRange(LOCATION_MZONE)
e0:SetOperation(s.adjustop)
c:RegisterEffect(e0)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
......@@ -19,14 +13,14 @@ function s.initial_effect(c)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--flag
--2X material
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(81096431)
e2:SetValue(id)
e2:SetRange(0xff)
e2:SetCode(EFFECT_TREAT_AS_2_XMATERIAL)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(s.sxyzfilter)
e2:SetValue(id)
e2:SetCountLimit(1,id+o)
c:RegisterEffect(e2)
end
......@@ -90,151 +84,3 @@ end
function s.sxyzfilter(e,c)
return c:IsSetCard(0x48)
end
function s.Drake_shark_f(function_f,int_lv,card_c)
return function (c)
return c:IsXyzLevel(card_c,int_lv) and (not function_f or function_f(c))
end
end
function s.sxfilter(c,tp,xc)
local te=c:IsHasEffect(81096431,tp)
if te then
local etg=te:GetTarget()
return not etg or etg(te,xc)
end
return false
end
function s.sxvalue(c,tp,xc)
local te=c:IsHasEffect(81096431,tp)
if te then
local etg=te:GetTarget()
if not etg or etg(te,xc) then
return te:GetValue()
end
end
end
function s.Drake_shark_gf(int_ct,int_tp,xc)
return function (g)
local ct=g:GetCount()
local eg=g:Filter(s.sxfilter,nil,int_tp,xc)
if #eg>0 then
ct=ct+eg:GetClassCount(s.sxvalue,int_tp,xc)
end
local tc=g:GetFirst()
while tc do
local te=tc:IsHasEffect(EFFECT_XYZ_LEVEL,int_tp)
if te then
local evf=te:GetValue()
if evf then
local ev=evf(te,tc,xc)
local lmct=(ev>>12)&0xf
if lmct>0 and lmct>g:GetCount() then
return false
end
end
end
tc=g:GetNext()
end
return ct>=int_ct
end
end
function s.xfilter(c,tp)
return c:IsHasEffect(81096431,tp)
end
function s.eftfilter(c,tp)
local te=c:IsHasEffect(81096431,tp)
return te:GetValue()
end
function s.gcheck(g,tp)
return g:GetClassCount(s.eftfilter,tp)==g:GetCount()
end
function s.adjustop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFlagEffect(0,81096431)==0 then
Duel.RegisterFlagEffect(0,81096431,0,0,1)
Drake_shark_AddXyzProcedure=aux.AddXyzProcedure
function aux.AddXyzProcedure(card_c,function_f,int_lv,int_ct,function_alterf,int_dese,int_maxc,function_op)
if int_ct>=3 then
Drake_shark_XyzLevelFreeOperation=Auxiliary.XyzLevelFreeOperation
function Auxiliary.XyzLevelFreeOperation(f,gf,minc,maxc,alterf,alterdesc,alterop)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
Auxiliary.Drake_Solve(tp,og,maxc,minc)
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=og:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local mg=e:GetLabelObject()
Auxiliary.Drake_Solve(tp,mg,maxc,minc)
if e:GetLabel()==1 then
local mg2=mg:GetFirst():GetOverlayGroup()
if mg2:GetCount()~=0 then
Duel.Overlay(c,mg2)
end
else
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=mg:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
end
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
end
end
aux.AddXyzProcedureLevelFree(card_c,s.Drake_shark_f(function_f,int_lv,card_c),s.Drake_shark_gf(int_ct,card_c:GetOwner(),card_c),int_ct-2,int_ct,function_alterf,int_dese,function_op)
Auxiliary.XyzLevelFreeOperation=Drake_shark_XyzLevelFreeOperation
else
Drake_shark_AddXyzProcedure(card_c,function_f,int_lv,int_ct,function_alterf,int_dese,int_maxc,function_op)
end
end
local rg=Duel.GetMatchingGroup(Card.IsType,tp,LOCATION_EXTRA,LOCATION_EXTRA,nil,TYPE_MONSTER)
for tc in aux.Next(rg) do
if tc.initial_effect then
local Traitor_initial_effect=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=Traitor_initial_effect
tc.initial_effect(tc)
end
end
end
e:Reset()
end
function Auxiliary.Drake_Solve(tp,g,maxct,minct)
if g:GetCount()<maxct and g:GetCount()>=minct and maxct==minct+2 then
local et=maxct-g:GetCount()
local exg=g:Filter(Card.IsHasEffect,nil,81096431,tp)
local ext=exg:GetClassCount(s.eftfilter,tp)
if (et==0 or et==ext) and #exg>0 then
for ttc in aux.Next(exg) do
local tte=ttc:IsHasEffect(81096431,tp)
if tte then
Duel.Hint(HINT_CARD,0,ttc:GetCode())
tte:UseCountLimit(tp)
end
end
elseif #exg>0 then
local st=et
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RESOLVECARD)
local reg=exg:SelectSubGroup(tp,s.gcheck,false,st,st,tp)
for ttc in aux.Next(reg) do
local tte=ttc:IsHasEffect(81096431,tp)
if tte then
Duel.Hint(HINT_CARD,0,ttc:GetCode())
tte:UseCountLimit(tp)
end
end
end
end
end
--ドレイク・シャーク
--not fully implemented
local s,id,o=GetID()
function s.initial_effect(c)
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e0:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EVENT_ADJUST)
e0:SetRange(0xff)
e0:SetOperation(s.adjustop)
c:RegisterEffect(e0)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
......@@ -20,14 +14,14 @@ function s.initial_effect(c)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
--flag
--2X material
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(id)
e2:SetValue(id)
e2:SetRange(0xff)
e2:SetCode(EFFECT_TREAT_AS_2_XMATERIAL)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(s.sxyzfilter)
e2:SetValue(id)
e2:SetCountLimit(1,id+o)
c:RegisterEffect(e2)
--material effect
......@@ -46,127 +40,6 @@ end
function s.sxyzfilter(e,c)
return c:IsAttribute(ATTRIBUTE_WATER)
end
function s.Drake_shark_f(function_f,int_lv,card_c)
return function (c)
return c:IsXyzLevel(card_c,int_lv) and (not function_f or function_f(c))
end
end
function s.sxfilter(c,tp,xc)
local te=c:IsHasEffect(id,tp)
if te then
local etg=te:GetTarget()
return not etg or etg(te,xc)
end
return false
end
function s.sxvalue(c,tp,xc)
local te=c:IsHasEffect(id,tp)
if te then
local etg=te:GetTarget()
if not etg or etg(te,xc) then
return te:GetValue()
end
end
end
function s.Drake_shark_gf(int_ct,int_tp,xc)
return function (g)
local ct=g:GetCount()
local eg=g:Filter(s.sxfilter,nil,int_tp,xc)
if #eg>0 then
ct=ct+eg:GetClassCount(s.sxvalue,int_tp,xc)
end
local tc=g:GetFirst()
while tc do
local te=tc:IsHasEffect(EFFECT_XYZ_LEVEL,int_tp)
if te then
local evf=te:GetValue()
if evf then
local ev=evf(te,tc,xc)
local lmct=(ev>>12)&0xf
if lmct>0 and lmct>g:GetCount() then
return false
end
end
end
tc=g:GetNext()
end
return ct>=int_ct
end
end
function s.xfilter(c,tp)
return c:IsHasEffect(id,tp)
end
function s.eftfilter(c,tp)
local te=c:IsHasEffect(id,tp)
return te:GetValue()
end
function s.gcheck(g,tp)
return g:GetClassCount(s.eftfilter,tp)==g:GetCount()
end
function s.adjustop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFlagEffect(0,81096431)==0 then
Duel.RegisterFlagEffect(0,81096431,0,0,1)
Drake_shark_AddXyzProcedure=aux.AddXyzProcedure
function aux.AddXyzProcedure(card_c,function_f,int_lv,int_ct,function_alterf,int_dese,int_maxc,function_op)
if int_ct>=3 then
Drake_shark_XyzLevelFreeOperation=Auxiliary.XyzLevelFreeOperation
function Auxiliary.XyzLevelFreeOperation(f,gf,minc,maxc,alterf,alterdesc,alterop)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
Auxiliary.Drake_Solve(tp,og,maxc,minc)
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=og:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
c:SetMaterial(og)
Duel.Overlay(c,og)
else
local mg=e:GetLabelObject()
Auxiliary.Drake_Solve(tp,mg,maxc,minc)
if e:GetLabel()==1 then
local mg2=mg:GetFirst():GetOverlayGroup()
if mg2:GetCount()~=0 then
Duel.Overlay(c,mg2)
end
else
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
local sg1=tc:GetOverlayGroup()
sg:Merge(sg1)
tc=mg:GetNext()
end
Duel.SendtoGrave(sg,REASON_RULE)
end
c:SetMaterial(mg)
Duel.Overlay(c,mg)
mg:DeleteGroup()
end
end
end
aux.AddXyzProcedureLevelFree(card_c,s.Drake_shark_f(function_f,int_lv,card_c),s.Drake_shark_gf(int_ct,card_c:GetOwner(),card_c),int_ct-2,int_ct,function_alterf,int_dese,function_op)
Auxiliary.XyzLevelFreeOperation=Drake_shark_XyzLevelFreeOperation
else
Drake_shark_AddXyzProcedure(card_c,function_f,int_lv,int_ct,function_alterf,int_dese,int_maxc,function_op)
end
end
local rg=Duel.GetMatchingGroup(Card.IsType,tp,LOCATION_EXTRA,LOCATION_EXTRA,nil,TYPE_MONSTER)
for tc in aux.Next(rg) do
if tc.initial_effect then
local Traitor_initial_effect=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=Traitor_initial_effect
tc.initial_effect(tc)
end
end
end
e:Reset()
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return not e:GetHandler():IsReason(REASON_DRAW)
end
......@@ -207,30 +80,3 @@ function s.xyzop(e,tp,eg,ep,ev,re,r,rp)
Duel.Overlay(c,Group.FromCards(tc))
end
end
function Auxiliary.Drake_Solve(tp,g,maxct,minct,chkg)
if g:GetCount()<maxct and g:GetCount()>=minct and maxct==minct+2 then
local et=maxct-g:GetCount()
local exg=g:Filter(Card.IsHasEffect,nil,81096431,tp)
local ext=exg:GetClassCount(s.eftfilter,tp)
if (et==0 or et==ext) and #exg>0 then
for ttc in aux.Next(exg) do
local tte=ttc:IsHasEffect(81096431,tp)
if tte then
Duel.Hint(HINT_CARD,0,ttc:GetCode())
tte:UseCountLimit(tp)
end
end
elseif #exg>0 then
local st=et
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RESOLVECARD)
local reg=exg:SelectSubGroup(tp,s.gcheck,false,st,st,tp)
for ttc in aux.Next(reg) do
local tte=ttc:IsHasEffect(81096431,tp)
if tte then
Duel.Hint(HINT_CARD,0,ttc:GetCode())
tte:UseCountLimit(tp)
end
end
end
end
end
......@@ -609,6 +609,7 @@ EFFECT_REPLACE_DAMAGE =371 --伤害由特定行动代替
EFFECT_XYZ_MIN_COUNT =372 --只能用在X只以上的超量召唤
EFFECT_SYNCHRO_LEVEL_EX =373 --支持使用没有等级的怪兽作为同调素材
EFFECT_RITUAL_LEVEL_EX =374 --支持使用没有等级的怪兽作为仪式素材
EFFECT_TREAT_AS_2_XMATERIAL =375 --需3只以上作素材的超量怪兽时可以作为2只数量
EFFECT_FLAG_EFFECT =0x20000000 --标记类效果,即RegisterFlagEffect()创建的效果
--下面是诱发效果的诱发事件、时点 (如果是TYPE_SINGLE则自己发生以下事件后触发,如果TYPE_FIELD则场上任何卡发生以下事件都触发)
......
......@@ -449,13 +449,13 @@ function Auxiliary.XyzCondition(f,lv,minct,maxct,alterf,alterdesc,alterop)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp=c:GetControler()
local mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
if alterf and (not min or min<=1) then
local mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
if mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,alterop) then
return true
end
......@@ -467,9 +467,57 @@ function Auxiliary.XyzCondition(f,lv,minct,maxct,alterf,alterdesc,alterop)
if max<maxc then maxc=max end
if minc>maxc then return false end
end
return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
if minct>=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then
return Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg)
else
return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
end
end
end
function Auxiliary.Xyz2XMaterialFilter(c,xyzc,lv,f)
return c:IsFaceupEx() and c:IsCanBeXyzMaterial(xyzc) and c:IsXyzLevel(xyzc,lv) and (not f or f(c,xyzc))
end
function Auxiliary.Xyz2XMaterialEffectFilter(c,xyzc,lv,f,tp,checked)
if not checked and not Auxiliary.Xyz2XMaterialFilter(c,xyzc,lv,f) then return false end
local e=c:IsHasEffect(EFFECT_TREAT_AS_2_XMATERIAL,tp)
if not e then return false end
local tg=e:GetTarget()
if tg and not tg(e,xyzc) then return false end
return true
end
function Auxiliary.Xyz2XMaterialGoal(g,tp,xyzc,minc)
if Duel.GetLocationCountFromEx(tp,tp,g,xyzc)<=0 then return false end
local lg=g:Filter(Card.IsHasEffect,nil,EFFECT_XYZ_MIN_COUNT,tp)
for c in Auxiliary.Next(lg) do
local le=c:IsHasEffect(EFFECT_XYZ_MIN_COUNT)
local ct=le:GetValue()
if #g<ct then return false end
end
local ct2=0
local limit_table={}
for c in Auxiliary.Next(g) do
local le=c:IsHasEffect(EFFECT_TREAT_AS_2_XMATERIAL,tp)
if le and not limit_table[le:GetValue()] then -- not fully implemented: assuming Hard once per turn effects
local tg=le:GetTarget()
if not tg or tg(le,xyzc) then
ct2=ct2+1
limit_table[le:GetValue()]=true
end
end
end
return #g+ct2>=minc
end
function Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg)
local tp=c:GetControler()
mg=mg:Filter(Auxiliary.Xyz2XMaterialFilter,nil,c,lv,f)
local sg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL)
if sg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(sg)
Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
local res=mg:CheckSubGroup(Auxiliary.Xyz2XMaterialGoal,2,maxc,tp,c,minc)
Auxiliary.GCheckAdditional=nil
return res
end
function Auxiliary.XyzTarget(f,lv,minct,maxct,alterf,alterdesc,alterop)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,min,max)
if og and not min then
......@@ -484,15 +532,19 @@ function Auxiliary.XyzTarget(f,lv,minct,maxct,alterf,alterdesc,alterop)
local b1=true
local b2=false
local altg=nil
local mg=nil
if og then
mg=og
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
end
if alterf and (not min or min<=1) then
local mg=nil
if og then
mg=og
altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop)
if minct>=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then
b1=Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg)
else
mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0)
b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
end
altg=mg:Filter(Auxiliary.XyzAlterFilter,nil,alterf,c,e,tp,alterop)
b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og)
b2=#altg>0
end
local g=nil
......@@ -507,7 +559,18 @@ function Auxiliary.XyzTarget(f,lv,minct,maxct,alterf,alterdesc,alterop)
end
else
e:SetLabel(0)
g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc,og)
if minct>=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then
mg=mg:Filter(Auxiliary.Xyz2XMaterialFilter,nil,c,lv,f)
local cancel=Duel.IsSummonCancelable()
local sg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL)
Duel.SetSelectedCard(sg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalX(EFFECT_TUNE_MAGICIAN_X)
g=mg:SelectSubGroup(tp,Auxiliary.Xyz2XMaterialGoal,cancel,2,maxc,tp,c,minc)
Auxiliary.GCheckAdditional=nil
else
g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc,og)
end
end
if g then
g:KeepAlive()
......@@ -519,6 +582,7 @@ end
function Auxiliary.XyzOperation(f,lv,minct,maxct,alterf,alterdesc,alterop)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max)
if og and not min then
Auxiliary.Xyz2XMaterialOperation(tp,og,c,minct,maxct)
local sg=Group.CreateGroup()
local tc=og:GetFirst()
while tc do
......@@ -537,6 +601,7 @@ function Auxiliary.XyzOperation(f,lv,minct,maxct,alterf,alterdesc,alterop)
Duel.Overlay(c,mg2)
end
else
Auxiliary.Xyz2XMaterialOperation(tp,mg,c,minct,maxct)
local sg=Group.CreateGroup()
local tc=mg:GetFirst()
while tc do
......@@ -552,6 +617,22 @@ function Auxiliary.XyzOperation(f,lv,minct,maxct,alterf,alterdesc,alterop)
end
end
end
function Auxiliary.Xyz2XMaterialOperation(tp,mg,xyzc,minct,maxct)
local sg=mg:Clone()
while #sg<minct do
local g=sg:Filter(Auxiliary.Xyz2XMaterialEffectFilter,nil,xyzc,nil,nil,tp,true)
if #g>1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RESOLVECARD)
g=g:Select(tp,1,1,nil)
end
local tc=g:GetFirst()
local te=tc:IsHasEffect(EFFECT_TREAT_AS_2_XMATERIAL,tp)
Duel.Hint(HINT_CARD,0,tc:GetCode())
te:UseCountLimit(tp)
sg:RemoveCard(tc)
minct=minct-2
end
end
---Xyz monster, any condition
---@param c Card
---@param f function|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