- 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:View/Expedition"
Jump to navigation
Jump to search
m |
|||
Line 93: | Line 93: | ||
local function tooltip(text, title) | local function tooltip(text, title) | ||
return F:tooltip2(text, title, '<br>') | return F:tooltip2(text, title, '<br>') | ||
+ | end | ||
+ | |||
+ | local itemTemplate = [=[<span style="position:relative;display:inline">[[File:${file}|35px|link=${link}|${name}]]<span style="font-size:12px;font-weight:800;position:absolute;color:f61;right:4px;bottom:-18px;text-shadow:#fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px">${text}</span>]=] | ||
+ | |||
+ | local itemFiles = { | ||
+ | [1] = 'Instant_repair.jpg', | ||
+ | [2] = 'Instant_construction.jpg', | ||
+ | [3] = 'Development_material.jpg', | ||
+ | [10] = 'Furniture_box_small.png', | ||
+ | [11] = 'Furniture_box_medium.png', | ||
+ | [12] = 'Furniture_box_large.jpg', | ||
+ | } | ||
+ | |||
+ | local itemLinks = { | ||
+ | [1] = 'Tutorial:_FAQ#What_are_buckets.3F', | ||
+ | [2] = 'Construction', | ||
+ | [3] = 'Development', | ||
+ | [10] = 'Furniture/Guide#Furniture_coin', | ||
+ | [11] = 'Furniture/Guide#Furniture_coin', | ||
+ | [12] = 'Furniture/Guide#Furniture_coin', | ||
+ | } | ||
+ | |||
+ | local itemNames = { | ||
+ | [1] = 'Instant Repair', | ||
+ | [2] = 'Instant Construction', | ||
+ | [3] = 'Development Material', | ||
+ | [10] = 'Small Furniture Coin Box', | ||
+ | [11] = 'Medium Furniture Coin Box', | ||
+ | [12] = 'Large Furniture Coin Box', | ||
+ | } | ||
+ | |||
+ | local function formatItem(id, count) | ||
+ | return U.format{ | ||
+ | itemTemplate, | ||
+ | file = itemFiles[id] or '??', | ||
+ | link = itemLinks[id] or '', | ||
+ | name = itemNames[id] or '??', | ||
+ | text = 'x' .. count, | ||
+ | } | ||
end | end | ||
Line 120: | Line 159: | ||
steel = tooltip(args.explicit[id .. ' steel'] or '??', 'Base resources gain from expedition (at 100% ratio)'), | steel = tooltip(args.explicit[id .. ' steel'] or '??', 'Base resources gain from expedition (at 100% ratio)'), | ||
bauxite = tooltip(args.explicit[id .. ' bauxite'] or '??', 'Base resources gain from expedition (at 100% ratio)'), | bauxite = tooltip(args.explicit[id .. ' bauxite'] or '??', 'Base resources gain from expedition (at 100% ratio)'), | ||
− | item1 = ' | + | item1 = e.win_item1[1] > 0 and formatItem(e.win_item1[1], e.win_item1[2]) or '', |
− | item2 = ' | + | item2 = e.win_item2[1] > 0 and formatItem(e.win_item2[1], e.win_item2[2]) or '', |
} | } | ||
end)) .. '\n|}</div>' | end)) .. '\n|}</div>' |
Revision as of 15:34, 18 July 2019
Documentation for this module may be created at Module:View/Expedition/doc
local U = require('Module:Core')
local F = require('Module:Formatting')
local view = require('Module:View')
local data = require('Module:Data/Expedition')
local backgrounds = {
[0] = 'EDEDED',
[1] = 'EDEDED',
[2] = 'EDEDD5',
[3] = 'CFE8E8',
[4] = 'C5E6D5',
[5] = 'D3D3EB',
-- [7] = '?',
}
local template = [=[|-
|style="${style}"|${id}
|style="${style}"|${name}
|style="${style}"|${time}
|style="${style}"|${hq}
|style="${style}"|${ship}
|style="${style}"|${fuel}
|style="${style}"|${ammo}
|style="${style}"|${steel}
|style="${style}"|${bauxite}
|style="${style}"|${item1}
|style="${style}"|${item2}]=]
-- todo: use modules
local worldNames = {
[1] = '鎮守府海域',
[2] = '南西諸島海域',
[3] = '北方海域',
[4] = '西方海域',
[5] = '南方海域',
[6] = '中部海域',
[7] = '南西海域',
}
local headerBackgrounds = {
[1] = 'lightgray',
[2] = '#cccc99',
[3] = '#99cccc',
[4] = '#66cc99',
[5] = '#9999cc',
[6] = 'lightgray',
[7] = 'lightgray',
}
local isons = {
[1] = 'World1icon',
[2] = 'World2icon',
[3] = 'World3icon',
[4] = 'World4icon',
[5] = 'World5icon',
[6] = 'World6icon',
[7] = 'World7icon',
}
local tableHeader = [=[<div style="width:90%;margin-left:20px">
{|style="width:100%"
|style="width:50px"|[[File:${icon}.png|link=]]
|<div style="background:${background};width:100%;padding-left:10px;border-top-right-radius:10px">'''${name}'''</div>
|}
</div>
<div style="position:relative;border:solid 1px lightgray;width:95%;border-radius:10px;padding:10px;margin:10px;margin-top:0px">
{|style="margin:0 auto;radius:10px;cellpadding:10px;width:100%" cellspacing="0"
!style="cellpadding:10px;width:4%;" |#
!style="cellpadding:10px;width:24%;" |Name
!style="cellpadding:10px;" |Time
!style="cellpadding:10px;width:1px;" rowspan="100" |
!style="cellpadding:10px;width:7%;" |HQ
!style="cellpadding:10px;width:7%;" |Ship
!style="cellpadding:10px;width:1px;" rowspan="100" |
!style="cellpadding:10px;width:7%;" |[[File:Fuel.png|30px|link=]]
!style="cellpadding:10px;width:7%;" |[[File:Ammunition.png|30px|link=]]
!style="cellpadding:10px;width:7%;" |[[File:Steel.png|30px|link=]]
!style="cellpadding:10px;width:7%;" |[[File:Bauxite.png|30px|link=]]
!style="cellpadding:10px;width:1px;" rowspan="100" |
!style="cellpadding:10px;width:20%;" colspan="2" |Rewards
|-
|style="background:gray;" colspan="14"|
]=]
local function pad(n)
return n < 10 and '0' .. n or n
end
local function formatTime(time)
return string.format('%s:%s', pad(math.floor(time / 60)), pad(time % 60))
end
local function tooltip(text, title)
return F:tooltip2(text, title, '<br>')
end
local itemTemplate = [=[<span style="position:relative;display:inline">[[File:${file}|35px|link=${link}|${name}]]<span style="font-size:12px;font-weight:800;position:absolute;color:f61;right:4px;bottom:-18px;text-shadow:#fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px, #fff 0px 0px 5px">${text}</span>]=]
local itemFiles = {
[1] = 'Instant_repair.jpg',
[2] = 'Instant_construction.jpg',
[3] = 'Development_material.jpg',
[10] = 'Furniture_box_small.png',
[11] = 'Furniture_box_medium.png',
[12] = 'Furniture_box_large.jpg',
}
local itemLinks = {
[1] = 'Tutorial:_FAQ#What_are_buckets.3F',
[2] = 'Construction',
[3] = 'Development',
[10] = 'Furniture/Guide#Furniture_coin',
[11] = 'Furniture/Guide#Furniture_coin',
[12] = 'Furniture/Guide#Furniture_coin',
}
local itemNames = {
[1] = 'Instant Repair',
[2] = 'Instant Construction',
[3] = 'Development Material',
[10] = 'Small Furniture Coin Box',
[11] = 'Medium Furniture Coin Box',
[12] = 'Large Furniture Coin Box',
}
local function formatItem(id, count)
return U.format{
itemTemplate,
file = itemFiles[id] or '??',
link = itemLinks[id] or '',
name = itemNames[id] or '??',
text = 'x' .. count,
}
end
local function render(args)
local world = tonumber(args.explicit.world)
local es = U.ifilter(data, function(e) return e.maparea_id == world end)
return U.format{
tableHeader,
icon = isons[world],
background = headerBackgrounds[world],
name = worldNames[world],
} .. U.joinLines(U.imap(es, function(e, i)
local id = e.disp_no
return U.format{
template,
style = string.format(
'text-align: center; height: 35px; background: #%s; color:#000',
i % 2 == 0 and '' or backgrounds[e.maparea_id] or backgrounds[0]
),
id = tooltip(id, 'ID number as displayed in game'),
name = tooltip(e.name, e.details),
time = tooltip(formatTime(e.time), 'Time required for expedition'),
hq = tooltip(args.explicit[id .. ' hq'] or '??', 'Admiral experience gained upon completion from this expedition'),
ship = tooltip(args.explicit[id .. ' ship'] or '??', 'Ship experience gained upon completion from this expedition'),
fuel = tooltip(args.explicit[id .. ' fuel'] or '??', 'Base resources gain from expedition (at 100% ratio)'),
ammo = tooltip(args.explicit[id .. ' ammo'] or '??', 'Base resources gain from expedition (at 100% ratio)'),
steel = tooltip(args.explicit[id .. ' steel'] or '??', 'Base resources gain from expedition (at 100% ratio)'),
bauxite = tooltip(args.explicit[id .. ' bauxite'] or '??', 'Base resources gain from expedition (at 100% ratio)'),
item1 = e.win_item1[1] > 0 and formatItem(e.win_item1[1], e.win_item1[2]) or '',
item2 = e.win_item2[1] > 0 and formatItem(e.win_item2[1], e.win_item2[2]) or '',
}
end)) .. '\n|}</div>'
end
local test = { explicit = { world = '7' } }
-- print(p.test())
return view(render, test)