×
Create a new article
Write your page title here:
We currently have 1,393 articles on World Trigger Wiki. Type your article name above or create one of the articles listed here!



    World Trigger Wiki

    Module:Char Stat: Difference between revisions

    Content added Content deleted
    m (Name test)
    No edit summary
     
    (9 intermediate revisions by 3 users not shown)
    Line 4: Line 4:
    ---@class Stat
    ---@class Stat
    local Stat = {}
    local Stat = {}
    Stat.__index = Stat


    function Stat:new(action_token, trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis,
    function Stat:new(action_token, trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis,
    parallel_processing, tactics, command, special_tactics, position)
    parallel_processing, tactics, command, special_tactics, position, listname, args)
    ---@class Stat
    ---@class Stat
    local res = Stat
    local res = {}
    setmetatable(res, Stat)
    setmetatable(res, self)
    self.__index = self
    self.__index = self
    res.action_token = tonumber(action_token) or 0
    res.action_token = tonumber(action_token) or 0
    Line 26: Line 25:
    res.special_tactics = tonumber(special_tactics) or 0
    res.special_tactics = tonumber(special_tactics) or 0
    res.position = position
    res.position = position
    res.listname = tonumber(listname) or 0
    res.args = args or {db = "bbf"}
    return res
    return res
    end
    end
    Line 38: Line 39:
    local ret = {}
    local ret = {}
    for k, t in pairs(data) do
    for k, t in pairs(data) do
    ret[k] = Stat
    ret[k] = Stat:new(t.action_token, t.trion, t.attack, t.defense, t.mobility, t.skill,
    t.range, t.mechanical_operation, t.data_analysis, t.parallel_processing, t.tactics, t.command,
    for ik, v in pairs(t) do
    t.special_tactics, t.position, t.listname)
    ret[k][ik] = v
    end
    end
    end
    return ret
    return ret
    Line 50: Line 50:
    for k, v in pairs(self) do
    for k, v in pairs(self) do
    if type(v) == "number" then
    if type(v) == "number" then
    if self.position == "Operator" and k ~= "trion" then
    if self.position == "Operator" and k ~= "trion" and k ~= "listname" then
    total = total + v
    total = total + v
    elseif self.position ~= "Operator" then
    elseif self.position ~= "Operator" and k ~= "listname" then
    total = total + v
    total = total + v
    end
    end
    Line 66: Line 66:
    local args, pargs = util.get_args_and_pargs(frame)
    local args, pargs = util.get_args_and_pargs(frame)
    local name = args[1] or pargs[1] or ""
    local name = args[1] or pargs[1] or ""
    name = name:gsub(" ", "_")
    local key = args[2] or pargs[2] or "total"
    local key = args[2] or pargs[2] or "total"
    ---@type Stat
    local entry = data["Takumi_Rindo"] or Stat
    local entry = data[name]
    local res = {}
    local res = {}
    for k, v in pairs(entry) do
    for k, v in pairs(entry) do
    Line 76: Line 78:
    res.total = entry:total()
    res.total = entry:total()
    return res[key]
    return res[key]
    end

    ---@param frame frame
    function Stat.calcListName(self, frame)
    local p = tostring(self.listname)
    local args = self.args
    local name = ""
    if args.db then name = "bbf" .. p elseif args.c then name = "c" .. p end
    args.name = name
    args.p = p
    return frame:expandTemplate{title = "ref", args = args}
    end

    ---@param frame frame
    function Stat.calcChartName(self, frame)
    return "[[Border Briefing File]] Page " .. self.listname .. self:calcListName(frame)
    end

    ---@param frame frame
    function Stat.GetListName(frame)
    local args, pargs = util.get_args_and_pargs(frame)
    local name = args[1] or pargs[1] or ""
    ---@type Stat
    local entry = data[name]
    return "[[" .. name .. "]]" .. entry:calcListName(frame)
    end

    ---@param frame frame
    function Stat.GetChartName(frame)
    local args, pargs = util.get_args_and_pargs(frame)
    local name = args[1] or pargs[1] or ""
    ---@type Stat
    local entry = data[name]
    return entry:calcChartName(frame)
    end
    end



    Latest revision as of 20:11, May 21, 2024

    Documentation for this module may be created at Module:Char Stat/doc

    ---@type Util
    local util = require("Module:Util")
    
    ---@class Stat
    local Stat = {}
    
    function Stat:new(action_token, trion, attack, defense, mobility, skill, range, mechanical_operation, data_analysis,
        parallel_processing, tactics, command, special_tactics, position, listname, args)
        ---@class Stat
        local res = {}
        setmetatable(res, self)
        self.__index = self
        res.action_token = tonumber(action_token) or 0
        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
        res.listname = tonumber(listname) or 0
        res.args = args or {db = "bbf"}
        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:new(t.action_token, t.trion, t.attack, t.defense, t.mobility, t.skill,
            t.range, t.mechanical_operation, t.data_analysis, t.parallel_processing, t.tactics, t.command,
            t.special_tactics, t.position, t.listname)
        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" and k ~= "listname" then
                    total = total + v
                elseif self.position ~= "Operator" and k ~= "listname" then
                    total = total + v
                end
            end
        end
        return total
    end
    
    local data = Stat.from_data()
    
    ---@param frame frame
    function Stat.GetStat(frame)
        local args, pargs = util.get_args_and_pargs(frame)
        local name = args[1] or pargs[1] or ""
        name = name:gsub(" ", "_")
        local key = args[2] or pargs[2] or "total"
        ---@type Stat
        local entry = data[name]
        local res = {}
        for k, v in pairs(entry) do
          if type(v) == "number" or type(v) == "string" then
            res[k] = v
          end
        end
        res.total = entry:total()
        return res[key]
    end
    
    ---@param frame frame
    function Stat.calcListName(self, frame)
        local p = tostring(self.listname)
        local args = self.args
        local name = ""
        if args.db then name = "bbf" .. p elseif args.c then name = "c" .. p end
        args.name = name
        args.p = p
        return frame:expandTemplate{title = "ref", args = args}
    end
    
    ---@param frame frame
    function Stat.calcChartName(self, frame)
        return "[[Border Briefing File]] Page " .. self.listname .. self:calcListName(frame)
    end
    
    ---@param frame frame
    function Stat.GetListName(frame)
        local args, pargs = util.get_args_and_pargs(frame)
        local name = args[1] or pargs[1] or ""
        ---@type Stat
        local entry = data[name]
        return "[[" .. name .. "]]" .. entry:calcListName(frame)
    end
    
    ---@param frame frame
    function Stat.GetChartName(frame)
        local args, pargs = util.get_args_and_pargs(frame)
        local name = args[1] or pargs[1] or ""
        ---@type Stat
        local entry = data[name]
        return entry:calcChartName(frame)
    end
    
    return Stat
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Fairemont • 2 days ago
  • Fairemont • 2 days ago
  • Fairemont • 2 days ago
  • Fairemont • 2 days ago
  • Welcome to WorldTriggerWiki.com!

    We have completed moving the wiki here from FANDOM. This is the wiki that will be maintained and updated in the future (more information). Enjoy your stay!


    If you would like to get involved, or if you have questions or feedback, check out the Community Portal.

    Happy Birthday!

    June 30

    Takeru Yuiga

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.