- 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"
Jump to navigation
Jump to search
m (Remove some hard-coding.) |
m (Did something stupid.) |
||
Line 72: | Line 72: | ||
local ships = {} | local ships = {} | ||
for i = 1, 6 do | for i = 1, 6 do | ||
− | ships[i] = Ship(args. | + | ships[i] = Ship(args["ship" .. tostring(i)], args["ship" .. tostring(i) .. "_remodel"]) |
end | end | ||
return format(self._template) | return format(self._template) |
Revision as of 04:06, 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{
_slots_per_ship = 4,
_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][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 -"
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"])
end
return format(self._template)
end
return NanaminFleet