Commit 1e2f66a0 authored by wind2009's avatar wind2009

Update library

parent 3f250783
......@@ -51,10 +51,10 @@ function s.spop(e,tp,eg,ep,ev,re,r,rp)
Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)
end
function s.eqcon1(e,tp,eg,ep,ev,re,r,rp)
return not aux.GoldenAllureQueenCondition(e:GetHandler(),tp)
return not aux.IsCanBeQuickEffect(e:GetHandler(),tp,95937545)
end
function s.eqcon2(e,tp,eg,ep,ev,re,r,rp)
return aux.GoldenAllureQueenCondition(e:GetHandler(),tp)
return aux.IsCanBeQuickEffect(e:GetHandler(),tp,95937545)
end
function s.eqfilter(c,tp)
return c:IsType(TYPE_MONSTER) and not c:IsForbidden() and c:CheckUniqueOnField(tp)
......
......@@ -48,11 +48,11 @@ function c23756165.regop(e,tp,eg,ep,ev,re,r,rp)
end
function c23756165.eqcon1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and not aux.GoldenAllureQueenCondition(c,tp)
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and not aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c23756165.eqcon2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and aux.GoldenAllureQueenCondition(c,tp)
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c23756165.filter(c)
return c:IsLevelBelow(5) and c:IsFaceup() and c:IsAbleToChangeControler()
......
......@@ -36,11 +36,11 @@ function c50140163.regop(e,tp,eg,ep,ev,re,r,rp)
end
function c50140163.eqcon1(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and not aux.GoldenAllureQueenCondition(c,tp)
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and not aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c50140163.eqcon2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and aux.GoldenAllureQueenCondition(c,tp)
return c:GetFlagEffect(id+1)>0 and not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c50140163.filter(c)
return c:IsAbleToChangeControler()
......
......@@ -34,10 +34,12 @@ function c87257460.initial_effect(c)
end
c87257460.lvup={23756165}
function c87257460.eqcon1(e,tp,eg,ep,ev,re,r,rp)
return not aux.IsSelfEquip(e:GetHandler(),FLAG_ID_ALLURE_QUEEN) and not aux.GoldenAllureQueenCondition(e:GetHandler(),tp)
local c=e:GetHandler()
return not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and not aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c87257460.eqcon2(e,tp,eg,ep,ev,re,r,rp)
return not aux.IsSelfEquip(e:GetHandler(),FLAG_ID_ALLURE_QUEEN) and aux.GoldenAllureQueenCondition(e:GetHandler(),tp)
local c=e:GetHandler()
return not aux.IsSelfEquip(c,FLAG_ID_ALLURE_QUEEN) and aux.IsCanBeQuickEffect(c,tp,95937545)
end
function c87257460.filter(c)
return c:IsLevelBelow(3) and c:IsFaceup() and c:IsAbleToChangeControler()
......
......@@ -847,12 +847,11 @@ function Auxiliary.XyzLevelFreeOperationAlter(f,gf,minct,maxct,alterf,alterdesc,
end
--Fusion Summon
--material: names in material list
---Fusion monster, mixed materials (fixed count)
---@param fcard Card
---@param sub boolean
---@param insf boolean
---@param sub boolean Can be fusion summoned with substitute material
---@param insf boolean Can be fusion summoned with no material (Instant Fusion)
---@param ... number|function|table
function Auxiliary.AddFusionProcMix(fcard,sub,insf,...)
if fcard:IsStatus(STATUS_COPYING_EFFECT) then return end
......@@ -903,17 +902,17 @@ function Auxiliary.FConditionMix(insf,sub,...)
--g:Material group(nil for Instant Fusion)
--gc:Material already used
--chkf: check field, default:PLAYER_NONE
--chkf&0x100: Not fusion summon
--chkf&0x200: Concat fusion
--chkf&0x100: Not fusion summon, can use substitute (Hex-Sealed Fusion)
--chkf&0x200: Not fusion summon, can't use substitute ("Contact Fusion", Neos Fusion)
local funs={...}
return function(e,g,gc,chkfnf)
if g==nil then return insf and Auxiliary.MustMaterialCheck(nil,e:GetHandlerPlayer(),EFFECT_MUST_BE_FMATERIAL) end
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=chkfnf&0x100>0
local concat_fusion=chkfnf&0x200>0
local sub2=(sub or notfusion) and not concat_fusion
local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,concat_fusion,table.unpack(funs))
local hexsealed=chkfnf&0x100>0
local notfusion=chkfnf&0x200>0
local sub2=(sub or hexsealed) and not notfusion
local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,table.unpack(funs))
if gc then
if not mg:IsContains(gc) then return false end
Duel.SetSelectedCard(gc)
......@@ -925,11 +924,11 @@ function Auxiliary.FOperationMix(insf,sub,...)
local funs={...}
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf)
local c=e:GetHandler()
local notfusion=chkfnf&0x100>0
local concat_fusion=chkfnf&0x200>0
local sub2=(sub or notfusion) and not concat_fusion
local cancel=concat_fusion and Duel.GetCurrentChain()==0
local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,concat_fusion,table.unpack(funs))
local hexsealed=chkfnf&0x100>0
local notfusion=chkfnf&0x200>0
local sub2=(sub or hexsealed) and not notfusion
local cancel=notfusion and Duel.GetCurrentChain()==0
local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,table.unpack(funs))
if gc then Duel.SetSelectedCard(gc) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL)
local sg=mg:SelectSubGroup(tp,Auxiliary.FCheckMixGoal,cancel,#funs,#funs,tp,c,sub2,chkfnf,table.unpack(funs))
......@@ -940,9 +939,9 @@ function Auxiliary.FOperationMix(insf,sub,...)
end
end
end
function Auxiliary.FConditionFilterMix(c,fc,sub,concat_fusion,...)
local fusion_type=concat_fusion and SUMMON_TYPE_SPECIAL or SUMMON_TYPE_FUSION
if not c:IsCanBeFusionMaterial(fc,fusion_type) then return false end
function Auxiliary.FConditionFilterMix(c,fc,sub,notfusion,...)
local check_type=notfusion and SUMMON_TYPE_SPECIAL or SUMMON_TYPE_FUSION
if not c:IsCanBeFusionMaterial(fc,check_type) then return false end
for i,f in ipairs({...}) do
if f(c,fc,sub) then return true end
end
......@@ -966,8 +965,8 @@ end
--if sg1 is subset of sg2 then not Auxiliary.FCheckAdditional(tp,sg1,fc) -> not Auxiliary.FCheckAdditional(tp,sg2,fc)
function Auxiliary.FCheckMixGoal(sg,tp,fc,sub,chkfnf,...)
local chkf=chkfnf&0xff
local concat_fusion=chkfnf&0x200>0
if not concat_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end
local not_fusion=chkfnf&(0x100|0x200)>0
if not not_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end
if not Auxiliary.MustMaterialCheck(sg,tp,EFFECT_MUST_BE_FMATERIAL) then return false end
local g=Group.CreateGroup()
return sg:IsExists(Auxiliary.FCheckMix,1,nil,sg,g,fc,sub,...) and (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0)
......@@ -977,8 +976,8 @@ end
---Fusion monster, mixed material * minc to maxc + material + ...
---@param fcard Card
---@param sub boolean
---@param insf boolean
---@param sub boolean Can be fusion summoned with substitute material
---@param insf boolean Can be fusion summoned with no material (Instant Fusion)
---@param fun1 number|function|table
---@param minc integer
---@param maxc integer
......@@ -1034,10 +1033,10 @@ function Auxiliary.FConditionMixRep(insf,sub,fun1,minc,maxc,...)
if g==nil then return insf and Auxiliary.MustMaterialCheck(nil,e:GetHandlerPlayer(),EFFECT_MUST_BE_FMATERIAL) end
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=chkfnf&0x100>0
local concat_fusion=chkfnf&0x200>0
local sub2=(sub or notfusion) and not concat_fusion
local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,concat_fusion,fun1,table.unpack(funs))
local hexsealed=chkfnf&0x100>0
local notfusion=chkfnf&0x200>0
local sub2=(sub or hexsealed) and not notfusion
local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,fun1,table.unpack(funs))
if gc then
if not mg:IsContains(gc) then return false end
local sg=Group.CreateGroup()
......@@ -1052,11 +1051,11 @@ function Auxiliary.FOperationMixRep(insf,sub,fun1,minc,maxc,...)
return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf)
local c=e:GetHandler()
local tp=c:GetControler()
local notfusion=chkfnf&0x100>0
local concat_fusion=chkfnf&0x200>0
local sub2=(sub or notfusion) and not concat_fusion
local cancel=concat_fusion and Duel.GetCurrentChain()==0
local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,concat_fusion,fun1,table.unpack(funs))
local hexsealed=chkfnf&0x100>0
local notfusion=chkfnf&0x200>0
local sub2=(sub or hexsealed) and not notfusion
local cancel=notfusion and Duel.GetCurrentChain()==0
local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,fun1,table.unpack(funs))
local sg=Group.CreateGroup()
if gc then sg:AddCard(gc) end
while sg:GetCount()<maxc+#funs do
......@@ -1100,8 +1099,8 @@ function Auxiliary.FCheckMixRepFilter(c,sg,g,fc,sub,chkf,fun1,minc,maxc,fun2,...
return false
end
function Auxiliary.FCheckMixRepGoalCheck(tp,sg,fc,chkfnf)
local concat_fusion=chkfnf&0x200>0
if not concat_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end
local not_fusion=chkfnf&(0x100|0x200)>0
if not not_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end
if not Auxiliary.MustMaterialCheck(sg,tp,EFFECT_MUST_BE_FMATERIAL) then return false end
if Auxiliary.FGoalCheckAdditional and not Auxiliary.FGoalCheckAdditional(tp,sg,fc) then return false end
return true
......@@ -2310,4 +2309,4 @@ end
function Auxiliary.FossilFusionLimit(e,se,sp,st)
return st==SUMMON_VALUE_FOSSIL_FUSION or se:GetHandler():IsCode(59419719)
or not e:GetHandler():IsLocation(LOCATION_EXTRA)
end
end
\ No newline at end of file
......@@ -3,6 +3,7 @@ aux=Auxiliary
POS_FACEUP_DEFENCE=POS_FACEUP_DEFENSE
POS_FACEDOWN_DEFENCE=POS_FACEDOWN_DEFENSE
RACE_CYBERS=RACE_CYBERSE
NULL_VALUE=-10
function GetID()
local offset=self_code<100000000 and 1 or 100
......@@ -548,38 +549,130 @@ end
function Auxiliary.IsInGroup(c,g)
return g:IsContains(c)
end
--return the column of card c (from the viewpoint of p)
function Auxiliary.GetColumn(c,p)
local seq=c:GetSequence()
if c:IsLocation(LOCATION_MZONE) then
if seq==5 then
seq=1
elseif seq==6 then
seq=3
--Get the row index (from the viewpoint of controller)
function Auxiliary.GetLocalRow(location,sequence)
if location==LOCATION_SZONE then
if 0<=sequence and sequence<=4 then
return 0
else
return NULL_VALUE
end
elseif c:IsLocation(LOCATION_SZONE) then
if seq>4 then
return nil
elseif location==LOCATION_MZONE then
if 0<=sequence and sequence<=4 then
return 1
elseif 5<=sequence and sequence<=6 then
return 2
else
return NULL_VALUE
end
else
return nil
return NULL_VALUE
end
end
--Get the global row index (from the viewpoint of 0)
function Auxiliary.GetGlobalRow(p,location,sequence)
local row=Auxiliary.GetLocalRow(location,sequence)
if row<0 then
return NULL_VALUE
end
if p==0 then
return row
else
return 4-row
end
end
--Get the column index (from the viewpoint of controller)
function Auxiliary.GetLocalColumn(location,sequence)
if location==LOCATION_SZONE then
if 0<=sequence and sequence<=4 then
return sequence
else
return NULL_VALUE
end
elseif location==LOCATION_MZONE then
if 0<=sequence and sequence<=4 then
return sequence
elseif sequence==5 then
return 1
elseif sequence==6 then
return 3
else
return NULL_VALUE
end
else
return NULL_VALUE
end
if c:IsControler(p or 0) then
return seq
end
--Get the global column index (from the viewpoint of 0)
function Auxiliary.GetGlobalColumn(p,location,sequence)
local column=Auxiliary.GetLocalColumn(location,sequence)
if column<0 then
return NULL_VALUE
end
if p==0 then
return column
else
return 4-seq
return 4-column
end
end
---Get the global row and column index of c
---@param c Card
---@return integer
---@return integer
function Auxiliary.GetFieldIndex(c)
local cp=c:GetControler()
local loc=c:GetLocation()
local seq=c:GetSequence()
return Auxiliary.GetGlobalRow(cp,loc,seq),Auxiliary.GetGlobalColumn(cp,loc,seq)
end
---Check if c is adjacent to (i,j)
---@param c Card
---@param i integer
---@param j integer
---@return boolean
function Auxiliary.AdjacentFilter(c,i,j)
local row,column=Auxiliary.GetFieldIndex(c)
if row<0 or column<0 then
return false
end
return (row==i and math.abs(column-j)==1) or (math.abs(row-i)==1 and column==j)
end
---Get the card group adjacent to (i,j)
---@param tp integer
---@param location1 integer
---@param location2 integer
---@param i integer
---@param j integer
---@return Group
function Auxiliary.GetAdjacentGroup(tp,location1,location2,i,j)
return Duel.GetMatchingGroup(Auxiliary.AdjacentFilter,tp,location1,location2,nil,i,j)
end
---Get the column index of card c (from the viewpoint of p)
---@param c Card
---@param p? integer default: 0
---@return integer
function Auxiliary.GetColumn(c,p)
p=p or 0
local cp=c:GetControler()
local loc=c:GetLocation()
local seq=c:GetSequence()
local column=Auxiliary.GetGlobalColumn(cp,loc,seq)
if column<0 then
return NULL_VALUE
end
if p==0 then
return column
else
return 4-column
end
end
--return the column of monster zone seq (from the viewpoint of controller)
function Auxiliary.MZoneSequence(seq)
if seq==5 then return 1 end
if seq==6 then return 3 end
return seq
return Auxiliary.GetLocalColumn(LOCATION_MZONE,seq)
end
--return the column of spell/trap zone seq (from the viewpoint of controller)
function Auxiliary.SZoneSequence(seq)
if seq>4 then return nil end
return seq
return Auxiliary.GetLocalColumn(LOCATION_SZONE,seq)
end
--generate the value function of EFFECT_CHANGE_BATTLE_DAMAGE on monsters
function Auxiliary.ChangeBattleDamage(player,value)
......@@ -1646,10 +1739,29 @@ end
function Auxiliary.IsSelfEquip(c,id)
return c:GetEquipGroup():IsExists(Card.GetFlagEffect,1,nil,id)
end
---Check if the equip effect of c becomes a Quick Effect.
---Orcustrated Babel
---@param c Card
---@param tp integer
---@return boolean
function Auxiliary.GoldenAllureQueenCondition(c,tp)
return Duel.IsPlayerAffectedByEffect(tp,95937545) and c:IsOriginalSetCard(0x3)
function Auxiliary.OrcustratedBabelFilter(c)
return c:IsOriginalSetCard(0x11b) and
(c:IsLocation(LOCATION_MZONE) and c:IsAllTypes(TYPE_LINK+TYPE_MONSTER) or c:IsLocation(LOCATION_GRAVE) and c:IsType(TYPE_MONSTER))
end
---Golden Allure Queen
---@param c Card
---@return boolean
function Auxiliary.GoldenAllureQueenFilter(c)
return c:IsOriginalSetCard(0x3)
end
--The table of all "become quick effects"
Auxiliary.quick_effect_filter={}
Auxiliary.quick_effect_filter[90351981]=Auxiliary.OrcustratedBabelFilter
Auxiliary.quick_effect_filter[95937545]=Auxiliary.GoldenAllureQueenFilter
---Check if the effect of c becomes a Quick Effect.
---@param c Card
---@param tp integer
---@param code integer
---@return boolean
function Auxiliary.IsCanBeQuickEffect(c,tp,code)
local filter=Auxiliary.quick_effect_filter[code]
return Duel.IsPlayerAffectedByEffect(tp,code)~=nil and filter~=nil and filter(c)
end
\ No newline at end of file
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