Content added Content deleted
mNo edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
function Stat:new(trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis, |
function Stat:new(trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis, |
||
parallel_processing, tactics, command, special_tactics) |
parallel_processing, tactics, command, special_tactics, position) |
||
local res = Stat |
local res = Stat |
||
setmetatable(res, Stat) |
setmetatable(res, Stat) |
||
Line 21: | Line 21: | ||
res.command = tonumber(command) or 0 |
res.command = tonumber(command) or 0 |
||
res.special_tactics = tonumber(special_tactics) or 0 |
res.special_tactics = tonumber(special_tactics) or 0 |
||
res.position = position |
|||
return res |
return res |
||
end |
end |
||
function Stat:from_table(table) |
function Stat:from_table(table) |
||
return Stat:new(unpack(table, 1, |
return Stat:new(unpack(table, 1, 13)) |
||
end |
end |
||
Line 41: | Line 42: | ||
end |
end |
||
⚫ | |||
---@param frame frame |
|||
local total = 0 |
|||
⚫ | |||
for k, v in pairs(self) do |
|||
if type(v) == "number" then |
|||
return Stat:from_table(args) |
|||
if self.position == "Operator" and k ~= "trion" then |
|||
total = total + v |
|||
elseif self.position ~= "Operator" then |
|||
total = total + v |
|||
end |
|||
end |
|||
end |
|||
return total |
|||
end |
end |
||
Revision as of 21:00, May 17, 2024
Documentation for this module may be created at Module:Char Stat/doc
---@type Util
local util = require("Module:Util")
local Stat = {}
Stat.__index = Stat
function Stat:new(trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis,
parallel_processing, tactics, command, special_tactics, position)
local res = Stat
setmetatable(res, Stat)
res.trion = tonumber(trion) or 0
res.attack = tonumber(attack) or 0
res.defense = tonumber(defense) or 0
res.mobility = tonumber(mobility) or 0
res.skill = tonumber(skill) or 0
res.range = tonumber(range) or 0
res.mechanical_operation = tonumber(mechanical_operation) or 0
res.data_analysis = tonumber(data_analysis) or 0
res.parallel_processing = tonumber(parallel_processing) or 0
res.tactics = tonumber(tactics) or 0
res.command = tonumber(command) or 0
res.special_tactics = tonumber(special_tactics) or 0
res.position = position
return res
end
function Stat:from_table(table)
return Stat:new(unpack(table, 1, 13))
end
function Stat:from_data()
---@type CS_Stat
local data = require("Module:Char Stat/data")
local ret = {}
for k, t in pairs(data) do
ret[k] = Stat
for ik, v in pairs(t) do
ret[k][ik] = v
end
end
return ret
end
function Stat.total(self)
local total = 0
for k, v in pairs(self) do
if type(v) == "number" then
if self.position == "Operator" and k ~= "trion" then
total = total + v
elseif self.position ~= "Operator" then
total = total + v
end
end
end
return total
end
return Stat