Module:Item/Weapon

Documentation for this module may be created at Module:Item/Weapon/doc

require( 'strict' )

local p = {}

local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti

function p._main(infobox, args)
    checkType('p._main', 1, infobox, 'table')
    checkType('p._main', 1, args, 'table')

    if args['range'] then
        args['range'] = args['range'] .. 'm'
    end
    if args['zoom'] then
        args['zoom'] = args['zoom'] .. 'x'
    end
    if args['rof'] then
        args['rof'] = args['rof'] .. 'RPM'
    end
    if args['hipfire spread'] then
        args['hipfire spread'] = args['hipfire spread'] .. '°'
    end
    if args['ads spread'] then
        args['ads spread'] = args['ads spread'] .. '°'
    end
    if args['crouch spread'] then
        args['crouch spread'] = args['crouch spread'] .. '%'
    end
    if args['moving inaccuracy'] then
        args['moving inaccuracy'] = args['moving inaccuracy'] .. '%'
    end
    if args['equip speed'] then
        args['equip speed'] = args['equip speed'] .. 's'
    end
    if args['ads speed'] then
        args['ads speed'] = args['ads speed'] .. 's'
    end
    if args['weight'] then
        args['weight'] = args['weight'] .. '%'
    end
    if args['recoil'] then
        args['recoil'] = args['recoil'] .. '%'
    end
    if args['aim assist'] then
        args['aim assist'] = args['aim assist'] .. '°'
    end
    if args['reload speed'] then
        args['reload speed'] = args['reload speed'] .. 's'
    end

    infobox:renderSection({
        content = {
            infobox:renderItem({
                label = "Ammunition",
                data = args['ammunition']
            }),
            infobox:renderItem({
                label = "Range",
                data = args['range']
            }),
            infobox:renderItem({
                label = "Magazine",
                data = args['magazine size']
            }),
            infobox:renderItem({
                label = "Zoom",
                data = args['zoom']
            })
        },
        col = 2
    })

    infobox:renderSection({
        title = "Firepower",
        content = {
            infobox:renderItem({
                label = "Damage",
                data = args['damage']
            }),
            infobox:renderItem({
                label = "Precision",
                data = args['precision']
            }),
            infobox:renderItem({
                label = "Rate of Fire",
                data = args['rof']
            })
        },
        col = 2
    })

    infobox:renderSection({
        title = "Accuracy",
        content = {
            infobox:renderItem({
                label = "Hipfire Spread",
                data = args['hipfire spread']
            }),
            infobox:renderItem({
                label = "ADS Spread",
                data = args['ads spread']
            }),
            infobox:renderItem({
                label = "Crouch Spread Bonus",
                data = args['crouch spread']
            }),
            infobox:renderItem({
                label = "Moving Inaccuracy",
                data = args['moving inaccuracy']
            })
        },
        col = 2
    })

    infobox:renderSection({
        title = "Handling",
        content = {
            infobox:renderItem({
                label = "Equip Speed",
                data = args['equip speed']
            }),
            infobox:renderItem({
                label = "ADS Speed",
                data = args['ads speed']
            }),
            infobox:renderItem({
                label = "Weight",
                data = args['weight']
            }),
            infobox:renderItem({
                label = "Recoil",
                data = args['recoil']
            }),
            infobox:renderItem({
                label = "Aim Assist",
                data = args['aim assist']
            }),
            infobox:renderItem({
                label = "Reload Speed",
                data = args['reload speed']
            })
        },
        col = 2
    })

    if args['nocat'] then
        return {}
    end

    local categories = {}

    table.insert(categories, "Marathon (2026)")

    if args['subtype'] then
        table.insert(categories, string.format("New Weapons (%s)", args['subtype']))
    end
    if args['ammunition'] then
        table.insert(categories, string.format("New Weapons (%s Ammunition)", args['ammunition']))
    end

    return categories
end

return p