Line 33: |
Line 33: |
| -- The ship infobox stuff... | | -- The ship infobox stuff... |
| | | |
− | local function renderStats(ship, shipNum) | + | local function renderStats(ship) |
| local shipName = ship.name[3] | | local shipName = ship.name[3] |
| local CardImg = '<div class="top-image">[[File:Ship Card ' .. shipName .. ".png|218x300px|link=]]</div>" | | local CardImg = '<div class="top-image">[[File:Ship Card ' .. shipName .. ".png|218x300px|link=]]</div>" |
Line 43: |
Line 43: |
| local Banners = | | local Banners = |
| '<td colspan="3" class="double-image" style="width:240px;height:60px">' .. BannerImg .. BannerDmgImg .. "</td>" | | '<td colspan="3" class="double-image" style="width:240px;height:60px">' .. BannerImg .. BannerDmgImg .. "</td>" |
− | local sortNo = ship.sortno or U.split(shipNum, "-")[1] or "?" | + | local sortNo = ship.sortno or U.split(ship.no, "-")[1] or "?" |
| local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNo .. "</th>" .. Banners .. "</tr>" | | local row1 = "<tr>" .. Cards .. '<th style="text-align: center;">' .. sortNo .. "</th>" .. Banners .. "</tr>" |
| -- Formatting Japanese | | -- Formatting Japanese |
Line 88: |
Line 88: |
| local JaName = "" | | local JaName = "" |
| if | | if |
− | shipNum == "147" or shipNum == "311" or shipNum == "312" or shipNum == "313" or shipNum == "313a" or | + | ship.no == "147" or ship.no == "311" or ship.no == "312" or ship.no == "313" or ship.no == "313a" or |
− | shipNum == "316" | + | ship.no == "316" |
| then --Russian ship markup | | then --Russian ship markup |
| JaName = | | JaName = |
Line 423: |
Line 423: |
| end | | end |
| | | |
− | local ShipData = mw.loadData("Module:Data/Ship") | + | local ShipData = require("Module:Data/Ship") |
− | local shipsByNo = mw.loadData("Module:Collection/ShipsByNo") | + | local shipsByNo = require("Module:Collection/ShipsByNo") |
− | local shipsById = mw.loadData("Module:Collection/ShipsByApiId") | + | local shipsById = require("Module:Collection/ShipsByApiId") |
| | | |
| local Ship = require("Module:Ship") | | local Ship = require("Module:Ship") |
| | | |
− | local function loadShipData(ship) | + | local function loadShipData(no) |
− | local shipName = ship.name[3] | + | local ship = Ship(shipsById[(U.find(shipsByNo, ShipData[no].name[3], "name") or {}).id] or "???") |
− | local shipKey = shipsById[(U.find(shipsByNo, shipName, "name") or {}).id] or "???"
| + | local data = {} |
− | local success, shipData = Ship(shipKey) | + | data.no = no |
− | if not success then | + | data.name = {ship:japanese_name() or "", ship:reading() or "", ship:name() or ""} |
− | return | + | data.class = ship:class():name() or "" |
| + | data.type = ship:formatted_type() or "" |
| + | data.rarity = ship:rarity() or "" |
| + | data.hp = {ship:hp() or "", ship:hp_max() or ""} |
| + | data.fp = {ship:firepower() or "", ship:firepower_max() or ""} |
| + | data.armor = {ship:armor() or "", ship:armor_max() or ""} |
| + | data.torpedo = {ship:torpedo() or "", ship:torpedo_max() or ""} |
| + | data.evasion = {ship:evasion() or "", ship:evasion_max() or ""} |
| + | data.aa = {ship:aa() or "", ship:aa_max() or ""} |
| + | data.asw = {ship:asw() or "", ship:asw_max() or ""} |
| + | data.spd = ship:formatted_speed() or "" |
| + | data.los = {ship:los() or "", ship:los_max() or ""} |
| + | data.range = ship:formatted_range() or "" |
| + | data.luck = {ship:luck() or "", ship:luck_max() or ""} |
| + | data.aircraft = {} |
| + | data.equip = {} |
| + | for _, v in ipairs(ship._equipment) do |
| + | table.insert(data.equip, v.name or "") |
| + | table.insert(data.aircraft, v.size or "") |
| end | | end |
− | ship.name = {shipData._japanese_name or "??", shipData._reading or "??", shipData:name() or "??"} | + | data.artist = ship:artist() or "" |
− | -- ship.class = "Independence" | + | data.seiyuu = ship:voice_actor() or "" |
− | -- ship.type = "Light Carrier"
| + | data.buildtime = { |
− | -- ship.rarity = 5
| + | ship._build_time or "", |
− | -- ship.hp = {31, 41}
| + | ship._buildable == true or false, |
− | -- ship.fp = {14, 32}
| + | ship._buildable_lsc == true or false |
− | -- ship.armor = {14, 30} | + | } |
− | -- ship.torpedo = 0 | + | data.remodellv = ship:remodel_level() or "" |
− | -- ship.evasion = {22, 43} | + | data.consumption = {ship:fuel() or "", ship:ammo() or ""} |
− | -- ship.aa = {32, 52} | + | data.remodelreq = {ship._remodel_steel or 0, ship._remodel_ammo or 0} |
− | -- ship.aircraft = {23, 7, 2} | + | data.dismantle = { |
− | -- ship.asw = {16, 52}
| + | ship._scrap_fuel or "", |
− | -- ship.spd = "Fast"
| + | ship._scrap_ammo or "", |
− | -- ship.los = {40, 68}
| + | ship._scrap_steel or "", |
− | -- ship.range = "Medium"
| + | ship._scrap_baux or "" |
− | -- ship.luck = {27, 87} | + | } |
− | -- ship.equip = {"TBF", "SBD-5", ""}
| + | data.modernization = { |
− | -- ship.artist = ""
| + | ship._firepower_mod or "", |
− | -- ship.seiyuu = ""
| + | ship._torpedo_mod or "", |
− | -- ship.buildtime = {70, false, false}
| + | ship._aa_mod or "", |
− | -- ship.remodellv = ""
| + | ship._armor_mod or "", |
− | -- ship.consumption = {35, 40}
| + | ship._luck_mod or nil |
− | -- ship.remodelreq = ""
| + | } |
− | -- ship.dismantle = {3, 4, 14, 4} | + | return data |
− | -- ship.modernization = {0, 0, 3, 2} | |
| end | | end |
| | | |
| local function render(frame) | | local function render(frame) |
− | local shipNum = frame.args[1] | + | local ship = loadShipData(frame.args[1]) |
− | local ship = ShipData[shipNum]
| |
− | -- loadShipData(ship)
| |
| return '<div style="display:inline-block;vertical-align:top"><table style="{{border-radius|10px 10px 10px 10px}} border:1px solid #aaaaaa;min-width:495px"><tr><td>' .. | | return '<div style="display:inline-block;vertical-align:top"><table style="{{border-radius|10px 10px 10px 10px}} border:1px solid #aaaaaa;min-width:495px"><tr><td>' .. |
− | renderStats(ship, shipNum) .. | + | renderStats(ship) .. |
| "</td></tr><tr><td>" .. | | "</td></tr><tr><td>" .. |
| renderEquipment(ship) .. | | renderEquipment(ship) .. |
Line 476: |
Line 491: |
| end | | end |
| | | |
− | return {KanmusuInfo = render} | + | local function test() |
| + | return render({args = {"525"}}) |
| + | end |
| + | |
| + | -- print(p.test()) |
| + | |
| + | return {KanmusuInfo = render, test = test} |