模块:钓鱼展示
外观
此模块的文档可以在模块:钓鱼展示/doc创建
local C = require('模块:物品通用')
local F = require('模块:钓鱼数据')
local p = {}
local function present(value) return value ~= nil and not (type(value) == 'string' and C.trim(value) == '') end
local function quantity(row)
local min, max = row.minQuantity, row.maxQuantity
if present(min) and present(max) then
if min == max then return '×' .. C.literal(min) end
if type(min) == 'number' and type(max) == 'number' then return '×' .. C.literal(min) .. '~' .. C.literal(max) end
return '(最少' .. C.literal(min) .. ';最多' .. C.literal(max) .. ')'
elseif present(min) then return '(至少' .. C.literal(min) .. ')'
elseif present(max) then return '(至多' .. C.literal(max) .. ')' end
return ''
end
function p.disassemblyText(result)
if result.status == 'error' then return C.diagnostic(result) end
if result.status ~= 'known' or not result.entries or #result.entries == 0 then return '' end
local parts = {}
for _, row in ipairs(result.entries) do
local text = row.rewardType == 'none' and '无产物' or C.link(row.item)
if row.rewardType ~= 'none' then text = text .. quantity(row) end
parts[#parts + 1] = text .. '(' .. C.probability(row) .. ')'
end
return "'''分解:'''" .. table.concat(parts, '、')
end
function p.ground(frame)
local c = C.context(frame)
if not c.enabled then return '' end
local name = c.option('钓场名', c.title.text)
local result = F.getGround(name)
local body
if result.status == 'error' then body = C.diagnostic(result)
elseif result.status ~= 'known' or #result.entries == 0 then body = '他妈,钓鱼还是不掉这个!'
else
local rows = {}
for _, entry in ipairs(result.entries) do
local isWum = entry.rewardType == 'wum'
local link = isWum and C.link('wums', entry.item) or C.link(entry.item)
local method = '普通钓获'
if entry.smallToBigBaits then
local baits = {}
for _, bait in ipairs(entry.smallToBigBaits) do baits[#baits + 1] = C.link(bait) end
method = (entry.ordinaryCatch and '普通钓获;' or '') .. '以小钓大(' .. table.concat(baits, '、') .. ')'
end
rows[#rows + 1] = '|-\n| ' .. link .. ' || ' .. (isWum and 'WUM' or '物品') .. ' || ' .. method
end
body = '这里只列可能钓获的范围,不表示无条件可获得。\n\n{| class="wikitable wum-item-table"\n! 钓获物 !! 类别 !! 取得方式\n' .. table.concat(rows, '\n') .. '\n|}'
end
return '<div class="wum-item-block wum-fishing-ground">\n' .. C.heading(c, '可能钓获', 2) .. body .. '\n</div>' ..
(c.categorize and '[[分类:钓场]]' or '') .. '\n'
end
return p