From Dark and Darker Wiki
m (fix placement of required gem header) |
(Updating column strings.) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 44: | Line 44: | ||
-- Add required gem col header | -- Add required gem col header | ||
if base_or_gem == 'gem' then | if base_or_gem == 'gem' then | ||
slot_headers = '<th | slot_headers = slot_headers .. '<th rowspan="2">Required Gem</th>' | ||
end | end | ||
Line 93: | Line 93: | ||
--Max Total Possible = MAX(1H Shield + 1H Weapon, 2 * 1H Weapon, 2H Physical, 2H Magical, 2H Hybrid) + Head + Chest + Legs + Hands + Foot + Cloak + Necklace) + 2*Ring | --Max Total Possible = MAX(1H Shield + 1H Weapon, 2 * 1H Weapon, 2H Physical, 2H Magical, 2H Hybrid) + Head + Chest + Legs + Hands + Foot + Cloak + Necklace) + 2*Ring | ||
local weapons = math.max( | local weapons = math.max( | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "1H", base_or_gem) + p.get_roll(slots_data, "1H Shield", base_or_gem), | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "1H", base_or_gem)*2, | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "2H Shield", base_or_gem), | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "2H Physical", base_or_gem), | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "2H Hybrid", base_or_gem), | ||
p.get_roll(slots_data, " | p.get_roll(slots_data, "2H Magical", base_or_gem) | ||
) | ) | ||
Line 119: | Line 119: | ||
if required_gem == nil then | if required_gem == nil then | ||
required_gem = "" | required_gem = "" | ||
else | |||
required_gem = "<div class=\"iconbox\" style=\"margin:0px;\"><div class=\"rounded relative\">[[File:" .. required_gem .. ".png|x35px|link=" .. required_gem .. "]]</div></div>" | |||
end | end | ||
required_gem_td = '<td>' .. required_gem .. '</td>' | required_gem_td = '<td id="gem" style=\"padding:0px;\">' .. required_gem .. '</td>' | ||
end | end | ||
Line 178: | Line 180: | ||
end | end | ||
return "<table class=\"wikitable\">" .. header_row .. data_rows .. "</table>" | return "<table class=\"wikitable\" style=\"border-collapse:collapse;\">" .. header_row .. data_rows .. "</table>" | ||
end | end | ||
return p | return p |
Latest revision as of 21:44, 3 March 2025
Overview
Functions for Enchantments. Data comes from Data:Enchantments.json.
Functions
draw_roll_range_table
Create's a table of enchants for the Enchantments page
Parameters
- base_or_gem - List 'base' (traditional) or 'gem' enchant roll ranges?
Examples
{{#invoke:Enchantments|draw_roll_range_table|gem}}
Enchantments | Required Gem | 1H | 1H Shield | 2H Shield | 2H Physical | 2H Hybrid | 2H Magical | Chest | Legs | Foot | Head | Hands | Cloak | Necklace | Ring | Max Total Possible | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | Min | Max | ||||
Attributes | |||||||||||||||||||||||||||||||
All Attributes | 0 | ||||||||||||||||||||||||||||||
Strength | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Vigor | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Agility | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Dexterity | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Will | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Knowledge | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Resourcefulness | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 10 | ||||||||||||||||||||
Physical Damage | |||||||||||||||||||||||||||||||
Physical Power Bonus | 1 | 1.8 | 1 | 1.8 | 2 | 2.7 | 2 | 2.7 | 2 | 2.7 | 2 | 2.7 | 1 | 1.8 | 1 | 1.8 | 1 | 1.8 | 14.4 | ||||||||||||
Physical Power | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 14 | ||||||||||||||
Physical Gear Weapon Damage | 1 | 1 | 1 | 1 | 2 | ||||||||||||||||||||||||||
Physical Damage Add | 1 | 1 | 1 | 1 | 5 | ||||||||||||||||||||||||||
True Physical Damage | 1 | 1 | 1 | 1 | 5 | ||||||||||||||||||||||||||
Armor Penetration | 2.5 | 3 | 4 | 6.5 | 4 | 6.5 | 2 | 2.5 | 2 | 2.5 | 2.5 | 3 | 2.5 | 3 | 1 | 1.8 | 21.1 | ||||||||||||||
Magical Damage | |||||||||||||||||||||||||||||||
Magical Power Bonus | 1 | 1.8 | 2 | 2.7 | 2 | 2.7 | 2 | 2.7 | 2 | 2.7 | 1 | 1.8 | 1 | 1.8 | 1 | 1.8 | 14.4 | ||||||||||||||
Magical Power | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 14 | ||||||||||||||
Magical Damage Add | 1 | 1 | 1 | 1 | 5 | ||||||||||||||||||||||||||
True Magical Damage | 1 | 1 | 1 | 1 | 5 | ||||||||||||||||||||||||||
Magical Penetration | 0 | ||||||||||||||||||||||||||||||
Reductions | |||||||||||||||||||||||||||||||
Armor Rating Add | 10 | 12 | 20 | 25 | 5 | 8 | 5 | 8 | 3 | 4 | 3 | 4 | 3 | 4 | 3 | 4 | 5 | 8 | 3 | 4 | 73 | ||||||||||
Physical Damage Reduction | 2 | 2.5 | 4 | 4.5 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1 | 1.2 | 17.1 | ||||||||||
Projectile Damage Reduction | 2 | 2.5 | 4 | 4.5 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1 | 1.2 | 17.1 | ||||||||||
Magical Damage Reduction | 2 | 2.5 | 4 | 4.5 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1 | 1.2 | 17.1 | ||||||||||
Magical Resistance | 10 | 12 | 20 | 25 | 5 | 8 | 5 | 8 | 3 | 4 | 3 | 4 | 3 | 4 | 3 | 4 | 5 | 8 | 3 | 4 | 73 | ||||||||||
Actions | |||||||||||||||||||||||||||||||
Action Speed | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1.5 | 1.8 | 1.5 | 1.8 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 14.4 | ||||||
Spell Casting Speed | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 12 | ||||||||||||||||
Move Speed Add | 3 | 4 | 4 | ||||||||||||||||||||||||||||
Move Speed Bonus | 1 | 1.2 | 1.2 | ||||||||||||||||||||||||||||
Health | |||||||||||||||||||||||||||||||
Max Health Add | 1 | 2 | 1 | 2 | 3 | 4 | 3 | 4 | 3 | 4 | 3 | 4 | 3 | 4 | 3 | 4 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 3 | 4 | 1 | 2 | 28 | ||
Max Health Bonus | 1 | 1.2 | 1 | 1.2 | 1.5 | 2.5 | 1.5 | 2.5 | 1.5 | 2.5 | 1.5 | 2.5 | 1.5 | 1.8 | 1.5 | 1.8 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1 | 1.2 | 1.5 | 1.8 | 1 | 1.2 | 15.1 | ||
Healing | |||||||||||||||||||||||||||||||
Outgoing Physical Healing Add | 1 | 2 | 1 | 2 | 1 | 6 | |||||||||||||||||||||||||
Outgoing Magical Healing Add | 1 | 1 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 2 | 1 | 8 | |||||||||||||||||||
Statuses | |||||||||||||||||||||||||||||||
Buff Duration Bonus | 3 | 4.5 | 3 | 4.5 | 5 | 9 | 5 | 9 | 5 | 9 | 5 | 9 | 5 | 9 | 5 | 9 | 3 | 4.5 | 3 | 4.5 | 3 | 4.5 | 3 | 4.5 | 5 | 9 | 3 | 4.5 | 63 | ||
Debuff Duration Bonus | 1 | 2.5 | 1 | 2.5 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 1 | 2.5 | 1 | 2.5 | 1 | 2.5 | 1 | 2.5 | 2 | 4.5 | 1 | 2.5 | 33.5 | ||
Memory | |||||||||||||||||||||||||||||||
Memory Capacity Add | 1 | 1 | 1 | 1 | 2 | 1 | 2 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 14 | ||||||||||||||||
Memory Capacity Bonus | 2 | 4.5 | 5 | 9 | 5 | 9 | 5 | 9 | 5 | 9 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 2 | 4.5 | 5 | 9 | 2 | 4.5 | 63 | ||||||||
Misc | |||||||||||||||||||||||||||||||
Luck | 25 | 45 | 25 | 45 | 15 | 22 | 15 | 22 | 15 | 22 | 25 | 45 | 15 | 22 | 245 |
draw_socket_cost_table
Create's a table of socket's cost per rarity for the Enchantments page
Parameters
none
Examples
{{#invoke:Enchantments|draw_socket_cost_table}}
Rarity | Cost |
---|---|
Poor | 10 |
Common | 20 |
Uncommon | 30 |
Rare | 50 |
Epic | 100 |
Legend | 150 |
Unique | 200 |
local enchantments_data = mw.loadJsonData("Data:Enchantments.json")
local utils = require("Module:Utilities")
local p = {}
function p.get_roll(slots_data, slot_name, base_or_gem, min_or_max, if_not_exist)
if min_or_max ~= "min" and min_or_max ~= "max" then
min_or_max = "max"
end
if if_not_exist == nil then
if_not_exist = 0
end
slot_data = slots_data[slot_name]
if slot_data == nil then
return if_not_exist
end
roll_data = slot_data[base_or_gem]
if roll_data == nil then
return if_not_exist
end
roll = roll_data[min_or_max]
if roll == nil then
return if_not_exist
end
return roll
end
function p.draw_roll_range_table(base_or_gem)
-- Handle based on how it was called
if type(base_or_gem) == "table" and base_or_gem.args then -- if called via wikitext instead of lua
local frame = base_or_gem
base_or_gem = frame.args[1]
end
-- Validate
if base_or_gem ~= "base" and base_or_gem ~= "gem" then return "1st parameter 'base_or_gem' must be either 'base' or 'gem'." end
local slot_headers = '<th rowspan="2" colspan="2">Enchantments</th>'
local min_max_headers = ''
-- Add required gem col header
if base_or_gem == 'gem' then
slot_headers = slot_headers .. '<th rowspan="2">Required Gem</th>'
end
-- Create enchant_name_headers (row1) and min/max (row2)
-- Iterate enchant groups
for i, slot_name in ipairs(enchantments_data["slottype_order"]) do
slot_headers = slot_headers .. '<th colspan="2">' .. slot_name .. '</th>'
min_max_headers = min_max_headers .. '<th>Min</th>' .. '<th>Max</th>'
end
-- Add body rows
local enchant_rows = ""
local enchant_row
for i, enchant_group_name in ipairs(enchantments_data["enchant_group_order"]) do
local enchants_in_group = enchantments_data["enchant_order"][enchant_group_name]
if enchants_in_group == nil then return "Error: " .. enchant_group_name .. " not found in \"enchant_order\"" end
-- Iterate enchants in the group
-- First just determine how many enchants are in the group to get the proper rowspan
local num_enchants_in_group = 0
for i, enchant_name in ipairs(enchants_in_group) do
num_enchants_in_group = num_enchants_in_group + 1
end
local is_first = true
for i, enchant_name in ipairs(enchants_in_group) do
-- Get that enchant's data
local slots_data = enchantments_data["enchant_rolls"][enchant_name]["slots"]
if slots_data == nil then return "Error: " .. enchant_name .. " not found in \"enchant_rolls\"" end
-- Iterate slottypes
local min_max_cols = ""
for i, slot_type in ipairs(enchantments_data["slottype_order"]) do
-- Get rolls, default to blank if missing
local min_roll = p.get_roll(slots_data, slot_type, base_or_gem, "min", "")
local max_roll = p.get_roll(slots_data, slot_type, base_or_gem, "max", "")
if min_roll == 0 then min_roll = "" end
if max_roll == 0 then max_roll = "" end
if min_roll == max_roll then
min_max_cols = min_max_cols .. "<td colspan=\"2\">" .. min_roll .. "</td>"
else
min_max_cols = min_max_cols .. "<td>" .. min_roll .. "</td><td>" .. max_roll .. "</td>"
end
end
-- Calc max
--Max Total Possible = MAX(1H Shield + 1H Weapon, 2 * 1H Weapon, 2H Physical, 2H Magical, 2H Hybrid) + Head + Chest + Legs + Hands + Foot + Cloak + Necklace) + 2*Ring
local weapons = math.max(
p.get_roll(slots_data, "1H", base_or_gem) + p.get_roll(slots_data, "1H Shield", base_or_gem),
p.get_roll(slots_data, "1H", base_or_gem)*2,
p.get_roll(slots_data, "2H Shield", base_or_gem),
p.get_roll(slots_data, "2H Physical", base_or_gem),
p.get_roll(slots_data, "2H Hybrid", base_or_gem),
p.get_roll(slots_data, "2H Magical", base_or_gem)
)
local armor = (
p.get_roll(slots_data, "Head", base_or_gem) +
p.get_roll(slots_data, "Chest", base_or_gem) +
p.get_roll(slots_data, "Legs", base_or_gem) +
p.get_roll(slots_data, "Hands", base_or_gem) +
p.get_roll(slots_data, "Foot", base_or_gem) +
p.get_roll(slots_data, "Cloak", base_or_gem) +
p.get_roll(slots_data, "Necklace", base_or_gem) +
p.get_roll(slots_data, "Ring", base_or_gem)*2
)
local max_total_possible = weapons + armor
-- Get the required gem
local required_gem_td = ''
if base_or_gem == 'gem' then
required_gem = enchantments_data["enchant_rolls"][enchant_name]["required_gem"]
if required_gem == nil then
required_gem = ""
else
required_gem = "<div class=\"iconbox\" style=\"margin:0px;\"><div class=\"rounded relative\">[[File:" .. required_gem .. ".png|x35px|link=" .. required_gem .. "]]</div></div>"
end
required_gem_td = '<td id="gem" style=\"padding:0px;\">' .. required_gem .. '</td>'
end
-- Add cells to row
local rowspanned_cell = ''
local row_id = ' id="' .. utils.dash_for_space(enchant_group_name) .. '"'
if is_first then
rowspan = ' rowspan="' .. num_enchants_in_group+1 .. '"'
rowspanned_cell = '<td' .. rowspan .. '>' .. enchant_group_name .. '</td></tr><tr' .. row_id .. '>'
end
enchant_row = '' .. rowspanned_cell
enchant_row = enchant_row .. "<td>" .. enchant_name .. "</td>"
enchant_row = enchant_row .. required_gem_td
enchant_row = enchant_row .. min_max_cols
enchant_row = enchant_row .. "<td>" .. max_total_possible .. "</td>"
enchant_rows = enchant_rows .. '<tr' .. row_id .. '>' .. enchant_row .. "</tr>"
is_first = false
end
end
local slot_headers = '<tr>' .. slot_headers .. '<th rowspan="2">Max Total Possible</th>' .. '</tr>'
local min_max_headers = '<tr>' .. min_max_headers .. '</tr>'
local table_str = '<table class="enchantmenttable">' .. slot_headers .. min_max_headers .. enchant_rows .. "</table>"
return table_str
end
function p.draw_socket_cost_table(frame)
local output_str = ""
local data_rows = ""
local header_row = "<tr>" .. "<th>Rarity</td>" .. "<th>Cost</th>" .. "</tr>"
local row
local i = 1 --display rarity_nums starting at i=1 (Poor), skipping Junk
local ending_i = 7 --end with Unique=7
-- this is O(n^2), but since theres only 8 elements, its inconsequential
-- Iterate costs in data first
local rarity_num
while i <= ending_i do
for rarity_name, cost in pairs(enchantments_data["enchant_costs"]) do
-- Determine the rarity_num
rarity_num = utils.rarity_name_to_num(rarity_name)
if i == rarity_num then
-- This is the next rarity that should be displayed
row = "<td>" .. "<span class=\"colorrarity" .. i .. "\">" .. rarity_name .. "</span>" .. "</td>" .. "<td>" .. cost .. "</td>"
data_rows = data_rows .. "<tr>" .. row .. "</tr>"
i = i+1 -- look for the next rarity
break -- end the current rarity-search
end
end
end
return "<table class=\"wikitable\" style=\"border-collapse:collapse;\">" .. header_row .. data_rows .. "</table>"
end
return p