Line 2: |
Line 2: |
| | | |
| local U = require('Module:Core') | | local U = require('Module:Core') |
− | local JSON = require('Module:Core/JSON')
| |
| local loadData = require('Module:Data').load | | local loadData = require('Module:Data').load |
| local getArgs = require('Module:GetArgs') | | local getArgs = require('Module:GetArgs') |
Line 9: |
Line 8: |
| local EquipmentCardKai = require('Module:EquipmentCardKai') | | local EquipmentCardKai = require('Module:EquipmentCardKai') |
| local ShipsByApiId = require('Module:Collection/ShipsByApiId') | | local ShipsByApiId = require('Module:Collection/ShipsByApiId') |
− | local EquipmentByApiId = require('Module:Collection/EquipmentByApiId')
| |
| | | |
− | local function getShipCard(ship) | + | local function getShipCard(ship, hp, maxHp) |
| + | maxHp = maxHp or 999 |
| + | local minHp = type(hp) == 'table' and U.imin(hp) or hp or maxHp or 999 |
| local id = tonumber(ship) | | local id = tonumber(ship) |
| if id then | | if id then |
| ship = ShipsByApiId[id] | | ship = ShipsByApiId[id] |
| end | | end |
− | return ShipBattleCardKai:Asset({ ship, hd = true, size = '160px' }) | + | return ShipBattleCardKai:Asset({ |
| + | ship, |
| + | hd = true, |
| + | size = '160px', |
| + | damaged = minHp / maxHp <= 0.5 and 'true' or 'false', |
| + | layers = minHp / maxHp <= 0.5 and 'smudge_medium status_medium_damage' or minHp / maxHp <= 0.75 and 'status_light_damage' or '', |
| + | }) |
| end | | end |
| | | |
| local function getEquipmentCard(eq, cardSize) | | local function getEquipmentCard(eq, cardSize) |
− | local id = tonumber(eq)
| |
− | if id then
| |
− | eq = EquipmentByApiId[id]
| |
− | end
| |
| return EquipmentCardKai:Asset({ eq, size = cardSize or '100px' }) | | return EquipmentCardKai:Asset({ eq, size = cardSize or '100px' }) |
| end | | end |
Line 48: |
Line 50: |
| ]=] | | ]=] |
| | | |
− | local fleetNames = require('Module:Fleet/Names') | + | local fleetNames = require('Module:FleetNames') |
| | | |
| local function getFleetName(fleet, event) | | local function getFleetName(fleet, event) |
Line 85: |
Line 87: |
| | | |
| local function formatHp(hps, maxHp) | | local function formatHp(hps, maxHp) |
− | return string.format( | + | local minHp = U.imin(hps) |
− | '<span class="explain" title="%s">~/%s</span>',
| + | if minHp / maxHp <= 0.5 then |
− | U.ijoin(hps, ', '),
| + | return string.format('{{color|red|{{tooltip|~/%s|%s}}}}', maxHp, U.ijoin(hps, ', ')) |
− | maxHp
| + | 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) |
| + | local file = type(e.voice) == 'number' and e.voice < 10 and |
| + | string.format('Ship Voice %s Spring 2019 Event Friend Fleet %s.ogg', e.ship, e.voice) or |
| + | string.format('Ship Voice %s %s.ogg', e.ship, e.voice) |
| + | return string.format('<span data-voice="%s">{{audio|file=%s}}</span>', file, file) |
| end | | end |
| | | |
| local function renderFriend(args, frame) | | local function renderFriend(args, frame) |
| -- local data = loadData('Fleet/Friend/' .. args.friend) | | -- local data = loadData('Fleet/Friend/' .. args.friend) |
− | local success, data = U.requireModule('Data/Fleet/Friend/' .. args.friend) | + | local success, data = U.requireModule('Data/FriendFleet/' .. args.friend) |
| if not success then | | if not success then |
| return "''No data''" | | return "''No data''" |
Line 100: |
Line 112: |
| local groups = {} | | local groups = {} |
| for i, e in pairs(data) do | | for i, 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 111: |
Line 123: |
| local fleets = groups[fleetType] | | local fleets = groups[fleetType] |
| table.sort(fleets, function(a, b) | | table.sort(fleets, function(a, b) |
| + | local node1 = U.ijoin(a.notes, ', ') |
| + | local node2 = U.ijoin(b.notes, ', ') |
| local l1 = table.getn(a.fleet) | | local l1 = table.getn(a.fleet) |
| local l2 = table.getn(b.fleet) | | local l2 = table.getn(b.fleet) |
| local ships1 = U.ijoin(U.imap(a.fleet, function (e) return e.ship end), ', ') | | local ships1 = U.ijoin(U.imap(a.fleet, function (e) return e.ship end), ', ') |
| local ships2 = U.ijoin(U.imap(b.fleet, function (e) return e.ship end), ', ') | | local ships2 = U.ijoin(U.imap(b.fleet, function (e) return e.ship end), ', ') |
− | if ships1 == ships2 then | + | if node1 == node2 then |
− | return l1 < l2
| + | if ships1 == ships2 then |
| + | return l1 < l2 |
| + | end |
| + | return ships1 < ships2 |
| end | | end |
− | return ships1 < ships2 | + | return node1 < node2 |
| end) | | end) |
| table.insert(result, string.format('{{!}}-{{!}} %s =', fleetType)) | | table.insert(result, string.format('{{!}}-{{!}} %s =', fleetType)) |
Line 133: |
Line 150: |
| if fleet.p2w and fleet.p2w > 0 then | | if fleet.p2w and fleet.p2w > 0 then |
| fleetNote = fleetNote .. ", '''{{color|red|{{tooltip|Powerful|" .. fleet.p2w .. " samples}}}}'''" | | 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[1], formatVoice), ' ') |
| end | | end |
| table.insert(result, fleetNote) | | table.insert(result, fleetNote) |
Line 141: |
Line 161: |
| table.insert(result, string.format( | | table.insert(result, string.format( |
| '|-\n|%s||%s||style="text-align:left;white-space:nowrap"|%s||%s||%s||%s||%s||%s', | | '|-\n|%s||%s||style="text-align:left;white-space:nowrap"|%s||%s||%s||%s||%s||%s', |
− | getShipCard(ship.ship), | + | getShipCard(ship.ship, ship.hp, ship.maxHp), |
| ship.level, | | ship.level, |
| U.ijoin(U.imap(ship.equipment, function(eq) return getEquipmentCard(eq, cardSize) end)), | | U.ijoin(U.imap(ship.equipment, function(eq) return getEquipmentCard(eq, cardSize) end)), |