全站通知:

模块:Artisan

来自星露谷物语维基
跳到导航 跳到搜索
[ 创建 | 刷新 ]文档页面
当前模块文档缺失,需要扩充。
local utils = require("Module:Utils")
local expandTemplate = utils.expandTemplate
local getArg = utils.getArg
local getArgs = require("Module:Arguments").getArgs

local p = {}

-- Artisan 产品的可食用性和价格计算倍率
-- 格式:{edibility_multiplier, sellprice_multiplier, price_multiplier, price_offset}
local MULTIPLIERS = {
    ["wine"] = {1.75, 0.1, 3.0, 0},
    ["juice"] = {2.0, 0.4, 2.25, 0},
    ["jelly"] = {2.0, 0.2, 2.0, 50},
    ["pickles"] = {1.75, 0.25, 2.0, 50},
    ["dried"] = {3.0, 0.5, 7.5, 25},
    ["honey"] = {2.0, 0.2, 2.0, 100},
    ["roe"] = {-1, -1, 0.5, 30},
    ["aged roe"] = {-1, -1, 1.0, 60},
    ["smoked"] = {1.5, 0.3, 2.0, 0}
}

-- calcArtisanEdibility(计算 Artisan 产品可食用性)
function p.cae(frame)
    local args = getArgs(frame)
    local sellprice = tonumber(args.sellprice)
    local edibility = tonumber(args.edibility)
    local atype = args.type

    if not sellprice or not edibility or not atype then return "参数缺失" end

    local multiplier = MULTIPLIERS[atype]
    if not multiplier then return "未知类型" end

    local result
    if edibility >= 0 then
        result = edibility * multiplier[1]
    elseif edibility == -300 then
        result = sellprice * multiplier[2]
    else
        result = edibility
    end

    return math.floor(result)
end

-- calcArtisanPrice(计算 Artisan 产品售价)
function p.cap(frame)
    local args = getArgs(frame)
    local baseprice = tonumber(args.sellprice)
    local multiplier = tonumber(args.multiplier) or 1
    local atype = args.type

    if not baseprice or not atype then return "参数缺失" end

    local mult = MULTIPLIERS[atype]
    if not mult then return "未知类型" end

    local price = math.floor((baseprice * mult[3] + mult[4]) * multiplier)
    return expandTemplate("Price", {price})
end

-- trimFishName(移除「鱼鱼籽」中重复的「鱼」字)
function p.tfn(input)
    local result = getArg(input):gsub("鱼鱼籽", "鱼籽")
    return result
end

return p