|
|
Line 923: |
Line 923: |
| end | | end |
|
| |
|
| --TODO: Is this necessary anymore? This could theoretically match 'increasedRolledReflectDamage' ('+0-${value} Reflect Damage') incorrectly | | --TODO: Is this necessary anymore? This could theoretically match 'increasedRolledReflectDamage' ('+0-${value} Reflect Damage') incorrectly but this isn't used |
| local sign = "+" | | local sign = "+" |
| if string.match(modifier.description, '${value}') then | | if string.match(modifier.description, '${value}') then |
Line 932: |
Line 932: |
|
| |
|
| return baseName, modifier.description, sign, modifier.isNegative, valueUnsigned, modifier | | return baseName, modifier.description, sign, modifier.isNegative, valueUnsigned, modifier |
| end
| |
| --TODO: Remove this
| |
| function p.test(modifierName)
| |
| local baseName = modifierName
| |
| local valueUnsigned = false
| |
| local modifier = GameData.rawData.modifierData[modifierName]
| |
|
| |
| if modifier == nil then
| |
| return nil
| |
| end
| |
|
| |
| if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
| |
| baseName = string.sub(modifierName, 10)
| |
| end
| |
|
| |
| --TODO: Is this necessary anymore? This could theoretically match 'increasedRolledReflectDamage' ('+0-${value} Reflect Damage') incorrectly
| |
| local sign = "+"
| |
| if string.match(modifier.description, '${value}') then
| |
| sign = "-"
| |
| end
| |
|
| |
| if string.match(modifier.description, ' ${value}') then valueUnsigned = true end
| |
|
| |
| return modifier
| |
| end
| |
| --TODO: Remove this; Original getModifierDetails
| |
| function p.ogetModifierDetails(modifierName)
| |
| local baseName = modifierName
| |
| local isIncrease = true
| |
| local isNegative = false
| |
| local valueUnsigned = false
| |
|
| |
| if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
| |
| baseName = string.sub(modifierName, 10)
| |
| isIncrease = Shared.startsWith(modifierName, "increased")
| |
| end
| |
|
| |
| local modifier = modifierTypes[baseName]
| |
| if modifier == nil then
| |
| return nil
| |
| end
| |
|
| |
| local isPositive = isIncrease
| |
| if modifier.isIncreaseNegative then
| |
| isPositive = not isPositive
| |
| end
| |
|
| |
| local sign = "+"
| |
| if (not isIncrease and not modifier.inverseSign) or (isIncrease and modifier.inverseSign) then
| |
| sign = "-"
| |
| end
| |
|
| |
| if type(modifier.unsigned) == 'boolean' then valueUnsigned = modifier.unsigned end
| |
|
| |
| return baseName, modifier.text, sign, not isPositive, valueUnsigned, modifier
| |
| end | | end |
|
| |
|
Line 1,053: |
Line 998: |
| local valSign = (valueUnsigned and '' or '') | | local valSign = (valueUnsigned and '' or '') |
| resultText = string.gsub(resultText, '${(value[^}]*)}', function(rule) return valSign .. (formatModValue(modMagnitude, rule) or '') end) | | resultText = string.gsub(resultText, '${(value[^}]*)}', function(rule) return valSign .. (formatModValue(modMagnitude, rule) or '') end) |
|
| |
| if doColor then
| |
| local colorCode = (isNegative ~= nil and isNegative and 'color:red' or 'color:green')
| |
| resultText = '<span style="' .. colorCode .. '">' .. resultText .. '</span>'
| |
| end
| |
| table.insert(resultArray, resultText)
| |
| end
| |
|
| |
| return table.concat(resultArray, '<br/>')
| |
| end
| |
| --TODO: Remove this; Original _getModifierText
| |
| function p._ogetModifierText(modifier, value, doColor)
| |
| if doColor == nil then doColor = true end
| |
| local modName, modText, sign, isNegative, valueUnsigned = p.ogetModifierDetails(modifier)
| |
|
| |
| if modName == nil then
| |
| return Shared.printError('Invalid modifier type for "' .. modifier .. '"')
| |
| end
| |
|
| |
| local formatModValue = function(value, rule)
| |
| local ruleFunctions = {
| |
| ['V'] = function(val) return val end,
| |
| ['VD'] = function(val) return val / 10 end,
| |
| ['VMS'] = function(val) return val / 1000 end,
| |
| ['VX'] = function(val) return val * 10 end,
| |
| ['VX100'] = function(val) return val * 100 end,
| |
| ['V+100'] = function(val) return val + 100 end,
| |
| ['V+1'] = function(val) return val + 1 end,
| |
| ['VMUL'] = function(val) return 2^val end,
| |
| ['VITEM'] = function(val)
| |
| -- For golbin raid starting weapons
| |
| local startingWeapons = { 'melvorD:Bronze_Scimitar', 'melvorD:Adamant_Scimitar' }
| |
| local itemID = startingWeapons[val + 1]
| |
| local item = GameData.getEntityByID('items', itemID)
| |
| if item ~= nil then
| |
| return item.name
| |
| else
| |
| return 'Unknown'
| |
| end
| |
| end
| |
| }
| |
| local ruleFunc = ruleFunctions[rule] or ruleFunctions['V']
| |
|
| |
| if type(value) == 'table' then
| |
| -- If table is a pair of values then format both & add a separator
| |
| return ruleFunc(value[1]) .. '-' .. ruleFunc(value[2])
| |
| else
| |
| return ruleFunc(value)
| |
| end
| |
| end
| |
|
| |
| local valueArray, resultArray = nil, {}
| |
| if type(value) ~= 'table' then
| |
| valueArray = {value}
| |
| else
| |
| valueArray = value
| |
| end
| |
|
| |
| for i, subVal in ipairs(valueArray) do
| |
| local resultText = modText
| |
| local modMagnitude = nil
| |
| if type(subVal) == 'table' and subVal.skillID ~= nil then
| |
| -- Modifier value is skill specific
| |
| modMagnitude = subVal.value
| |
| local skillName = p.getSkillName(subVal.skillID)
| |
| if skillName ~= nil then
| |
| resultText = string.gsub(resultText, '{SV0}', skillName)
| |
| end
| |
| else
| |
| -- Modifier value is the magnitude only
| |
| modMagnitude = subVal
| |
| end
| |
|
| |
| local valSign = (valueUnsigned and '' or sign or '')
| |
| resultText = string.gsub(resultText, '{(V[^}]*)}', function(rule) return valSign .. (formatModValue(modMagnitude, rule) or '') end)
| |
| resultText = string.gsub(resultText, '{S}', sign)
| |
|
| |
|
| if doColor then | | if doColor then |
Line 1,225: |
Line 1,094: |
|
| |
|
| local baseName = p.getModifierDetails(modifier) | | local baseName = p.getModifierDetails(modifier) |
| if baseName == nil then
| |
| return { Shared.printError('Modifier "' .. modifier .. '" is invalid') }
| |
| end
| |
|
| |
| if modifierTypes[baseName].skills ~= nil then
| |
| for i, skillName in Shared.skpairs(modifierTypes[baseName].skills) do
| |
| if not Shared.contains(skillArray, skillName) then
| |
| table.insert(skillArray, skillName)
| |
| end
| |
| end
| |
| end
| |
| end
| |
|
| |
| return skillArray
| |
| end
| |
| --TODO: Remove this; Original getModifierSkills
| |
| function p.ogetModifierSkills(modifiers)
| |
| local skillArray = {}
| |
|
| |
| for modifier, value in pairs(modifiers) do
| |
| if type(value) == 'table' then
| |
| for i, subVal in ipairs(value) do
| |
| if type(subVal) == 'table' and subVal.skillID ~= nil then
| |
| local skillName = p.getSkillName(subVal.skillID)
| |
| if not Shared.contains(skillArray, skillName) then
| |
| table.insert(skillArray, skillName)
| |
| end
| |
| end
| |
| end
| |
| end
| |
|
| |
| local baseName = p.ogetModifierDetails(modifier)
| |
| if baseName == nil then | | if baseName == nil then |
| return { Shared.printError('Modifier "' .. modifier .. '" is invalid') } | | return { Shared.printError('Modifier "' .. modifier .. '" is invalid') } |