- 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 |
m (Fix all problems.) |
||
Line 2: | Line 2: | ||
local Equipment = require('Module:Equipment') | local Equipment = require('Module:Equipment') | ||
local Formatting = require('Module:Formatting') | local Formatting = require('Module:Formatting') | ||
− | |||
local format = require('Module:StringInterpolation').format | local format = require('Module:StringInterpolation').format | ||
Line 12: | Line 11: | ||
| style="background: lightskyblue;" |Equipment | | style="background: lightskyblue;" |Equipment | ||
|- | |- | ||
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card1} |
− | ${ | + | ${ship_equips1} |
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card4} |
− | ${ | + | ${ship_equips4} |
|- | |- | ||
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card2} |
− | ${ | + | ${ship_equips2} |
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card5} |
− | ${ | + | ${ship_equips5} |
|- | |- | ||
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card3} |
− | ${ | + | ${ship_equips3} |
− | | rowspan="4" style="background: whitesmoke;" |${ | + | | rowspan="4" style="background: whitesmoke;" |${ship_card6} |
− | ${ | + | ${ship_equips6} |
|}]], | |}]], | ||
_slot_template = [[|- | _slot_template = [[|- | ||
Line 33: | Line 32: | ||
} | } | ||
− | function NanaminFleet:ship_card( | + | function NanaminFleet:ship_card(ship) |
− | return Formatting:format_image( | + | return "" |
+ | --return Formatting:format_image(ship:card()) | ||
end | end | ||
− | function NanaminFleet:slot_equipment( | + | function NanaminFleet:slot_equipment(ship) |
local slots = {} | local slots = {} | ||
local ship_slot_count = ship:slots() | local ship_slot_count = ship:slots() | ||
for i = 1, 4 do | for i = 1, 4 do | ||
+ | local equip, plane_count, icon, equip_type | ||
if i > ship_slot_count then | if i > ship_slot_count then | ||
equip, plane_count, icon, equip_type = "- Locked -", "-", 0, false | equip, plane_count, icon, equip_type = "- Locked -", "-", 0, false | ||
else | else | ||
− | + | equip, plane_count = ship:slot(i) | |
− | equip, plane_count = | + | equip = Equipment:create(ship.equip[i].name) |
− | equip = | ||
if equip then | if equip then | ||
icon = equip:icon() | icon = equip:icon() | ||
− | equip_type = | + | equip_type = false |
equip = Formatting:format_link(equip:link()) | equip = Formatting:format_link(equip:link()) | ||
else | else | ||
Line 70: | Line 70: | ||
function NanaminFleet:Infobox(args) | function NanaminFleet:Infobox(args) | ||
local ships = {} | local ships = {} | ||
+ | local vars = {} | ||
for i = 1, 6 do | for i = 1, 6 do | ||
ships[i] = Ship(args["ship" .. tostring(i)], args["ship" .. tostring(i) .. "_remodel"]) | ships[i] = Ship(args["ship" .. tostring(i)], args["ship" .. tostring(i) .. "_remodel"]) | ||
− | -- | + | |
− | ships[i] | + | --Get the equips categorized under each ship specifically so the ship number doesn't have to be passed. |
+ | ships[i].equip = {} | ||
for a = 1, 4 do | for a = 1, 4 do | ||
ships[i].equip[a] = args["ship" .. tostring(i) .. "_equip" .. tostring(a)] | ships[i].equip[a] = args["ship" .. tostring(i) .. "_equip" .. tostring(a)] | ||
end | end | ||
+ | |||
+ | vars["ship_card" .. i] = self:ship_card(ships[i]) | ||
+ | vars["ship_equips" .. i] = self:slot_equipment(ships[i]) | ||
end | end | ||
− | mw.log( | + | |
− | return format(self._template) | + | mw.log(format(self._template, vars)) |
+ | return format(self._template, vars) | ||
+ | end | ||
+ | |||
+ | function test(frame) | ||
+ | args = { | ||
+ | ship1 = "Haruna", | ||
+ | ship1_remodal = "Kai Ni", | ||
+ | ship1_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship1_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship1_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship1_equip4 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship2 = "Haruna", | ||
+ | ship2_remodal = "Kai Ni", | ||
+ | ship2_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship2_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship2_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship2_equip4 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship3 = "Haruna", | ||
+ | ship3_remodal = "Kai Ni", | ||
+ | ship3_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship3_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship3_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship3_equip4 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship4 = "Haruna", | ||
+ | ship4_remodal = "Kai Ni", | ||
+ | ship4_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship4_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship4_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship4_equip4 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship5 = "Haruna", | ||
+ | ship5_remodal = "Kai Ni", | ||
+ | ship5_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship5_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship5_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship5_equip4 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship6 = "Haruna", | ||
+ | ship6_remodal = "Kai Ni", | ||
+ | ship6_equip1 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship6_equip2 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship6_equip3 = {name = "35.6cm Twin Gun Mount"}, | ||
+ | ship6_equip4 = {name = "35.6cm Twin Gun Mount"} | ||
+ | } | ||
+ | NanaminFleet:Infobox(args) | ||
end | end | ||
return NanaminFleet | return NanaminFleet |
Revision as of 07:31, 6 April 2015
Documentation for this module may be created at Module:NanaminFleet/doc
local Ship = require('Module:Ship')
local Equipment = require('Module:Equipment')
local Formatting = require('Module:Formatting')
local format = require('Module:StringInterpolation').format
local NanaminFleet = {
_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_card1}
${ship_equips1}
| rowspan="4" style="background: whitesmoke;" |${ship_card4}
${ship_equips4}
|-
| rowspan="4" style="background: whitesmoke;" |${ship_card2}
${ship_equips2}
| rowspan="4" style="background: whitesmoke;" |${ship_card5}
${ship_equips5}
|-
| rowspan="4" style="background: whitesmoke;" |${ship_card3}
${ship_equips3}
| rowspan="4" style="background: whitesmoke;" |${ship_card6}
${ship_equips6}
|}]],
_slot_template = [[|-
| style="background: whitesmoke;" |${icon} ${equip}
| style="background: whitesmoke;" |${plane_count}
]]
}
function NanaminFleet:ship_card(ship)
return ""
--return Formatting:format_image(ship:card())
end
function NanaminFleet:slot_equipment(ship)
local slots = {}
local ship_slot_count = ship:slots()
for i = 1, 4 do
local equip, plane_count, icon, equip_type
if i > ship_slot_count then
equip, plane_count, icon, equip_type = "- Locked -", "-", 0, false
else
equip, plane_count = ship:slot(i)
equip = Equipment:create(ship.equip[i].name)
if equip then
icon = equip:icon()
equip_type = false
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 = {}
local vars = {}
for i = 1, 6 do
ships[i] = Ship(args["ship" .. tostring(i)], args["ship" .. tostring(i) .. "_remodel"])
--Get the equips categorized under each ship specifically so the ship number doesn't have to be passed.
ships[i].equip = {}
for a = 1, 4 do
ships[i].equip[a] = args["ship" .. tostring(i) .. "_equip" .. tostring(a)]
end
vars["ship_card" .. i] = self:ship_card(ships[i])
vars["ship_equips" .. i] = self:slot_equipment(ships[i])
end
mw.log(format(self._template, vars))
return format(self._template, vars)
end
function test(frame)
args = {
ship1 = "Haruna",
ship1_remodal = "Kai Ni",
ship1_equip1 = {name = "35.6cm Twin Gun Mount"},
ship1_equip2 = {name = "35.6cm Twin Gun Mount"},
ship1_equip3 = {name = "35.6cm Twin Gun Mount"},
ship1_equip4 = {name = "35.6cm Twin Gun Mount"},
ship2 = "Haruna",
ship2_remodal = "Kai Ni",
ship2_equip1 = {name = "35.6cm Twin Gun Mount"},
ship2_equip2 = {name = "35.6cm Twin Gun Mount"},
ship2_equip3 = {name = "35.6cm Twin Gun Mount"},
ship2_equip4 = {name = "35.6cm Twin Gun Mount"},
ship3 = "Haruna",
ship3_remodal = "Kai Ni",
ship3_equip1 = {name = "35.6cm Twin Gun Mount"},
ship3_equip2 = {name = "35.6cm Twin Gun Mount"},
ship3_equip3 = {name = "35.6cm Twin Gun Mount"},
ship3_equip4 = {name = "35.6cm Twin Gun Mount"},
ship4 = "Haruna",
ship4_remodal = "Kai Ni",
ship4_equip1 = {name = "35.6cm Twin Gun Mount"},
ship4_equip2 = {name = "35.6cm Twin Gun Mount"},
ship4_equip3 = {name = "35.6cm Twin Gun Mount"},
ship4_equip4 = {name = "35.6cm Twin Gun Mount"},
ship5 = "Haruna",
ship5_remodal = "Kai Ni",
ship5_equip1 = {name = "35.6cm Twin Gun Mount"},
ship5_equip2 = {name = "35.6cm Twin Gun Mount"},
ship5_equip3 = {name = "35.6cm Twin Gun Mount"},
ship5_equip4 = {name = "35.6cm Twin Gun Mount"},
ship6 = "Haruna",
ship6_remodal = "Kai Ni",
ship6_equip1 = {name = "35.6cm Twin Gun Mount"},
ship6_equip2 = {name = "35.6cm Twin Gun Mount"},
ship6_equip3 = {name = "35.6cm Twin Gun Mount"},
ship6_equip4 = {name = "35.6cm Twin Gun Mount"}
}
NanaminFleet:Infobox(args)
end
return NanaminFleet