Commit 794d09f2 authored by GuGu's avatar GuGu

Update Gds.lua

parent afea8590
Pipeline #32913 passed with stage
in 29 seconds
......@@ -121,3 +121,150 @@ function Gds.efcdptg(e,c)
if g:GetCount()<=0 then return false end
return g:IsContains(c)
end
--
--形式变更时点(抄的油库
Goil={}
--AFI
local Goil = false
EVENT_Goil_POS = 2008
local ms = {}
ms[0] = {}
ms[1] = {}
for i = 0, 13 do
ms[0][i] = {}
ms[1][i] = {}
end
local lasts = {}
function Gds.AdjustFieldInfoStore(c)
if Goil == true then return end
Goil = true
--store
local g=Group.CreateGroup()
g:KeepAlive()
--adjust
local e0 = Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e0:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e0:SetCode(EVENT_ADJUST)
e0:SetOperation(Gds.AdjustFieldInfoCheck)
e0:SetLabelObject(g)
Duel.RegisterEffect(e0, 0)
end
function Gds.AdjustFieldInfoCheck(e,tp,eg,ep,ev,re,r,rp)
--define
local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
local preg = e:GetLabelObject()
if g:GetCount()>0 then
--check
Gds.AdjustFieldInfoCheckMI(g, preg, e)
--renew
preg:Clear()
preg:Merge(g)
Gds.AdjustFieldInfoRenewMI(g)
else
if preg:GetCount()==0 then return end
preg:Clear()
end
end
function Gds.AdjustFieldInfoCheckMI(g, preg, e)
local n = -1 -- now seq
local p = -1 -- now player
local pn = -1 -- pre seq
local pp = -1 -- pre player
local tempg1 = {} -- up group(newVal > oldVal or cannot compare)
local tempg2 = {} -- down group(newVal < oldVal)
local isChange = not g:Equal(preg)
tempg1[0] = Group.CreateGroup()
tempg2[0] = Group.CreateGroup()
local tempc = g:GetFirst()
while(tempc) do
p = tempc:GetControler()
n = tempc:GetSequence()
if tempc:IsLocation(LOCATION_SZONE) then
n= n+7
end
if preg:IsContains(tempc) then
pp, pn = Gds.AdjustFieldInfoFindMI(tempc)
if pp < 0 or pn < 0 or ms[pp][pn][-1] ~= tempc:GetRealFieldID() then
-- do nothing
else
--pos
local pos = ms[pp][pn][1]
if pos ~= tempc:GetPosition() then
Duel.RaiseSingleEvent(tempc, EVENT_Goil_POS, e, 0, 0, 0, tempc:GetPosition())
if tempc:IsFaceup() then
tempg1[0]:AddCard(tempc)
else
tempg2[0]:AddCard(tempc)
end
end
end
end
tempc = g:GetNext()
end
if tempg1[0]:GetCount() > 0 then
Duel.RaiseEvent(tempg1[0], EVENT_Goil_POS, e, 0, 0, 0, 1)
isChange = true
end
if tempg2[0]:GetCount() > 0 then
Duel.RaiseEvent(tempg2[0], EVENT_Goil_POS, e, 0, 0, 0, 2)
isChange = true
end
if isChange then
lasts = Nef.DeepCopy(ms)
end
end
function Gds.AdjustFieldInfoRenewMI(g)
local n = -1
local p = -1
for i = 0, 13 do
ms[0][i][0] = nil
ms[1][i][0] = nil
end
tempc = g:GetFirst()
while(tempc) do
n = tempc:GetSequence()
if tempc:IsLocation(LOCATION_SZONE) then
n = n+7
end
p = tempc:GetControler()
ms[p][n][0] = tempc
ms[p][n][-1] = tempc:GetRealFieldID()
ms[p][n][1] = tempc:GetPosition()
tempc = g:GetNext()
end
end
function Gds.AdjustFieldInfoFindMI(c)
local i, j
for i = 0, 1 do
for j = 0, 13 do
if ms[i][j][0] == c then return i, j end
end
end
return -1, -1
end
function Gds.AFIFindLastMI(c)
local i, j
for i = 0, 1 do
for j = 0, 13 do
if lasts[i][j][0] == c then return i, j end
end
end
return -1, -1
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