×
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
    No edit summary
    No edit summary
    Line 2: Line 2:
    local util = require("Module:Util")
    local util = require("Module:Util")


    ---@class Stat
    local Stat = {}
    local Stat = {}
    Stat.__index = Stat
    Stat.__index = Stat
    Line 7: Line 8:
    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, position)
    parallel_processing, tactics, command, special_tactics, position)
    ---@class Stat
    local res = Stat
    local res = Stat
    setmetatable(res, Stat)
    setmetatable(res, Stat)
    Line 25: Line 27:
    end
    end


    function Stat:from_table(table)
    function Stat.from_table(table)
    return Stat:new(unpack(table, 1, 13))
    return Stat.new(unpack(table, 1, 13))
    end
    end


    function Stat:from_data()
    function Stat.from_data()
    ---@type CS_Stat
    ---@type CS_Stat
    local data = require("Module:Char Stat/data")
    local data = require("Module:Char Stat/data")
    Line 54: Line 56:
    end
    end
    return total
    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 ""
    local key = args[2] or pargs[2] or "total"
    local entry = data[name] or Stat
    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
    end



    Revision as of 21:20, May 17, 2024

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

    ---@type Util
    local util = require("Module:Util")
    
    ---@class Stat
    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)
        ---@class Stat
        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
    
    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 ""
        local key = args[2] or pargs[2] or "total"
        local entry = data[name] or Stat
        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
    
    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.