Commit 456cb1a8 authored by 聖園ミカ's avatar 聖園ミカ 🐟

Replace c20000000.lua

parent 826e4086
Pipeline #30421 canceled with stages
in 4 minutes and 4 seconds
require("expansions/script/c20099997") dofile("expansions/script/c20099997.lua")
if fuef then return end if fuef then return end
fuef = { } --2024/10/7 fuef = { DebugMode = false } --2024/10/14
fuef.__index = fuef fuef.__index = fuef
fuef.DebugMode = false
---------------------------------------------------------------- Standard Register ---------------------------------------------------------------- Standard Register
-- no cod -- no cod
fuef.I = function(_owner, _handler, _ignore) return fuef:Creat("I", nil, _owner, _handler, _ignore) end fuef.I = function(_owner, _handler, _ignore) return fuef:Creat("I", nil, _owner, _handler, _ignore) end
...@@ -21,28 +20,10 @@ end ...@@ -21,28 +20,10 @@ end
---------------------------------------------------------------- fuef() ---------------------------------------------------------------- fuef()
function fuef:__call(_cod, _handler, _ignore) function fuef:__call(_cod, _handler, _ignore)
-- _cod is owner (Creat and Register Noc -- _cod is owner (Creat and Register Noc
if type(_cod) == "userdata" then if type(_cod) == "userdata" then return self:CreatNoc(_cod, _handler, _ignore) end
local ori = self
while ori.pre do
ori = ori.pre
end
repeat
self = fuef:Creat(ori.typ, ori.cod, _cod, _handler, _ignore)
for _,_key in ipairs(fusf.CutString("cat,pro,ran,tran,res,lab,obj", ",", "__call_1")) do
self[_key] = ori[_key] or nil
end
self:RCreat():SetKey("call Reg Noc"):Reg()
for _,_key in ipairs(fusf.CutString("des,ctl,val,con,cos,tg,op", ",", "__call_2")) do
if ori[_key] then fuef[_key:upper()](self, table.unpack(ori[_key])) end
end
local chk = ori.aft
if chk then ori = ori.aft end
until not chk
return self
end
-- Creat and Clone all key -- Creat and Clone all key
local CE = setmetatable({ }, fuef) local CE = setmetatable({ }, fuef)
for _,_key in ipairs(fusf.CutString("typ,cod,des,cat,pro,ran,tran,ctl,val,con,cos,tg,op,res,lab,obj,handler", ",", "__call_3")) do for _,_key in ipairs(fusf.CutString("typ,cod,des,cat,pro,ran,tran,ctl,val,con,cos,tg,op,res,lab,obj,handler", ",", "__call")) do
CE[_key] = self[_key] or nil CE[_key] = self[_key] or nil
end end
if _cod then CE.cod = fusf.Get_Constant("cod", _cod) end if _cod then CE.cod = fusf.Get_Constant("cod", _cod) end
...@@ -74,6 +55,21 @@ function fuef:Creat(_typ, _cod, _owner, _handler, _ignore) ...@@ -74,6 +55,21 @@ function fuef:Creat(_typ, _cod, _owner, _handler, _ignore)
-- Register Effect -- Register Effect
return E:Reg(_handler, _ignore) return E:Reg(_handler, _ignore)
end end
function fuef:CreatNoc(_owner, _handler, _ignore)
local ori = self
while ori.pre do
ori = ori.pre
end
repeat
self = fuef:Creat(ori.typ, ori.cod, _owner, _handler, _ignore)
for _,_key in ipairs(fusf.CutString("des,cat,pro,ran,tran,ctl,val,con,cos,tg,op,res,lab,obj", ",", "CreatNoc")) do
if ori[_key] then fuef[_key:upper()](self, table.unpack(ori[_key])) end
end
local chk = ori.aft
if chk then ori = ori.aft end
until not chk
return self
end
-- Register Effect -- Register Effect
function fuef:Reg(_handler, _ignore) function fuef:Reg(_handler, _ignore)
local handler = self.handler or self.e:GetOwner() local handler = self.handler or self.e:GetOwner()
...@@ -117,27 +113,9 @@ function fuef:Reg(_handler, _ignore) ...@@ -117,27 +113,9 @@ function fuef:Reg(_handler, _ignore)
end end
return self return self
end end
-- Reset and Creat Effect
function fuef:RCreat()
-- chk self.e is effect
if not aux.GetValueType(self.e) == "Effect" then return self end
-- Reset self
local _owner = self.e:GetOwner()
self.e:Reset()
self.e = Effect.CreateEffect(_owner)
-- Reset if handler is group
if self.gclo then
for _, gcloe in ipairs(self.gclo) do
gcloe:Reset()
end
self.gclo = nil
end
return self
end
-- Set all Key -- Set all Key
function fuef:SetKey(_from) function fuef:SetKey(_from)
fuef.Debug("SetKey st <- ".._from) self:Debug("SetKey st <- ".._from)
if not self.e then return self end
if self.typ then self.e:SetType(self.typ) end if self.typ then self.e:SetType(self.typ) end
if self.cod then self.e:SetCode(self.cod) end if self.cod then self.e:SetCode(self.cod) end
if self.des then self.e:SetDescription(self.des) end if self.des then self.e:SetDescription(self.des) end
...@@ -154,17 +132,29 @@ function fuef:SetKey(_from) ...@@ -154,17 +132,29 @@ function fuef:SetKey(_from)
if self.res then self.e:SetReset(table.unpack(self.res)) end if self.res then self.e:SetReset(table.unpack(self.res)) end
if self.lab then self.e:SetLabel(table.unpack(self.lab)) end if self.lab then self.e:SetLabel(table.unpack(self.lab)) end
if self.obj then self.e:SetLabelObject(self.obj) end if self.obj then self.e:SetLabelObject(self.obj) end
fuef.Debug("SetKey ed <- ".._from) self:Debug("")
return self return self
end end
-- chk is Noc (use in every set key final return without cal need self.e -- Reset and Creat Effect and SetKey and Reg (use in every set key final return
function fuef:Reload(_from) function fuef:Reload(_from)
if not self.e then return self end -- chk self.e is effect
return self:RCreat():SetKey("Reload <- ".._from):Reg() if not aux.GetValueType(self.e) == "Effect" then return self:Debug("self.e is not Effect <- Reload <- ".._from) end
-- Reset self
local _owner = self.e:GetOwner()
self.e:Reset()
self.e = Effect.CreateEffect(_owner)
-- Reset if handler is group
if self.gclo then
for _, gcloe in ipairs(self.gclo) do
gcloe:Reset()
end
self.gclo = nil
end
return self:SetKey("Reload <- ".._from):Reg()
end end
function fuef.IsNil(from, ...) function fuef:IsNil(from, ...)
local res = fusf.IsNil(...) local res = fusf.IsNil(...)
if res then fuef.Debug("... IsNil <- ".._from) end if res then self:Debug("... IsNil <- ".._from) end
return res return res
end end
function fuef:PreChk(from, ...) function fuef:PreChk(from, ...)
...@@ -172,25 +162,26 @@ function fuef:PreChk(from, ...) ...@@ -172,25 +162,26 @@ function fuef:PreChk(from, ...)
self[from:lower()] = {...} self[from:lower()] = {...}
return false return false
end end
return not fuef.IsNil("PreChk <- "..from, ...) return not self:IsNil("PreChk <- "..from, ...)
end end
function fuef.Debug(msg) function fuef:Debug(msg)
if fuef.DebugMode then Debug.Message(msg) end if fuef.DebugMode then Debug.Message(msg) end
return self
end end
----------------------------------------------------------------DES ----------------------------------------------------------------DES
function fuef:DES(_code, _id) -- (0), ("n"), (m), ("+1") function fuef:DES(_code, _id) -- (0), ("n"), (m), ("+1")
if not self:PreChk("DES", _code, _id) then return self end if not self:PreChk("DES", _code, _id) then return self end
self.des = fusf.GetDES(_code, _id, self.e:GetOwner():GetOriginalCode()) self.des = fusf.GetDES(_code, _id, self.e:GetOwner():GetOriginalCode())
return self:RCreat():SetKey("DES"):Reg() return self:Reload("DES")
end end
----------------------------------------------------------------TYP, COD, CAT and PRO ----------------------------------------------------------------TYP, COD, CAT and PRO
function fuef:Cons_Model(_key, _val) function fuef:Cons_Model(_key, _val)
if fuef.IsNil(_key:upper(), _val) then return self end -- nil chk if not self:PreChk(_key:upper(), _val) then return self end
local _keytype = _key == "typ" and "etyp" or _key local _keytype = _key == "typ" and "etyp" or _key
local val, des = fusf.Get_Constant(_keytype, _val) local val, des = fusf.Get_Constant(_keytype, _val)
self[_key] = val self[_key] = val
if _key == "cod" and not self.des and fucs.des[des] then self.des = fucs.des[des] end if _key == "cod" and not self.des and fucs.des[des] then self.des = fucs.des[des] end
return self:Reload("Cons_Model") return self:Reload("Cons_Model <- ".._key:upper())
end end
function fuef:TYP(_val) function fuef:TYP(_val)
return self:Cons_Model("typ", _val) return self:Cons_Model("typ", _val)
...@@ -206,12 +197,12 @@ function fuef:PRO(_val) ...@@ -206,12 +197,12 @@ function fuef:PRO(_val)
end end
----------------------------------------------------------------RAN and TRAN ----------------------------------------------------------------RAN and TRAN
function fuef:RAN(_loc) function fuef:RAN(_loc)
if fuef.IsNil("RAN", _loc) then return self end -- nil chk if not self:PreChk("RAN", _loc) then return self end
self.ran = fusf.Get_Loc(_loc, nil, "fuef:RAN()") self.ran = fusf.Get_Loc(_loc, nil, "fuef:RAN()")
return self:Reload("RAN") return self:Reload("RAN")
end end
function fuef:TRAN(_loc1, _loc2) function fuef:TRAN(_loc1, _loc2)
if fuef.IsNil("TRAN", _loc1, _loc2) then return self end -- nil chk if not self:PreChk("TRAN", _loc1, _loc2) then return self end
self.tran = {fusf.Get_Loc(_loc1, _loc2, "fuef:TRAN()")} self.tran = {fusf.Get_Loc(_loc1, _loc2, "fuef:TRAN()")}
return self:Reload("TRAN") return self:Reload("TRAN")
end end
...@@ -221,13 +212,13 @@ function fuef:CTL(_count, _code, _pro) --count, code, pro ...@@ -221,13 +212,13 @@ function fuef:CTL(_count, _code, _pro) --count, code, pro
if type(_count) == "string" or _count > 99 then -- ("n+D") or (m) -> (1, "n+D") or (1, m) if type(_count) == "string" or _count > 99 then -- ("n+D") or (m) -> (1, "n+D") or (1, m)
_count, _code, _pro = 1, _count, _code _count, _code, _pro = 1, _count, _code
end end
local res, ctl_val = {0, 0}, { local res, ctl_val = {_code or 0, _pro or 0}, {
O = EFFECT_COUNT_CODE_OATH, O = EFFECT_COUNT_CODE_OATH,
D = EFFECT_COUNT_CODE_DUEL, D = EFFECT_COUNT_CODE_DUEL,
C = EFFECT_COUNT_CODE_CHAIN, C = EFFECT_COUNT_CODE_CHAIN,
} }
if _pro then -- (1, n, "D") if _pro then -- (1, n, "D")
res[1] = fusf.M_chk(_code) + ctl_val[_pro:match("[ODC]")] res = {fusf.M_chk(_code), ctl_val[_pro:match("[ODC]")]}
elseif type(_code) == "string" then -- (1, "n+D") elseif type(_code) == "string" then -- (1, "n+D")
res = fusf.CutString(_code, "+", "CTL_1") -- (n), (n, d), (d) res = fusf.CutString(_code, "+", "CTL_1") -- (n), (n, d), (d)
if res[1]:match("[ODC]") then if res[1]:match("[ODC]") then
...@@ -241,13 +232,13 @@ function fuef:CTL(_count, _code, _pro) --count, code, pro ...@@ -241,13 +232,13 @@ function fuef:CTL(_count, _code, _pro) --count, code, pro
if res[2] & 0x30000000 > 0 and res[1] == 0 then res[1] = self.e:GetOwner():GetOriginalCode() end -- is O or D if res[2] & 0x30000000 > 0 and res[1] == 0 then res[1] = self.e:GetOwner():GetOriginalCode() end -- is O or D
end end
self.ctl = {_count, res[1] + res[2]} self.ctl = {_count, res[1] + res[2]}
return self:RCreat():SetKey("CTL"):Reg() return self:Reload("CTL")
end end
----------------------------------------------------------------VAL, CON, COS, TG and OP ----------------------------------------------------------------VAL, CON, COS, TG and OP
function fuef:Func(_val, _func, ...) function fuef:Func(_val, _func, ...)
-- func = ("val,con,cos(v1,v2),tg,op") or ("con(v1,v2),op") or (val, "con,op(v1, v2)"), if v = %1~n then { ... } is value table -- func = ("val,con,cos(v1,v2),tg,op") or ("con(v1,v2),op") or (val, "con,op(v1, v2)"), if v = %1~n then { ... } is value table
if fusf.IsNil(_val, _func) then -- nil chk if fusf.IsNil(_val, _func) then -- nil chk
fuef.Debug("_val, _func IsNil <- Func".._from) self:Debug("_val, _func IsNil <- Func".._from)
return self return self
end end
local vals = {...} local vals = {...}
...@@ -289,17 +280,17 @@ function fuef:Func(_val, _func, ...) ...@@ -289,17 +280,17 @@ function fuef:Func(_val, _func, ...)
local val = self.val[1] local val = self.val[1]
if type(val) == "string" then if type(val) == "string" then
self.val = tonumber(val) or fucs.val[val] or fusf.Get_Func(self.e:GetOwner(), table.unpack(self.val)) self.val = tonumber(val) or fucs.val[val] or fusf.Get_Func(self.e:GetOwner(), table.unpack(self.val))
if not self.val then fuef.Debug("val Func value is nil") end if not self.val then self:Debug("val Func value is nil") end
else -- number or function else -- number or function
self.val = val self.val = val
end end
end end
for _,set in ipairs(sets) do for _,set in ipairs(sets) do
local res = fusf.Get_Func(self.e:GetOwner(), table.unpack(self[set])) local res = fusf.Get_Func(self.e:GetOwner(), table.unpack(self[set]))
if not res then fuef.Debug(set.." Func value is nil") end if not res then self:Debug(set.." Func value is nil") end
self[set] = res self[set] = res
end end
return self:RCreat():SetKey("Func"):Reg() return self:Reload("Func")
end end
function fuef:Func_Model(_key, _func, ...) function fuef:Func_Model(_key, _func, ...)
if not self:PreChk(_key:upper(), _func, ...) then return self end if not self:PreChk(_key:upper(), _func, ...) then return self end
...@@ -317,8 +308,8 @@ function fuef:Func_Model(_key, _func, ...) ...@@ -317,8 +308,8 @@ function fuef:Func_Model(_key, _func, ...)
vals = vals[1] -- 若 vals 中只有一个表,则直接解包表 vals = vals[1] -- 若 vals 中只有一个表,则直接解包表
end end
self[_key] = val_chk or fusf.Get_Func(self.e:GetOwner(), _func, vals) self[_key] = val_chk or fusf.Get_Func(self.e:GetOwner(), _func, vals)
if not self[_key] then fuef.Debug(_key.." Func value is nil") end if not self[_key] then self:Debug(_key.." Func value is nil") end
return self:RCreat():SetKey(_key):Reg() return self:Reload("Func_Model <- ".._key:upper())
end end
function fuef:VAL(_func, ...) function fuef:VAL(_func, ...)
return self:Func_Model("val", _func, ...) return self:Func_Model("val", _func, ...)
...@@ -337,13 +328,13 @@ function fuef:OP(_func, ...) ...@@ -337,13 +328,13 @@ function fuef:OP(_func, ...)
end end
----------------------------------------------------------------RES ----------------------------------------------------------------RES
function fuef:RES(_flag, _count) -- _flag = a + b/b1/b2 + c | 1 function fuef:RES(_flag, _count) -- _flag = a + b/b1/b2 + c | 1
if fuef.IsNil("RES", _flag, _count) then return self end -- nil chk if not self:PreChk("RES", _flag, _count) then return self end
self.res = fusf.GetRES(_flag, _count) self.res = fusf.GetRES(_flag, _count)
return self:Reload("RES") return self:Reload("RES")
end end
----------------------------------------------------------------LAB ----------------------------------------------------------------LAB
function fuef:LAB(...) function fuef:LAB(...)
if fuef.IsNil("LAB", ...) then return self end -- nil chk if not self:PreChk("LAB", ...) then return self end
local _labs = {...} local _labs = {...}
local labs = { } local labs = { }
for _,_lab in ipairs(_labs) do for _,_lab in ipairs(_labs) do
...@@ -360,7 +351,7 @@ function fuef:LAB(...) ...@@ -360,7 +351,7 @@ function fuef:LAB(...)
end end
----------------------------------------------------------------OBJ ----------------------------------------------------------------OBJ
function fuef:OBJ(_val) function fuef:OBJ(_val)
if fuef.IsNil("OBJ", _val) then return self end -- nil chk if not self:PreChk("OBJ", _val) then return self end
self.obj = _val self.obj = _val
return self:Reload("OBJ") return self:Reload("OBJ")
end end
...@@ -368,9 +359,8 @@ end ...@@ -368,9 +359,8 @@ end
function fuef.initial(_lib, _glo, _exop_func, ...) function fuef.initial(_lib, _glo, _exop_func, ...)
local cm, m = GetID() local cm, m = GetID()
local exop_val = { ... } local exop_val = { ... }
cm.pre = {} cm.es, cm.lib = {}, _lib
cm.initial_effect = function(c) cm.initial_effect = cm.initial_effect or function(c)
if _lib then cm.lib = _lib end -- set lib
-- do ex_op -- do ex_op
if _exop_func then if _exop_func then
local place = 1 local place = 1
...@@ -387,19 +377,19 @@ function fuef.initial(_lib, _glo, _exop_func, ...) ...@@ -387,19 +377,19 @@ function fuef.initial(_lib, _glo, _exop_func, ...)
end end
end end
end end
local dof = function(_tab, _name, _exval) local dof = function(_name, _exval)
local n = 1 local n = 1
while _tab[_name..n] do while cm[_name..n] do
_tab[_name..n](c, _exval) cm.es[_name..n] = cm[_name..n](c, _exval)
n = n + 1 n = n + 1
end end
end end
dof(cm, "e") -- do e1 ~ en dof("e") -- do e1 ~ en
dof(cm.pre, "e") -- do e1 ~ en in lib pre set dof("pe") -- do e1 ~ en in lib pre set
-- if cm[_glo] then do ge1 ~ gen -- if cm[_glo] then do ge1 ~ gen
if not (_glo and not cm[_glo]) then return end if not (_glo and not cm[_glo]) then return end
cm[_glo] = {0, 0} cm[_glo] = {0, 0}
dof(cm, "ge", 1) dof("ge", 1)
end end
return cm, m return cm, m
end 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