Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:GameSkills: Difference between revisions

From SpiritVale Wiki
No edit summary
No edit summary
Line 301: Line 301:
--  - For non-healing: "100% + 40 / 80 / 120 ... Attack Per Level"
--  - For non-healing: "100% + 40 / 80 / 120 ... Attack Per Level"
--  - For healing: "10 / 20 / 30 ... Healing Per Level"
--  - For healing: "10 / 20 / 30 ... Healing Per Level"
local function formatDamageEntry(entry, maxLevel, isHealing)
local function formatDamageEntry(entry, maxLevel)
if type(entry) ~= "table" then
if type(entry) ~= "table" then
return nil
return nil
end
end
local isHealing = (entry.Type == "Healing")


local baseRaw = entry["Base %"]
local baseRaw = entry["Base %"]
Line 312: Line 314:
local perN  = toNum(perRaw)
local perN  = toNum(perRaw)


local basis = basisLabel(entry, isHealing)
local basis = isHealing and "Healing" or basisLabel(entry)


-- Healing: never show "%" or "nil%".
local function baseIsPresent()
if isHealing then
if baseN ~= nil then
-- Prefer per-level expansion if possible
return baseN ~= 0
if perN ~= nil and perN ~= 0 and maxLevel and maxLevel > 0 then
local start = (baseN ~= nil) and baseN or 0
local vals = {}
for lv = 1, maxLevel do
table.insert(vals, fmtNum(start + (perN * lv)))
end
if #vals > 0 then
return string.format("%s %s Per Level", table.concat(vals, " / "), basis)
end
end
 
-- Fallbacks
if baseN ~= nil and baseN ~= 0 then
return string.format("%s %s", fmtNum(baseN), basis)
end
end
if perN ~= nil and perN ~= 0 then
return string.format("%s %s Per Level", fmtNum(perN), basis)
end
return nil
end
-- Non-healing base display: treat Base 0 as "missing" (so we don't show "0% + ...")
local basePresent = false
if baseN ~= nil then
basePresent = (baseN ~= 0)
else
if baseRaw ~= nil then
if baseRaw ~= nil then
local s = tostring(baseRaw)
local s = tostring(baseRaw)
basePresent = (s ~= "" and s ~= "0" and s ~= "0.0" and s ~= "0.00")
return (s ~= "" and s ~= "0" and s ~= "0.0" and s ~= "0.00")
end
end
return false
end
end


local baseText = nil
local baseText = nil
if basePresent then
if baseIsPresent() then
if baseN ~= nil then
if baseN ~= nil then
baseText = fmtNum(baseN) .. "%"
baseText = fmtNum(baseN) .. "%"
Line 358: Line 336:
end
end


-- If we have no Per Level scaling (or can't expand), show just Base if present.
if perN == nil or perN == 0 or not maxLevel or maxLevel <= 0 then
if perN == nil or perN == 0 or not maxLevel or maxLevel <= 0 then
if baseText then
return baseText and (baseText .. " " .. basis) or nil
return string.format("%s %s", baseText, basis)
end
return nil
end
end


-- Expand cumulative list: per * 1..maxLevel
local vals = {}
local vals = {}
for lv = 1, maxLevel do
for lv = 1, maxLevel do
table.insert(vals, fmtNum(perN * lv))
table.insert(vals, fmtNum(perN * lv) .. "%")
end
local listText = (#vals > 0) and table.concat(vals, " / ") or nil
if not listText then
return baseText
end
end
local listText = table.concat(vals, " / ")


-- If Base missing/0: just the list (no "nil% +")
if not baseText then
if not baseText then
return string.format("%s %s Per Level", listText, basis)
return string.format("%s %s Per Level", listText, basis)
end
end
return string.format("%s + %s %s Per Level", baseText, listText, basis)
return string.format("%s + %s %s Per Level", baseText, listText, basis)
end
end