Module:Sandbox/One Bar: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
One Bar (talk | contribs)
No edit summary
One Bar (talk | contribs)
No edit summary
Line 2: Line 2:
local item_data = mw.loadJsonData("Data:ItemData.json")
local item_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local soul_unlocks_data = mw.loadJsonData("Data:SoulUnlockData.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")


local level_scaling_key_to_name = {
p.write_spirit_scaling_table = function(frame)
BulletDamage = "Bullet Damage",
MaxHealth = "Health",
TechPower = "Spirit Power",
LightMeleeDamage = "Light Melee Damage",
HeavyMeleeDamage = "Heavy Melee Damage"
}
 
-- Not in HeroData.json although Shiv is just (bullet damage * 12)
local alt_fires = {
Shiv = {base = 59.4, level = 2.64, suffix = "alt fire 12 pellets"},
Viscous = {base = 70, level = 0.9, suffix = "alt fire AOE"},
Yamato = {base = 70, level = 0.35, suffix = "alt fire AOE"}
}
 
p.write_power_increase_table = function(frame)
local pi_souls_list = {}
local pi_souls_list = {}
for _, v in ipairs(soul_unlocks_data) do
for _, v in ipairs(soul_unlocks_data) do
Line 30: Line 15:
local filtered_heroes = {}
local filtered_heroes = {}
for _, hero in pairs(heroes_data) do
for hero_key, hero in pairs(heroes_data) do
if (not hero["IsDisabled"]) then
if (not hero["IsDisabled"]) then
table.insert(filtered_heroes, hero)
filtered_heroes[hero_key] = hero
end
end
end
end
local property = frame.args[1] --frame:getParent().args[1]
local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
local name = level_scaling_key_to_name[property]
local suffix = property == "BulletDamage" and " (Full Shot)" or ""
local create_div = mw.html.create("div"):css("overflow-x", "auto"):done()
local create_table = mw.html.create("table"):addClass("wikitable sortable mw-collapsible mw-collapsed"):done()
local title_header = mw.html.create("tr")
local title_header = mw.html.create("tr")
title_header:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done()
title_header:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done()
create_table:node(title_header)
create_table:node(title_header)
local label_header = mw.html.create("tr")
local header = mw.html.create("tr")
label_header
header
:tag("th"):attr("rowspan", 2):wikitext("Hero"):done()
:tag("th"):wikitext("Hero"):done()
:tag("th"):attr("rowspan", 2):wikitext("Base " .. name .. suffix):done()
:tag("th"):wikitext("Stats"):done()
:tag("th"):attr("rowspan", 2):wikitext("PL Increase" .. suffix):done()
:tag("th"):attr("colspan", 2):wikitext("First Skill"):done()
:tag("th"):attr("colspan", level_count):wikitext("Souls Collected"):done()
:tag("th"):attr("colspan", 2):wikitext("Second Skill"):done()
create_table:node(label_header)
:tag("th"):attr("colspan", 2):wikitext("Third Skill"):done()
:tag("th"):attr("colspan", 2):wikitext("Ultimate"):done()
create_table:node(header)
local souls_header = mw.html.create("tr")
for hero_key, hero in pairs(filtered_heroes) do
for _, v in ipairs(pi_souls_list) do
local test = hero["Spirit Scaling"]
local souls_formatted = string.format("%.1fK", (v + 400) / 1000)
souls_formatted = frame:expandTemplate{ title = "Souls", args = {souls_formatted}}
souls_header:tag("th"):wikitext(souls_formatted):done()
end
create_table:node(souls_header)
for _, hero in ipairs(filtered_heroes) do
local base = math.floor((hero[property] or 0) * 100) / 100
local level = math.floor(hero["LevelScaling"][property] * 100) / 100
local shots = hero["BulletsPerShot"]
local burst = hero["BulletsPerBurst"]
local bullet_mult = shots * burst
local hero_icon = frame:expandTemplate{ title = "HeroIcon", args = {hero["Name"]}}
local hero_suffix = ""
if (property == "BulletDamage" and bullet_mult > 1) then
base = base * bullet_mult
level = level * bullet_mult
if (shots > 1) then hero_suffix = hero_suffix .. " (" .. shots .. " pellets)" end
if (burst > 1) then hero_suffix = hero_suffix .. " (" .. burst .. " bullets)" end
end
local hero_row = mw.html.create("tr")
local hero_row = mw.html.create("tr")
hero_row
stats_text = ""
:tag("td"):wikitext(hero_icon .. hero_suffix):done()
if (hero["SpiritScaling"] ~= nil and next(hero["SpiritScaling"]) ~= nil) then
:tag("td"):wikitext(base):done()
for k, v in ipairs(hero["SpiritScaling"]) do
:tag("td"):wikitext("+" .. level):done()
stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n"
end
for i, v in ipairs(pi_souls_list) do
else
local total = (tonumber(base) ~= nil and base or 0) + (tonumber(level) ~= nil and level or 0)  * i
stats_text = "-"
hero_row
:tag("td"):wikitext(total):done()
end
end
hero_row:tag('td'):wikitext(hero_text):done()
create_table:node(hero_row)
for i=1,4 do
local ability = ability_data[hero_key][tostring(i)]
if (property == "BulletDamage" and alt_fires[hero["Name"]] ~= nil) then
hero_row:tag('td'):wikitext(ability["Name"]):done()
local alt_fire = alt_fires[hero["Name"]]
local ability_text = ""
local alt_base = alt_fire["base"]
-- Nowhere close to all the instances of ability spirit scaling
local alt_level = alt_fire["level"]
if (ability["Info1"]["Main"]["Props"] ~= nil and next(ability["Info1"]["Main"]["Props"]) ~= nil) then
local alt_suffix = " (" .. alt_fire["suffix"] .. ")"
for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
local alt_fire_row = mw.html.create("tr")
if (prop["Scale"] ~= nil and next(prop["Scale"]) ~= nil) then
alt_fire_row
ability_text = ability_text .. prop["Name"] ..": " .. prop["Value"] .. " + " .. prop["Scale"]["Value"] .. "\n"
:tag("td"):wikitext(hero_icon .. alt_suffix):done()
end
:tag("td"):wikitext(alt_base):done()
end
:tag("td"):wikitext("+" .. alt_level):done()
else
ability_text = "-"
for i, v in ipairs(pi_souls_list) do
local total = alt_base + alt_level * i
alt_fire_row:tag("td"):wikitext(total):done()
end
end
hero_row:tag('td'):wikitext(ability_text):done()
create_table:node(alt_fire_row)
end
end
create_table:node(hero_row)
end
end
create_div:node(create_table)
return tostring(create_table)
return tostring(create_div)
end
end



