• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Difference between revisions of "Module:NanaminFleet"

From Kancolle Wiki
Jump to navigation Jump to search
m
m
Line 7: Line 7:
  
 
local NanaminFleet = BaseTable{
 
local NanaminFleet = BaseTable{
    _slots_per_ship = 4,
 
 
     _template = [[{| class="mw-collapsible mw-collapsed"
 
     _template = [[{| class="mw-collapsible mw-collapsed"
 
     | style="background: lightskyblue;" |Ship
 
     | style="background: lightskyblue;" |Ship
Line 28: Line 27:
 
     | rowspan="4" style="background: whitesmoke;" |${ship_card(6)}
 
     | rowspan="4" style="background: whitesmoke;" |${ship_card(6)}
 
     ${slot_equipment(6)}
 
     ${slot_equipment(6)}
     ]],
+
     |}]],
 
     _slot_template = [[|-
 
     _slot_template = [[|-
 
     | style="background: whitesmoke;" |${icon} ${equip}
 
     | style="background: whitesmoke;" |${icon} ${equip}

Revision as of 04:25, 6 April 2015

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

local BaseTable = require('Module:BaseTable')
local Ship = require('Module:Ship')
local Equipment = require('Module:Equipment')
local Formatting = require('Module:Formatting')

local format = require('Module:StringInterpolation').format

local NanaminFleet = BaseTable{
    _template = [[{| class="mw-collapsible mw-collapsed"
    | style="background: lightskyblue;" |Ship
    | style="background: lightskyblue;" |Equipment
    | style="background: lightskyblue;" |Ship
    | style="background: lightskyblue;" |Equipment
    |-
    | rowspan="4" style="background: whitesmoke;" |${ship_card(1)}
    ${slot_equipment(1)}
    | rowspan="4" style="background: whitesmoke;" |${ship_card(4)}
    ${slot_equipment(4)}
    |-
    | rowspan="4" style="background: whitesmoke;" |${ship_card(2)}
    ${slot_equipment(2)}
    | rowspan="4" style="background: whitesmoke;" |${ship_card(5)}
    ${slot_equipment(5)}
    |-
    | rowspan="4" style="background: whitesmoke;" |${ship_card(3)}
    ${slot_equipment(3)}
    | rowspan="4" style="background: whitesmoke;" |${ship_card(6)}
    ${slot_equipment(6)}
    |}]],
    _slot_template = [[|-
    | style="background: whitesmoke;" |${icon} ${equip}
    | style="background: whitesmoke;" |${plane_count}
    ]]
}

function NanaminFleet:ship_card(ships, fleet_slot)
    return Formatting:format_image(ships[fleet_slot]:card())
end

function NanaminFleet:slot_equipment(ships, fleet_slot)
    local slots = {}
    local ship_slot_count = ship:slots()
    for i = 1, 4 do
        if i > ship_slot_count then
            equip, plane_count, icon, equip_type = "- Locked -", "-", 0, false
        else
            local equip, plane_count, icon, equip_type
            equip, plane_count = ships[fleet_slot]:slot(i)
            equip = ships[fleet_slot].equip[i].name
            if equip then
                icon = equip:icon()
                equip_type = equip:type()
                equip = Formatting:format_link(equip:link())
            else
                icon = false
                equip_type = false
                equip = "- Unequipped -"
                plane_count = 0
            end
            icon = Formatting:format_image{Formatting:format_equipment_icon(icon), caption = Formatting:format_equipment_type(equip_type)}
        end
        table.insert(slots, format{self._slot_template,
            icon = icon,
            equip = equip,
            plane_count = plane_count
        })
    end
    return table.concat(slots)
end

function NanaminFleet:Infobox(args)
    local ships = {}
    for i = 1, 6 do
        ships[i] = Ship(args["ship" .. tostring(i)], args["ship" .. tostring(i) .. "_remodel"])
        --Also get all the equips for the ship
        ships[i].equipment = {}
        for a = 1, 4 do
            ships[i].equip[a] = args["ship" .. tostring(i) .. "_equip" .. tostring(a)]
        end
    end
    return format(self._template)
end

return NanaminFleet