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 910: Line 910:
-- hitsDisplay: find + render Hits from multiple possible structured locations.
-- hitsDisplay: find + render Hits from multiple possible structured locations.
local function hitsDisplay()
local function hitsDisplay()
local effects = (type(mech.Effects) == "table") and mech.Effects or {}
local h =
local h =
typeBlock.Hits or typeBlock["Hits"] or typeBlock["Hit Count"] or typeBlock["Hits Count"] or
typeBlock.Hits or typeBlock["Hits"] or typeBlock["Hit Count"] or typeBlock["Hits Count"] or
mech.Hits or mech["Hits"] or mech["Hit Count"] or mech["Hits Count"] or
mech.Hits or mech["Hits"] or mech["Hit Count"] or mech["Hits Count"] or
effects.Hits or effects["Hits"] or effects["Hit Count"] or effects["Hits Count"] or
rec.Hits or rec["Hits"]
rec.Hits or rec["Hits"]


Line 932: Line 935:


-- Fallback name extraction
-- Fallback name extraction
local function valName(x)
if x == nil then return nil end
if type(x) == "table" then
if x.Name and x.Name ~= "" then return tostring(x.Name) end
if x.ID and x.ID ~= "" then return tostring(x.ID) end
if x.Value ~= nil then return tostring(x.Value) end
end
if type(x) == "number" then return tostring(x) end
if type(x) == "string" and x ~= "" then return x end
return nil
end
local vn = valName(h)
local vn = valName(h)
if vn and not isNoneLike(vn) then
if vn and not isNoneLike(vn) then
Line 1,299: Line 1,314:
local effects = (type(mech.Effects) == "table") and mech.Effects or nil
local effects = (type(mech.Effects) == "table") and mech.Effects or nil
local mods    = (type(rec.Modifiers) == "table") and rec.Modifiers or nil
local mods    = (type(rec.Modifiers) == "table") and rec.Modifiers or nil
------------------------------------------------------------------
-- Hits guard (we want Hits ONLY in SkillType)
------------------------------------------------------------------
local function isHitsKey(name)
if not name then return false end
local k = mw.ustring.lower(mw.text.trim(tostring(name)))
return (
k == "hit" or
k == "hits" or
k == "hit count" or
k == "hits count" or
k == "hitcount" or
k == "hitscount"
)
end


------------------------------------------------------------------
------------------------------------------------------------------
Line 1,310: Line 1,341:
["bond"] = true,
["bond"] = true,
["combo"] = true,
["combo"] = true,
-- hits variants
["hit"] = true,
["hits"] = true,
["hits"] = true,
["hit count"] = true,
["hits count"] = true,
["hitcount"] = true,
["hitscount"] = true,
}
}


Line 1,356: Line 1,394:


for _, name in ipairs(keys) do
for _, name in ipairs(keys) do
local block = effects[name]
-- Skip Hits completely (it belongs in SkillType)
if type(block) == "table" then
if not isHitsKey(name) then
local disp = displayFromSeries(seriesFromValuePair(block, maxLevel), level)
local block = effects[name]
local t = trim(block.Type)
if type(block) == "table" then
-- Also skip if the block's Type is "Hits" (some data may encode it that way)
if not isHitsKey(block.Type) then
local disp = displayFromSeries(seriesFromValuePair(block, maxLevel), level)
local t = trim(block.Type)


local value = disp
local value = disp


-- If Type exists and is distinct, prefix it.
-- If Type exists and is distinct, prefix it.
if t and not isNoneLike(t) and mw.ustring.lower(t) ~= mw.ustring.lower(tostring(name)) then
if t and not isNoneLike(t) and mw.ustring.lower(t) ~= mw.ustring.lower(tostring(name)) then
if value then
if value then
value = mw.text.nowiki(t) .. ": " .. value
value = mw.text.nowiki(t) .. ": " .. value
else
else
value = mw.text.nowiki(t)
value = mw.text.nowiki(t)
end
end
 
if value then
table.insert(mechItems, { label = tostring(name), value = value })
end
end
end
end
if value then
table.insert(mechItems, { label = tostring(name), value = value })
end
end
end
end