Commit 8565f4bc authored by mercury233's avatar mercury233 Committed by GitHub

fix Auxiliary.SameValueCheck (#2348)

* fix Auxiliary.SameValueCheck

* quick break

* more cards
parent 2c8b0e90
......@@ -59,8 +59,7 @@ function c27069566.spfilter(c,e,tp)
return c:IsSetCard(0x14e) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c27069566.fselect(g)
return g:GetClassCount(Card.GetRace)==1
and g:GetClassCount(Card.GetAttribute)==1
return aux.SameValueCheck(g,Card.GetRace) and aux.SameValueCheck(g,Card.GetAttribute)
end
function c27069566.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
......
......@@ -33,7 +33,7 @@ function c28776350.initial_effect(c)
c:RegisterEffect(e3)
end
function c28776350.lcheck(g)
return g:GetClassCount(Card.GetLinkRace)==1
return aux.SameValueCheck(g,Card.GetLinkRace)
end
function c28776350.regcon(e,tp,eg,ep,ev,re,r,rp)
return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_LINK)==SUMMON_TYPE_LINK
......
......@@ -26,7 +26,7 @@ function c30163008.initial_effect(c)
c:RegisterEffect(e2)
end
function c30163008.lcheck(g)
return g:GetClassCount(Card.GetLinkRace)==1
return aux.SameValueCheck(g,Card.GetLinkRace)
end
function c30163008.cfilter(c,e,tp,lg,zone)
return c:IsFaceup() and lg:IsContains(c)
......
......@@ -31,7 +31,7 @@ function c46935289.initial_effect(c)
c:RegisterEffect(e2)
end
function c46935289.lcheck(g,lc)
return g:GetClassCount(Card.GetLinkAttribute)==1 and g:GetClassCount(Card.GetLinkRace)==1
return aux.SameValueCheck(g,Card.GetLinkAttribute) and aux.SameValueCheck(g,Card.GetLinkRace)
end
function c46935289.discon(e,tp,eg,ep,ev,re,r,rp)
return re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev)
......
......@@ -31,7 +31,7 @@ function c61641818.mfilter(c,xyzc)
return c:IsXyzType(TYPE_MONSTER) and c:IsXyzLevel(xyzc,3)
end
function c61641818.xyzcheck(g)
return g:GetClassCount(Card.GetRace)==1 and g:GetClassCount(Card.GetAttribute)==1
return aux.SameValueCheck(g,Card.GetRace) and aux.SameValueCheck(g,Card.GetAttribute)
end
function c61641818.etcon(e)
return e:GetHandler():GetOverlayCount()~=0
......
......@@ -27,7 +27,7 @@ function c61665245.initial_effect(c)
c:RegisterEffect(e2)
end
function c61665245.lcheck(g)
return g:GetClassCount(Card.GetLinkRace)==1
return aux.SameValueCheck(g,Card.GetLinkRace)
end
function c61665245.spcon1(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
......
......@@ -27,7 +27,7 @@ function c78348934.filter1(c,e)
return c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() and c:IsCanBeEffectTarget(e)
end
function c78348934.fselect(g)
return g:GetClassCount(Card.GetRace)==1
return aux.SameValueCheck(g,Card.GetRace)
end
function c78348934.filter3(c)
return c:IsFaceup() and c:IsSetCard(0xd6,0xd7)
......
......@@ -16,8 +16,7 @@ function c79266769.initial_effect(c)
c:RegisterEffect(e1)
end
function c79266769.spcheck(g)
return g:GetClassCount(Card.GetLinkRace)==1
and g:GetClassCount(Card.GetLinkAttribute)==1
return aux.SameValueCheck(g,Card.GetLinkRace) and aux.SameValueCheck(g,Card.GetLinkAttribute)
end
function c79266769.filter(c,e,tp,zone)
return (c:IsFaceup() or not c:IsLocation(LOCATION_REMOVED)) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE,tp,zone)
......
......@@ -39,12 +39,9 @@ function c98095162.initial_effect(c)
e3:SetOperation(c98095162.thop)
c:RegisterEffect(e3)
end
function c98095162.attfilter(c,att)
return c:GetLinkAttribute()&att==0
end
function c98095162.lcheck(g)
local tc=g:GetFirst()
return not g:IsExists(c98095162.attfilter,1,tc,tc:GetLinkAttribute()) and g:GetClassCount(Card.GetLinkRace)==#g
return aux.SameValueCheck(g,Card.GetLinkAttribute) and g:GetClassCount(Card.GetLinkRace)==#g
end
function c98095162.tgcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
......
......@@ -1480,18 +1480,20 @@ end
function Auxiliary.NegateSummonCondition()
return Duel.GetReadyChain()==0
end
--
function Auxiliary.SameValueFilter(f,value)
return function(c)
return f(c)&value==0
end
end
---Check if all cards in g have the same Attribute/Race
---@param g Group
---@param f function
---@param f function Like Card.GetAttribute, must return binary value
---@return boolean
function Auxiliary.SameValueCheck(g,f)
if #g<=1 then return true end
if #g==2 then return f(g:GetFirst())&f(g:GetNext())~=0 end
local tc=g:GetFirst()
local filter=Auxiliary.SameValueFilter(f,f(tc))
return not g:IsExists(filter,1,tc)
local v=f(tc)
tc=g:GetNext()
while tc do
v=v&f(tc)
if v==0 then return false end
tc=g:GetNext()
end
return v~=0
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