Revision as of 22:52, 19 May 2025

Documentation for this module may be created at Module:Sandbox/One Bar/doc

local p = {};
local item_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local ability_data = mw.loadJsonData("Data:AbilityCards.json")

p.write_spirit_scaling_table = function(frame)
	local pi_souls_list = {}
	for _, v in ipairs(soul_unlocks_data) do
		if (v["PowerIncrease"]) then
			table.insert(pi_souls_list, v["RequiredSouls"])
		end
	end
	local level_count = 0
	for _ in ipairs(pi_souls_list) do level_count = level_count + 1 end
	
	local filtered_heroes = {}
	for hero_key, hero in pairs(heroes_data) do
		if (not hero["IsDisabled"]) then
			filtered_heroes[hero_key] = hero
		end
	end
	
	local create_table = mw.html.create("table"):addClass("wikitable sortable"):done()
	local title_header = mw.html.create("tr")
	title_header:tag("th"):attr("colspan", (level_count + 3)):wikitext("Base " .. name .. " based on PI"):done()
	create_table:node(title_header)
	
	local header = mw.html.create("tr")
	header
		:tag("th"):wikitext("Hero"):done()
		:tag("th"):wikitext("Stats"):done()
		:tag("th"):attr("colspan", 2):wikitext("First Skill"):done()
		:tag("th"):attr("colspan", 2):wikitext("Second Skill"):done()
		:tag("th"):attr("colspan", 2):wikitext("Third Skill"):done()
		:tag("th"):attr("colspan", 2):wikitext("Ultimate"):done()
	create_table:node(header)
	
	for hero_key, hero in pairs(filtered_heroes) do
		local test = hero["Spirit Scaling"]
		local hero_row = mw.html.create("tr")
		stats_text = ""
		if (hero["SpiritScaling"] ~= nil and next(hero["SpiritScaling"]) ~= nil) then
			for k, v in ipairs(hero["SpiritScaling"]) do
				stats_text = stats_text .. k ..": ".. hero[k] .. "+" .. v .. "\n"
			end
		else
			stats_text = "-"
		end
		hero_row:tag('td'):wikitext(hero_text):done()
		for i=1,4 do
			local ability = ability_data[hero_key][tostring(i)]
			hero_row:tag('td'):wikitext(ability["Name"]):done()
			local ability_text = ""
			-- Nowhere close to all the instances of ability spirit scaling
			if (ability["Info1"]["Main"]["Props"] ~= nil and next(ability["Info1"]["Main"]["Props"]) ~= nil) then
				for _, prop in ipairs(ability["Info1"]["Main"]["Props"]) do
					if (prop["Scale"] ~= nil and next(prop["Scale"]) ~= nil) then
						ability_text = ability_text .. prop["Name"] ..": " .. prop["Value"] .. " + " .. prop["Scale"]["Value"] .. "\n"
					end
				end
			else
				ability_text = "-"
			end
			hero_row:tag('td'):wikitext(ability_text):done()
		end
		create_table:node(hero_row)
	end
	
	return tostring(create_table)
end

local function get_disabled_items_array()
	local disabledItems = {}
	for k, v in pairs(item_data) do
		if (v["IsDisabled"] == true and v["Name"] ~= nil) then
			disabledItems[k] = v
		end
	end
	return disabledItems
end

p.disabledItemsTable = function(frame)
	local requirements = {}
	local listofItems = ""
	local filteredData = {}
	filteredData = get_disabled_items_array()
	
	local createTable = mw.html.create('table')
			:addClass('wikitable sortable')
			:tag('caption'):wikitext("List of items"):done()
		
	local createTableHeader = mw.html.create('tr')
	createTableHeader
		:tag('th'):wikitext('Variable'):done()
		:tag('th'):wikitext('Name'):done()
		:tag('th'):wikitext('Category'):done()
		:tag('th'):wikitext('Description'):done()
		
	createTable:node(createTableHeader)
	
	-- query all the filtered items. itemName is the item table.
	for internalName, itemName in pairs(filteredData) do 
		local display = itemName["Name"]
		
		listofItems = listofItems .. itemName["Name"] .. "<br/>"
		
		
		local categoryDisplay = itemName["Slot"]
		
		local description = itemName["Description"]
		
		local tableData = mw.html.create('tr')
		tableData
			:tag('td'):wikitext(internalName):done()
			:tag('td'):wikitext(display):done()
			:tag('td'):wikitext(categoryDisplay):done()
			:tag('td'):wikitext(description):done()
			
		table.insert(requirements, tableData)
			
	end	
	
	for _, row in ipairs(requirements) do
		createTable:node(row)
	end
	
	return tostring(createTable)
end

return p