FANDOM


Linia 48: Linia 48:
 
local function get_weapon_data(weapon_name)
 
local function get_weapon_data(weapon_name)
 
return weapon_data["weapons"][weapon_name] or {}
 
return weapon_data["weapons"][weapon_name] or {}
  +
end
  +
  +
local function has_attack_type(weapon_name, attack_type)
  +
return weapon_data["weapons"][weapon_name][attack_type:lower() .. "_attack"] ~= nil
  +
end
  +
  +
local function get_attack_data(weapon_name, attack_type)
  +
return weapon_data["weapons"][weapon_name][attack_type:lower() .. "_attack"]
 
end
 
end
   
Linia 87: Linia 95:
   
 
local function get_damage_per_pellet(weapon_name, attack_type)
 
local function get_damage_per_pellet(weapon_name, attack_type)
local pellet_count = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_count"]
+
local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
local damage = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["damage"]
+
local damage = (get_attack_data(weapon_name, attack_type) or {})["damage"]
 
if pellet_count == nil or damage == nil then return nil end
 
if pellet_count == nil or damage == nil then return nil end
 
return utils.sum(utils.unpack_any_table(damage)) / pellet_count
 
return utils.sum(utils.unpack_any_table(damage)) / pellet_count
Linia 94: Linia 102:
   
 
local function get_elemental_type(weapon_name, attack_type)
 
local function get_elemental_type(weapon_name, attack_type)
local data = get_weapon_data(weapon_name)[attack_type .. "_attack"]
+
local data = get_attack_data(weapon_name, attack_type)
 
if(data == nil or data["damage"] == nil) then return nil end
 
if(data == nil or data["damage"] == nil) then return nil end
 
for k, v in pairs(data["damage"]) do
 
for k, v in pairs(data["damage"]) do
Linia 170: Linia 178:
 
end,
 
end,
 
["ammo_cost"] = function(weapon_name, attack_type)
 
["ammo_cost"] = function(weapon_name, attack_type)
local ammo_cost = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["ammo_cost"]
+
local ammo_cost = (get_attack_data(weapon_name, attack_type) or {})["ammo_cost"]
 
return ammo_cost and ammo_cost .. " amunicji na strzał"
 
return ammo_cost and ammo_cost .. " amunicji na strzał"
 
end,
 
end,
Linia 198: Linia 206:
 
end,
 
end,
 
["projectile_speed"] = function(weapon_name, attack_type)
 
["projectile_speed"] = function(weapon_name, attack_type)
local bullet_speed = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["projectile_speed"]
+
local bullet_speed = (get_attack_data(weapon_name, attack_type) or {})["projectile_speed"]
 
if type(bullet_speed) == "string" then
 
if type(bullet_speed) == "string" then
 
return bullet_speed
 
return bullet_speed
Linia 226: Linia 234:
 
end,
 
end,
 
["fire_rate"] = function(weapon_name, attack_type)
 
["fire_rate"] = function(weapon_name, attack_type)
local fire_rate = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["fire_rate"]
+
local fire_rate = (get_attack_data(weapon_name, attack_type) or {})["fire_rate"]
 
if fire_rate == nil then return nil end
 
if fire_rate == nil then return nil end
 
if(is_melee(weapon_name)) then
 
if(is_melee(weapon_name)) then
Linia 235: Linia 243:
 
end,
 
end,
 
["multishot_name"] = function(weapon_name, attack_type)
 
["multishot_name"] = function(weapon_name, attack_type)
local pellet_name = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_name"]
+
local pellet_name = (get_attack_data(weapon_name, attack_type) or {})["pellet_name"]
local pellet_count = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_count"]
+
local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
 
return pellet_count and ((pellet_name and utils.make_polish_plural(pellet_name, pellet_count)) or "Odłamki")
 
return pellet_count and ((pellet_name and utils.make_polish_plural(pellet_name, pellet_count)) or "Odłamki")
 
end,
 
end,
 
["multishot"] = function(weapon_name, attack_type)
 
