Line 1: |
Line 1: |
| local U = require('Module:Core') | | local U = require('Module:Core') |
− | local loadData = require('Module:Data').load
| |
| local getArgs = require('Module:GetArgs') | | local getArgs = require('Module:GetArgs') |
| local Ship = require('Module:Ship') | | local Ship = require('Module:Ship') |
Line 7: |
Line 6: |
| local function getShipCard(ship) | | local function getShipCard(ship) |
| local s = Ship(ship) | | local s = Ship(ship) |
− | local i = s:id() or s:true_id() | + | -- local i = s:id() or s:true_id() |
− | local is = i and (i < 10 and '00' .. i or i < 100 and '0' .. i or i) or '?' | + | -- local is = i and (i < 10 and '00' .. i or i < 100 and '0' .. i or i) or '?' |
− | return '[[File:KanMusu' .. is .. 'Banner.png|160px|link=' .. s:base_name() .. ']]<br>[[' .. s:base_name() .. '|' .. s:name() .. ']]' | + | return '[[File:Ship Banner ' .. s:name() .. '.png|160px|link=' .. s:base_name() .. ']]<br>[[' .. s:base_name() .. '|' .. s:name() .. ']]' |
| end | | end |
| | | |
| local function getEquipmentCard(eq) | | local function getEquipmentCard(eq) |
− | return '[[File:Equipment' .. (Equipment(eq):id() or '?') .. '-1.png|100px|link=' .. eq .. ']]' | + | local e = Equipment(eq) |
| + | return '[[File:Equipment Card ' .. e:name():gsub("/", " ") .. '.png|100px|link=' .. e:name() .. ']]' |
| end | | end |
| | | |
| local function getFleetName(fleet, event) | | local function getFleetName(fleet, event) |
− | local names = require('Module:Fleet/Names')[event] or {} | + | local names = require('Module:FleetNames')[event] or {} |
− | if names[1] then | + | if names == 'flagship' then |
| + | return Ship(fleet[1].ship):base_name() .. ' FS' |
| + | elseif names[1] then |
| for _, f in ipairs(names) do | | for _, f in ipairs(names) do |
| for i, ship in ipairs(f.ships) do | | for i, ship in ipairs(f.ships) do |
Line 49: |
Line 51: |
| | | |
| local function formatHp(hps, maxHp) | | local function formatHp(hps, maxHp) |
− | return string.format('<span class="explain" title="%s">~/%s</span>', U.ijoin(hps, ', '), maxHp) | + | local minHp = U.imin(hps) |
| + | if minHp / maxHp <= 0.5 then |
| + | return string.format('{{color|red|{{tooltip|~/%s|%s}}}}', maxHp, U.ijoin(hps, ', ')) |
| + | elseif minHp / maxHp <= 0.75 then |
| + | return string.format('{{color|coral|{{tooltip|~/%s|%s}}}}', maxHp, U.ijoin(hps, ', ')) |
| + | else |
| + | return string.format('{{tooltip|~/%s|%s}}', maxHp, U.ijoin(hps, ', ')) |
| + | end |
| + | end |
| + | |
| + | local function formatVoice(e) |
| + | if type(e.voice) == 'number' and e.voice < 10 then |
| + | return string.format('{{audio|file=Ship Voice %s Spring 2019 Event Friend Fleet %s.mp3}}', e.ship, e.voice) |
| + | else |
| + | return string.format('{{audio|file=Ship Voice %s %s.mp3}}', e.ship, e.voice) |
| + | end |
| end | | end |
| | | |
| local tableStart = | | local tableStart = |
− | [=[{|class="wikitable mw-collapsible mw-collapsed" style="text-align:center" | + | [=[{|class="wikitable mw-collapsible mw-collapsed" style="text-align:center;min-width:700px" |
− | |-
| |
− | !colspan="11"|(%s)
| |
| |- | | |- |
| + | !colspan="11"|%s]=] |
| + | |
| + | local tableHeader = [=[|- |
| !Ship | | !Ship |
| !Lv. | | !Lv. |
− | !colspan="4"|Equipment | + | !Equipment |
| ![[File:Icon HP.png]] | | ![[File:Icon HP.png]] |
| ![[File:Icon Gun.png]] | | ![[File:Icon Gun.png]] |
Line 67: |
Line 85: |
| | | |
| local function render(args) | | local function render(args) |
− | local data = loadData('Fleet/Friend', args.friend)
| + | local success, data = U.requireModule('Data/FriendFleet/' .. args.friend) |
| + | if not success then |
| + | return "''No data''" |
| + | end |
| local groups = {} | | local groups = {} |
| for _, e in pairs(data) do | | for _, e in pairs(data) do |
− | if not args.map or U.ifind(e.maps, args.map) then | + | if not args.map and not args.node or U.ifind(e.maps, args.map) or U.ifind(e.notes, args.node) then |
| local fleetType = getFleetName(e.fleet, args.friend) | | local fleetType = getFleetName(e.fleet, args.friend) |
| groups[fleetType] = groups[fleetType] or {} | | groups[fleetType] = groups[fleetType] or {} |
Line 76: |
Line 97: |
| end | | end |
| end | | end |
− | local fleetTypes = U.isort(U.keys(groups))
| |
| local result = {} | | local result = {} |
| local first = true | | local first = true |
− | for _, fleetType in ipairs(fleetTypes) do | + | for _, fleetType in ipairs(U.isort(U.keys(groups))) do |
| local fleets = groups[fleetType] | | local fleets = groups[fleetType] |
| table.sort( | | table.sort( |
Line 117: |
Line 137: |
| first = false | | first = false |
| end | | end |
− | table.insert(result, string.format('|-\n!colspan="11"|%s', fleetType .. ' (Variant ' .. i .. ')')) | + | local fleetNote = U.ijoin(fleet.notes, ', ') .. ' : ' ..fleetType .. ' (Variant ' .. i .. ', ' .. (fleet.date or '??') .. '~)' |
| + | if fleet.f2p and fleet.f2p > 0 then |
| + | fleetNote = fleetNote .. " '''{{color|green|{{tooltip|Regular|" .. fleet.f2p .. " samples}}}}'''" |
| + | end |
| + | if fleet.p2w and fleet.p2w > 0 then |
| + | fleetNote = fleetNote .. " '''{{color|red|{{tooltip|Powerful|" .. fleet.p2w .. " samples}}}}'''" |
| + | end |
| + | if table.getn(fleet.voices or {}) > 0 then |
| + | fleetNote = fleetNote .. ' ' .. U.ijoin(U.imap(fleet.voices, formatVoice), ' ') |
| + | end |
| + | table.insert(result, string.format('|-\n!colspan="11"|%s', fleetNote)) |
| + | table.insert(result, tableHeader) |
| for _, ship in ipairs(fleet.fleet) do | | for _, ship in ipairs(fleet.fleet) do |
| table.insert( | | table.insert( |
| result, | | result, |
| string.format( | | string.format( |
− | '|-\n|%s||%s||%s||%s||%s||%s||%s||%s||%s||%s||%s', | + | '|-\n|%s||%s||style="text-align:left;white-space:nowrap"|%s%s%s%s%s%s||%s||%s||%s||%s||%s', |
| getShipCard(ship.ship), | | getShipCard(ship.ship), |
| ship.level, | | ship.level, |
− | ship.equipment[1] and getEquipmentCard(ship.equipment[1]) or 'style="background:grey;width:100px"| ', | + | ship.equipment[1] and getEquipmentCard(ship.equipment[1]) or '', |
− | ship.equipment[2] and getEquipmentCard(ship.equipment[2]) or 'style="background:grey;width:100px"| ', | + | ship.equipment[2] and getEquipmentCard(ship.equipment[2]) or '', |
− | ship.equipment[3] and getEquipmentCard(ship.equipment[3]) or 'style="background:grey;width:100px"| ', | + | ship.equipment[3] and getEquipmentCard(ship.equipment[3]) or '', |
− | ship.equipment[4] and getEquipmentCard(ship.equipment[4]) or 'style="background:grey;width:100px"| ', | + | ship.equipment[4] and getEquipmentCard(ship.equipment[4]) or '', |
| + | ship.equipment[5] and getEquipmentCard(ship.equipment[5]) or '', |
| + | ship.extraSlot and string.format('<span style="display:inline-block;border-radius:10px;border:5px solid steelblue">%s</span>', getEquipmentCard(ship.extraSlot)) or '', |
| type(ship.hp) == 'table' and formatHp(ship.hp, ship.maxHp) or ship.hp ~= ship.maxHp and string.format('%s/%s', ship.hp, ship.maxHp) or | | type(ship.hp) == 'table' and formatHp(ship.hp, ship.maxHp) or ship.hp ~= ship.maxHp and string.format('%s/%s', ship.hp, ship.maxHp) or |
| ship.maxHp, | | ship.maxHp, |