new mode: best case scenario
This commit is contained in:
parent
39898fed1a
commit
b3b54fbe0c
4 changed files with 54 additions and 16 deletions
|
@ -29,6 +29,10 @@ this.modes = {
|
|||
{
|
||||
mode = "worstCaseScenario",
|
||||
description = "Calculates results from all formulas, and uses the highest value.",
|
||||
},
|
||||
{
|
||||
mode = "bestCaseScenario",
|
||||
description = "Calculates results from all formulas, and uses the lowest value.",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,4 +64,17 @@ this.keyOfLargestValue = function(t)
|
|||
return picked
|
||||
end
|
||||
|
||||
-- picks the key of the smallest value out of a key:whatever, value:number table
|
||||
this.keyOfSmallestValue = function(t)
|
||||
local picked
|
||||
local smallest = math.huge
|
||||
for key, value in pairs(t) do
|
||||
if value < smallest then
|
||||
smallest = value
|
||||
picked = key
|
||||
end
|
||||
end
|
||||
return picked
|
||||
end
|
||||
|
||||
return this
|
||||
|
|
|
@ -12,7 +12,7 @@ this.defaultConfig = {
|
|||
encumbrancePercentage = 100
|
||||
},
|
||||
mode = common.modes[1].mode,
|
||||
allEquipmentWorstCaseNecroMode = true
|
||||
caseScenarioNecroMode = true
|
||||
}
|
||||
|
||||
local currentConfig
|
||||
|
|
|
@ -35,6 +35,24 @@ end
|
|||
-- Formula functions
|
||||
local formulas = {}
|
||||
|
||||
-- Formula helper
|
||||
local function calculateAll(actor, mobile, ref)
|
||||
local results = {}
|
||||
|
||||
for mode, func in pairs(formulas) do
|
||||
-- don't go recursive
|
||||
if not string.find(mode, "CaseScenario") then
|
||||
-- sometimes I really wish lua had continue -_-
|
||||
if (config.caseScenarioNecroMode and mode ~= "allEquipment") or
|
||||
(not config.caseScenarioNecroMode and mode ~= "allEquipmentNecroEdit") then
|
||||
results[mode] = func(actor, mobile, ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return results
|
||||
end
|
||||
|
||||
formulas.equippedArmour = function(actor, mobile, ref)
|
||||
local armourClass = getTotalArmourClass(actor)
|
||||
local downPull = (config.multipliers.equippedArmour / 10) * armourClass
|
||||
|
@ -76,17 +94,7 @@ end
|
|||
formulas.worstCaseScenario = function(actor, mobile, ref)
|
||||
local downPull = 0
|
||||
|
||||
local results = {}
|
||||
for mode, func in pairs(formulas) do
|
||||
-- don't go recursive
|
||||
if mode ~= "worstCaseScenario" then
|
||||
-- sometimes I really wish lua had continue -_-
|
||||
if (config.allEquipmentWorstCaseNecroMode and mode ~= "allEquipment") or
|
||||
(not config.allEquipmentWorstCaseNecroMode and mode ~= "allEquipmentNecroEdit") then
|
||||
results[mode] = func(actor, mobile, ref)
|
||||
end
|
||||
end
|
||||
end
|
||||
local results = calculateAll(actor, mobile, ref)
|
||||
|
||||
local largest = common.keyOfLargestValue(results)
|
||||
downPull = results[largest]
|
||||
|
@ -96,6 +104,19 @@ formulas.worstCaseScenario = function(actor, mobile, ref)
|
|||
return downPull, debugStr
|
||||
end
|
||||
|
||||
formulas.bestCaseScenario = function(actor, mobile, ref)
|
||||
local downPull = 0
|
||||
|
||||
local results = calculateAll(actor, mobile, ref)
|
||||
|
||||
local smallest = common.keyOfSmallestValue(results)
|
||||
downPull = results[smallest]
|
||||
|
||||
local debugStr = string.format("Pulling %s down by %s using best mode:%s", ref.id, downPull, common.camelCaseToWords(smallest))
|
||||
|
||||
return downPull, debugStr
|
||||
end
|
||||
|
||||
-- Event functions
|
||||
local function sinkInWater(e)
|
||||
-- shortcut refs
|
||||
|
|
|
@ -67,13 +67,13 @@ category:createDropdown({
|
|||
})
|
||||
|
||||
category:createDropdown({
|
||||
label = "Worst Case Scenario All Equipment variety",
|
||||
description = "Chooses which variety of the All Equipment formula is used when Worst Case Scenario is selected",
|
||||
label = "Worst or Best Case Scenario All Equipment variety",
|
||||
description = "Chooses which variety of the All Equipment formula is used when Worst or Best Case Scenario is selected.",
|
||||
options = {
|
||||
{ label = "Original Formula", value = false },
|
||||
{ label = "Original Formula)", value = false },
|
||||
{ label = "Necro Edit", value = true }
|
||||
},
|
||||
variable = createTableVar("allEquipmentWorstCaseNecroMode")
|
||||
variable = createTableVar("caseScenarioNecroMode")
|
||||
})
|
||||
|
||||
for name, _ in pairs(config.defaultConfig.multipliers) do
|
||||
|
|
Loading…
Add table
Reference in a new issue