["multishot"] = function(weapon_name, attack_type)
return (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_count"]
+
return (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
 
end,
 
end,
 
["damage_per_pellet"] = function(weapon_name, attack_type)
 
["damage_per_pellet"] = function(weapon_name, attack_type)
return utils.to_minimum_precision(get_damage_per_pellet(weapon_name, attack_type), 1)
+
local damage_per_pellet = get_damage_per_pellet(weapon_name, attack_type)
  +
return damage_per_pellet and utils.to_minimum_precision(get_damage_per_pellet(weapon_name, attack_type), 1)
 
end,
 
end,
 
["multishot_full"] = function(weapon_name, attack_type)
 
["multishot_full"] = function(weapon_name, attack_type)
local pellet_name = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_name"]
+
local pellet_name = (get_attack_data(weapon_name, attack_type) or {})["pellet_name"]
local pellet_count = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["pellet_count"]
+
local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
 
local damage_per_pellet = get_damage_per_pellet(weapon_name, attack_type)
 
local damage_per_pellet = get_damage_per_pellet(weapon_name, attack_type)
 
return (pellet_count and damage_per_pellet) and pellet_count .. " (" .. utils.to_minimum_precision(damage_per_pellet, 1) .. " obrażeń na " .. ((pellet_name and pellet_name:lower()) or "odłamek") .. ")"
 
return (pellet_count and damage_per_pellet) and pellet_count .. " (" .. utils.to_minimum_precision(damage_per_pellet, 1) .. " obrażeń na " .. ((pellet_name and pellet_name:lower()) or "odłamek") .. ")"
Linia 303: Linia 311:
 
end,
 
end,
 
["damage"] = function(weapon_name, attack_type)
 
["damage"] = function(weapon_name, attack_type)
local damage = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["damage"]
+
local damage = (get_attack_data(weapon_name, attack_type) or {})["damage"]
 
if damage == nil then return nil end
 
if damage == nil then return nil end
 
if utils.table_size(damage) == 1 then
 
if utils.table_size(damage) == 1 then
Linia 318: Linia 326:
 
end,
 
end,
 
["elemental"] = function(weapon_name, attack_type)
 
["elemental"] = function(weapon_name, attack_type)
local data = get_weapon_data(weapon_name)[attack_type .. "_attack"] or {}
+
local data = get_attack_data(weapon_name, attack_type) or {}
 
local element_type = get_elemental_type(weapon_name, attack_type)
 
local element_type = get_elemental_type(weapon_name, attack_type)
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
Linia 326: Linia 334:
 
end,
 
end,
 
["slash"] = function(weapon_name, attack_type)
 
["slash"] = function(weapon_name, attack_type)
local data = get_weapon_data(weapon_name)[attack_type .. "_attack"] or { damage = {} }
+
local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
 
local slash = data["damage"]["slash"]
 
local slash = data["damage"]["slash"]
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
Linia 334: Linia 342:
 
end,
 
end,
 
["impact"] = function(weapon_name, attack_type)
 
["impact"] = function(weapon_name, attack_type)
local data = get_weapon_data(weapon_name)[attack_type .. "_attack"] or { damage = {} }
+
local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
 
local impact = data["damage"]["impact"]
 
local impact = data["damage"]["impact"]
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
Linia 342: Linia 350:
 
end,
 
end,
 
["puncture"] = function(weapon_name, attack_type)
 
["puncture"] = function(weapon_name, attack_type)
local data = get_weapon_data(weapon_name)[attack_type .. "_attack"] or { damage = {} }
+
local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
 
local puncture = data["damage"]["puncture"]
 
local puncture = data["damage"]["puncture"]
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
 
if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then
Linia 350: Linia 358:
 
end,
 
end,
 
["charging_time"] = function(weapon_name, attack_type)
 
["charging_time"] = function(weapon_name, attack_type)
local charging_time = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["charge_time"]
+
local charging_time = (get_attack_data(weapon_name, attack_type) or {})["charge_time"]
 
return charging_time and utils.to_minimum_precision(charging_time, 1) .. "s"
 
return charging_time and utils.to_minimum_precision(charging_time, 1) .. "s"
 
end,
 
end,
 
["critical_chance"] = function(weapon_name, attack_type)
 
["critical_chance"] = function(weapon_name, attack_type)
local crit_chance = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["critical_chance"]
+
local crit_chance = (get_attack_data(weapon_name, attack_type) or {})["critical_chance"]
  +
if crit_chance == nil and has_attack_type(weapon_name, "normal") then
  +
local normal_crit_chance = get_attack_data(weapon_name, "normal")["critical_chance"]
  +
return normal_crit_chance and utils.to_percent(normal_crit_chance)
  +
end
 
return crit_chance and utils.to_percent(crit_chance)
 
return crit_chance and utils.to_percent(crit_chance)
 
end,
 
end,
 
["critical_multiplier"] = function(weapon_name, attack_type)
 
["critical_multiplier"] = function(weapon_name, attack_type)
local crit_mult = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["critical_multiplier"]
+
local crit_mult = (get_attack_data(weapon_name, attack_type) or {})["critical_multiplier"]
  +
if crit_mult == nil and has_attack_type(weapon_name, "normal") then
  +
local normal_crit_mult = get_attack_data(weapon_name, "normal")["critical_multiplier"]
  +
return normal_crit_mult and utils.to_minimum_precision(normal_crit_mult, 1) .. 'x'
  +
end
 
return crit_mult and utils.to_minimum_precision(crit_mult, 1) .. 'x'
 
return crit_mult and utils.to_minimum_precision(crit_mult, 1) .. 'x'
 
end,
 
end,
 
["falloff"] = function(weapon_name, attack_type)
 
["falloff"] = function(weapon_name, attack_type)
local falloff = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["falloff"]
+
local falloff = (get_attack_data(weapon_name, attack_type) or {})["falloff"]
 
if falloff == nil then return nil end
 
if falloff == nil then return nil end
 
local ret = "Maksymalne obrażenia do " .. utils.to_minimum_precision(falloff.start_range, 1) .. "m<br>Minimalne obrażenia od " .. utils.to_minimum_precision(falloff.end_range, 1) .. "m"
 
local ret = "Maksymalne obrażenia do " .. utils.to_minimum_precision(falloff.start_range, 1) .. "m<br>Minimalne obrażenia od " .. utils.to_minimum_precision(falloff.end_range, 1) .. "m"
Linia 371: Linia 379:
 
end,
 
end,
 
["status_chance"] = function(weapon_name, attack_type)
 
["status_chance"] = function(weapon_name, attack_type)
local status_chance = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["status_chance"]
+
local status_chance = (get_attack_data(weapon_name, attack_type) or {})["status_chance"]
 
return status_chance and utils.to_percent(status_chance)
 
return status_chance and utils.to_percent(status_chance)
 
end,
 
end,
 
["punch_through"] = function(weapon_name, attack_type)
 
["punch_through"] = function(weapon_name, attack_type)
local punch = (get_weapon_data(weapon_name)[attack_type .. "_attack"] or {})["punch_through"]
+
local punch = (get_attack_data(weapon_name, attack_type) or {})["punch_through"]
 
return punch and utils.to_minimum_precision(punch, 1) .. "m"
 
return punch and utils.to_minimum_precision(punch, 1) .. "m"
 
end,
 
end,

Wersja z 16:41, sie 11, 2018

--
local weapon_data = mw.loadData("Module:Weapon/data")
local mods = require("Module:Mods")
local icon = require("Module:I")
local utils = require("Module:Utils")
local module_export = {}
 
local primary_weapon_type = "Główna"
local secondary_weapon_type = "Boczna"
local weapon_type = {
    primary = "Główna",
    secondary = "Boczna",
    melee = "Broń Biała"
}
 
local archwing_weapon_type = {
    primary = "Archwing Główna",
    melee = "Archwing Broń Biała"
}
 
local weapon_category = {
    bow = 'Łuk',
    launcher = "Wyrzutnia",
    rifle = "Karabin",
    shotgun = "Strzelba",
    sniper_rifle = "Karabin Snajperski",
    thrown = "Rzucana"
}
 
local ammo_type = {
    bow = "Strzały", -- FIX
    launcher = "Snajperska",
    pistol = "Pistoletowa",
    rifle = "Karabinowa",
    shotgun = "Strzelba", -- FIX
    sniper_rifle = "Snajperska",
}
 
local noise_level = {
    alarming = "Alarmujący",
    silent = "Cichy"
}
 
local physical_damage_types = { "impact", "puncture", "slash" }
local elemental_damage_types = { "" }
local weapon_names = utils.table_keys(weapon_data["weapons"])
 
local function get_weapon_data(weapon_name)
    return weapon_data["weapons"][weapon_name] or {}
end
 
local function has_attack_type(weapon_name, attack_type)
    return weapon_data["weapons"][weapon_name][attack_type:lower() .. "_attack"] ~= nil
end
 
local function get_attack_data(weapon_name, attack_type)
    return weapon_data["weapons"][weapon_name][attack_type:lower() .. "_attack"]
end
 
local function is_weapon(name)
    return utils.contains(weapon_names, name)
end
 
local function is_melee(weapon_name)
    local weap_data = get_weapon_data(weapon_name)
    return weap_data["type"] == weapon_type.melee or weap_data["type"] == archwing_weapon_type.melee
end
 
local function is_archwing_melee(weapon_name)
    local weap_data = get_weapon_data(weapon_name)
    return weap_data["type"] == archwing_weapon_type.melee
end
 
local function is_physical(val)
    return utils.contains(physical_damage_types, val)
end
 
local function is_elemental(val)
    return not is_physical(val)
end
 
local function get_damage_bias(damage)
    local max_damage = 0
    local max_damage_type = nil
    local total_damage = utils.sum(utils.unpack_any_table(damage))
    for k, v in pairs(damage) do
        if(max_damage < v) then
            max_damage = v
            max_damage_type = k
        end
    end
 
    return max_damage / total_damage, max_damage_type
end
 
local function get_damage_per_pellet(weapon_name, attack_type)
    local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
    local damage = (get_attack_data(weapon_name, attack_type) or {})["damage"]
    if pellet_count == nil or damage == nil then return nil end
    return utils.sum(utils.unpack_any_table(damage)) / pellet_count
end
 
local function get_elemental_type(weapon_name, attack_type)
    local data = get_attack_data(weapon_name, attack_type)
    if(data == nil or data["damage"] == nil) then return nil end
    for k, v in pairs(data["damage"]) do
        if is_elemental(k) then 
            return k
        end
    end
    return nil -- no elemental damage
end
 
local function get_stances(weapon_name)
    local weapon_cat = get_weapon_data(weapon_name)["category"]
    local stances = weapon_data["stances"]
    local matching_stances = {}
    for _, stance in ipairs(stances) do
        if stance["category"] == weapon_cat then
            table.insert(matching_stances, stance)
        end
    end
    return matching_stances
end
 
local function get_augments(weapon_name)
    local augments = weapon_data["augments"]
    local matching_augments = {}
    for _, augment in ipairs(augments) do
        if utils.contains(augment.weapons, weapon_name) then
            table.insert(matching_augments, augment)
        end
    end
    return matching_augments
end
 
local function get_variants(weapon_name)
    local weapon_variant = get_weapon_data(weapon_name)["family"]
    if weapon_variant == nil then return {} end
    local variants = {}
    for name, weapon in pairs(weapon_data["weapons"]) do
        if weapon["family"] == weapon_variant and name ~= weapon_name then
            table.insert(variants, name)
        end
    end
    return variants
end
 
local getters = {
    -- Image
    ["image"] = function(weapon_name)
        local image = get_weapon_data(weapon_name)["image"]
        return image or "Panel.png"
    end,
 
    -- Headers
    ["header"] = function(weapon_name, type)
        return (get_weapon_data(weapon_name)[type .. "_attack"] or {})["header"]
    end,
 
    -- Fields
    ["mastery"] = function(weapon_name)
        local mastery = get_weapon_data(weapon_name)["mastery"]
        return mastery or 0
    end,
    ["category"] = function(weapon_name)
        return get_weapon_data(weapon_name)["category"]
    end,
    ["type"] = function(weapon_name)
        return get_weapon_data(weapon_name)["type"]
    end,
    ["trigger"] = function(weapon_name)
        return get_weapon_data(weapon_name)["trigger"]
    end,
    ["accuracy"] = function(weapon_name)
        local accuarcy = get_weapon_data(weapon_name)["accuracy"]
        return accuracy and utils.to_minimum_precision(accuracy, 1)
    end,
    ["ammo_cost"] = function(weapon_name, attack_type)
        local ammo_cost = (get_attack_data(weapon_name, attack_type) or {})["ammo_cost"]
        return ammo_cost and ammo_cost .. " amunicji na strzał"
    end,
    ["ammo_type"] = function(weapon_name)
        return get_weapon_data(weapon_name)["ammo_type"]
    end,
    ["ammo_type_default"] = function(weapon_name)
        local weap_type = get_weapon_data(weapon_name)["type"]
        local weap_cat = get_weapon_data(weapon_name)["category"]
        if weap_type == weapon_type.secondary then
            return ammo_type.pistol
        elseif weap_type == weapon_type.primary then
            if weap_cat == nil or weap_cat == weapon_category.rifle then
                return ammo_type.rifle
            elseif weap_cat == weapon_category.bow then
                return ammo_type.bow
            elseif weap_cat == weapon_category.launcher then
                return ammo_type.launcher
            elseif weap_cat == weapon_category.shotgun then
                return ammo_type.shotgun
            elseif weap_cat == weapon_category.sniper_rifle then
                return ammo_type.sniper_rifle
            end
        end
 
        return nil -- not matching any 
    end,
    ["projectile_speed"] = function(weapon_name, attack_type)
        local bullet_speed = (get_attack_data(weapon_name, attack_type) or {})["projectile_speed"]
        if type(bullet_speed) == "string" then
            return bullet_speed
        elseif type(bullet_speed) == "number" then
            return bullet_speed and utils.to_minimum_precision(bullet_speed, 1) .. "m/s" -- Ensure bullet_speed is not nil
        else 
            return nil
        end
    end,
    ["range"] = function(weapon_name)
        local range = get_weapon_data(weapon_name)["range"]
        return range and utils.to_precision(range, 1) .. "m"
    end,
    ["noise_level"] = function(weapon_name)
        return get_weapon_data(weapon_name)["noise_level"]
    end,
    ["noise_level_default"] = function(weapon_name)
        if not is_melee(weapon_name) then
            local weap_cat = get_weapon_data(weapon_name)["category"]
            if weap_cat == weapon_category.bow or weap_cat == weapon_category.thrown then
                return noise_level.silent
            else
                return noise_level.alarming
            end
        end
        return nil -- not matching any
    end,
    ["fire_rate"] = function(weapon_name, attack_type)
        local fire_rate = (get_attack_data(weapon_name, attack_type) or {})["fire_rate"]
        if fire_rate == nil then return nil end
        if(is_melee(weapon_name)) then
            return utils.to_minimum_precision(fire_rate, 2)
        else
            return utils.to_minimum_precision(fire_rate, 1) .. " " .. utils.make_polish_plural("pocisk", fire_rate) .. " na sekundę"
        end
    end,
    ["multishot_name"] = function(weapon_name, attack_type)
        local pellet_name = (get_attack_data(weapon_name, attack_type) or {})["pellet_name"]
        local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
        return pellet_count and ((pellet_name and utils.make_polish_plural(pellet_name, pellet_count)) or "Odłamki")
    end,
    ["multishot"] = function(weapon_name, attack_type)
        return (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
    end,
    ["damage_per_pellet"] = function(weapon_name, attack_type)
        local damage_per_pellet = get_damage_per_pellet(weapon_name, attack_type)
        return damage_per_pellet and utils.to_minimum_precision(get_damage_per_pellet(weapon_name, attack_type), 1)
    end,
    ["multishot_full"] = function(weapon_name, attack_type)
        local pellet_name = (get_attack_data(weapon_name, attack_type) or {})["pellet_name"]
        local pellet_count = (get_attack_data(weapon_name, attack_type) or {})["pellet_count"]
        local damage_per_pellet = get_damage_per_pellet(weapon_name, attack_type)
        return (pellet_count and damage_per_pellet) and pellet_count .. " (" .. utils.to_minimum_precision(damage_per_pellet, 1) .. " obrażeń na " .. ((pellet_name and pellet_name:lower()) or "odłamek") .. ")"
    end,
    ["zoom"] = function(weapon_name)
        local zoom = get_weapon_data(weapon_name)["zoom"]
        if(type(zoom) == "table") then
            return utils.table_concat(zoom, '<br>')
        else
            return get_weapon_data(weapon_name)["zoom"]
        end
    end,
    ["mag_capacity"] = function(weapon_name)
        local mag = get_weapon_data(weapon_name)["mag_capacity"]
        return mag and mag .. " " .. utils.make_polish_plural("pocisk", mag) -- Ensure mag is not nil
    end,
    ["max_ammo"] = function(weapon_name)
        local max_ammo = get_weapon_data(weapon_name)["max_ammo"]
        return max_ammo and max_ammo .. " " .. utils.make_polish_plural("pocisk", max_ammo) -- Ensure max_ammo is not nil
    end,
    ["reload"] = function(weapon_name)
        local reload = get_weapon_data(weapon_name)["reload"]
        return reload and utils.to_minimum_precision(reload, 1) .. "s" -- Ensure reload is not nil
    end,
    ["spool"] = function(weapon_name)
        return get_weapon_data(weapon_name)["spool"]
    end,
    ["sniper_combo_reset"] = function(weapon_name)
        local combo_reset = get_weapon_data(weapon_name)["sniper_combo_reset"]
        return  combo_reset and utils.to_minimum_precision(combo_reset, 1) .. "s"
    end,
    ["sniper_combo_min"] = function(weapon_name)
        local combo_min = get_weapon_data(weapon_name)["sniper_combo_min"]
        return combo_min and combo_min .. " " .. utils.make_polish_plural("strzał", combo_min)
    end,
    ["finisher"] = function(weapon_name)
        local finisher = get_weapon_data(weapon_name)["finisher"]
        return finisher and utils.to_precision(finisher, 1)
    end,
    ["channeling_multiplier"] = function(weapon_name)
        if(is_melee(weapon_name)) then
            local channeling_mult = get_weapon_data(weapon_name)["channeling_multiplier"] or 1.5
            return utils.to_minimum_precision(channeling_mult, 1) .. "x"
        else 
            return nil
        end
    end,
    ["block_resist"] = function(weapon_name)
        local block = get_weapon_data(weapon_name)["block_resist"]
        return block and utils.to_percent(block)
    end,
    ["disposition"] = function(weapon_name)
        local disposition = get_weapon_data(weapon_name)["disposition"]
        return disposition and "[[File: Disposition" .. get_weapon_data(weapon_name)["disposition"] .. ".png|x20px]]"
    end,
    ["damage"] = function(weapon_name, attack_type)
        local damage = (get_attack_data(weapon_name, attack_type) or {})["damage"]
        if damage == nil then return nil end
        if utils.table_size(damage) == 1 then
            local proc_type = utils.proc_to_polish(utils.table_keys(damage)[1]:lower())
            return icon.proc(proc_type) .. " " .. utils.to_minimum_precision(utils.sum(utils.unpack_any_table(damage)), 1)
        else
            local damage_bias, damage_bias_attack_type = get_damage_bias(damage)
            return utils.to_minimum_precision(utils.sum(utils.unpack_any_table(damage)), 1) .. " (" .. icon.proc(utils.proc_to_polish(damage_bias_attack_type)) .. " " .. utils.to_percent(damage_bias) ..")"
        end
    end,
    ["elemental_type"] = function(weapon_name, attack_type)
         local element = get_elemental_type(weapon_name, attack_type)
         return element and utils.proc_to_polish(element)
    end,
    ["elemental"] = function(weapon_name, attack_type)
        local data = get_attack_data(weapon_name, attack_type) or {}
        local element_type = get_elemental_type(weapon_name, attack_type)
        if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then 
            return nil 
        end
        return element_type and utils.to_precision(data["damage"][element_type], 1)
    end,
    ["slash"] = function(weapon_name, attack_type)
        local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
        local slash = data["damage"]["slash"]
        if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then 
            return nil 
        end
        return slash and utils.to_precision(slash, 1)
    end,
    ["impact"] = function(weapon_name, attack_type)
        local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
        local impact = data["damage"]["impact"]
        if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then 
            return nil 
        end
        return impact and utils.to_precision(impact, 1)
    end,
    ["puncture"] = function(weapon_name, attack_type)
        local data = get_attack_data(weapon_name, attack_type) or { damage = {} }
        local puncture = data["damage"]["puncture"]
        if data["damage"] ~= nil and utils.table_size(data["damage"]) == 1 then 
            return nil 
        end
        return puncture and utils.to_precision(puncture, 1)
    end,
    ["charging_time"] = function(weapon_name, attack_type)
        local charging_time = (get_attack_data(weapon_name, attack_type) or {})["charge_time"]
        return charging_time and utils.to_minimum_precision(charging_time, 1) .. "s"
    end,
    ["critical_chance"] = function(weapon_name, attack_type)
        local crit_chance = (get_attack_data(weapon_name, attack_type) or {})["critical_chance"]
        if crit_chance == nil and has_attack_type(weapon_name, "normal") then
            local normal_crit_chance = get_attack_data(weapon_name, "normal")["critical_chance"]
            return normal_crit_chance and utils.to_percent(normal_crit_chance)
        end
        return crit_chance and utils.to_percent(crit_chance)
    end,
    ["critical_multiplier"] = function(weapon_name, attack_type)
        local crit_mult = (get_attack_data(weapon_name, attack_type) or {})["critical_multiplier"]
        if crit_mult == nil and has_attack_type(weapon_name, "normal") then
            local normal_crit_mult = get_attack_data(weapon_name, "normal")["critical_multiplier"]
            return normal_crit_mult and utils.to_minimum_precision(normal_crit_mult, 1) .. 'x'
        end
        return crit_mult and utils.to_minimum_precision(crit_mult, 1) .. 'x'
    end,
    ["falloff"] = function(weapon_name, attack_type)
        local falloff = (get_attack_data(weapon_name, attack_type) or {})["falloff"]
        if falloff == nil then return nil end
        local ret = "Maksymalne obrażenia do " .. utils.to_minimum_precision(falloff.start_range, 1) .. "m<br>Minimalne obrażenia od " .. utils.to_minimum_precision(falloff.end_range, 1) .. "m"
        if falloff.reduction ~= nil then
            ret = ret .. "<br>" .. utils.to_percent(falloff.reduction) .. " redukcji obrażeń"
        end
        return ret
    end,
    ["status_chance"] = function(weapon_name, attack_type)
        local status_chance = (get_attack_data(weapon_name, attack_type) or {})["status_chance"]
        return status_chance and utils.to_percent(status_chance)
    end,
    ["punch_through"] = function(weapon_name, attack_type)
        local punch = (get_attack_data(weapon_name, attack_type) or {})["punch_through"]
        return punch and utils.to_minimum_precision(punch, 1) .. "m"
    end,
    ["slam_attack"] = function(weapon_name)
        local slam = get_weapon_data(weapon_name)["slam_attack"]
        return slam and utils.to_precision(slam, 1)
    end,
    ["slam_attack_radius"] = function(weapon_name)
        local radius = get_weapon_data(weapon_name)["slam_attack_radius"]
        return radius and utils.to_precision(radius, 1) .. "m"
    end,
    ["slide_attack"] = function(weapon_name)
        local slide = get_weapon_data(weapon_name)["slide_attack"]
        return slide and utils.to_precision(slide, 1)
    end,
    ["wall_attack"] = function(weapon_name)
        local wall = get_weapon_data(weapon_name)["wall_attack"]
        return wall and utils.to_precision(wall, 1)
    end,
    ["augments"] = function(weapon_name)
        local augments = get_augments(weapon_name)
        if utils.array_size(augments) == 0 then
            return nil
        end
        return utils.table_concat(utils.table_each(augments, function(augment) return mods._build_tooltip_link(augment["name"]) .. " (" .. icon.pol(augment["polarity"]) .. ")" end), "<br>")
    end,
    ["stances"] = function(weapon_name)
        local stances = get_stances(weapon_name)
        if utils.array_size(stances) == 0 then
            return nil
        end
        return utils.table_concat(utils.table_each(stances, function(stance) return mods._build_tooltip_link(stance["name"], stance["link"]) .. " (" .. icon.pol(stance["polarity"]) .. ")" end), "<br>")
    end,
    ["polarities"] = function(weapon_name)
        local polarities = get_weapon_data(weapon_name)["polarities"]
        if(polarities == nil) then
            return nil
        end
        return utils.table_concat(utils.table_each(polarities, function(polarity) return icon.pol(polarity) end))
    end,
    ["stance_polarity"] = function(weapon_name)
        local polarity = get_weapon_data(weapon_name)["stance_polarity"]
        return polarity and icon.pol(polarity)
    end,
    ["introduced"] = function(weapon_name)
        return get_weapon_data(weapon_name)["introduced"]
    end,
    ["variants"] = function(weapon_name)
        local variants = get_variants(weapon_name)
        if utils.array_size(variants) == 0 then
            return nil
        else
            return utils.table_concat(utils.table_each(variants, function(variant) return "[[" .. variant .. "]]" end), "<br>")
        end
    end,
    ['users'] = function(weapon_name)
        local users = get_weapon_data(weapon_name)["users"]
        return users and utils.table_concat(users, "<br>")
    end,
}
 
local function get_value(weapon_name, field_name, default, formatted_string)
    local value = getters[field_name:lower()](weapon_name, formatted_string)
    if value == nil and default == true then
        local default_getter = getters[field_name:lower() .. "_default"]
        if default_getter ~= nil then
            return default_getter(weapon_name, formatted_string)
        end
    end
 
    return value
end
 
local function get_attack_value(weapon_name, attack_type, field_name, default, formatted_string)
    local value = getters[field_name:lower()](weapon_name, attack_type:lower(), formatted_string)
    if value == nil and default == true then
        local default_getter = getters[field_name:lower() .. "_default"]
        if default_getter ~= nil then
            return default_getter(weapon_name, attack_type:lower(), formatted_string)
        end
    end
 
    return value
end
 
function module_export.get_value(frame)
    -- Unpack params
    local weapon_name = frame.args[1]
    local field_name = frame.args[2]
    local attack_field_name = frame.args[3]
    local default = frame.args.default
    local formatted_string = frame.args.formatted_string
 
    if default == nil or default == "" then
        default = false
    else 
        default = true
    end
 
    if formatted_string == nil or formatted_string == "" then
        formatted_string = false
    else
        formatted_string = true
    end
 
    if(weapon_name == nil or not is_weapon(weapon_name)) then
        return nil
    end
 
    -- Offload work to local func
    if(attack_field_name ~= nil and attack_field_name ~= "") then
        return get_attack_value(weapon_name, field_name, attack_field_name, default, formatted_string)
    else
        return get_value(weapon_name, field_name, default, formatted_string);
    end
end
 
function module_export.is_melee(frame)
    if is_melee(frame.args[1]) == true then
        return "true"
    else 
        return nil
    end
end
 
function module_export.get_augments(frame)
    return get_augment(frame.args[1])
end
 
function module_export.get_stances(frame)
    return get_stances(frame.args[1])
end
 
return module_export
Treści społeczności są dostępne na podstawie licencji CC-BY-SA , o ile nie zaznaczono inaczej.