Module:Abilities/details table

From Deadlock Wiki
Revision as of 11:25, 1 October 2024 by Saag (talk | contribs) (Created page with "p = {} local utils = require "Module:Abilities/utils" p.get_details_table = function(frame) local hero_name = frame.args[1] local ability_num = frame.args[2] local ability = utils.get_ability_card_data(hero_name, ability_num) if(ability == nil) then return "Ability Not Found" end local rows = '' for info_section_num=1, 10 do local info_section = ability['Info'..info_section_num] if info_section == nil then break end -- display props from info sections...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Abilities module handles any simple functions that don't require a submodule

Usage

Template:Ability card v2/Details

Submodules

Abilities - Simple functions. Eg. getting ability name

Abilities/utils - Common internal functions that are shared amongst any Abilities/ modules

Abilities/card - Generates hero ability cards

Abilities/icon - Searches for an icon based on the (English) name of the ability

Abilities/details table (WIP) - Generates details table to show raw ability data


p = {}

local utils = require "Module:Abilities/utils"

p.get_details_table = function(frame)
	local hero_name = frame.args[1]
	local ability_num = frame.args[2]

	local ability = utils.get_ability_card_data(hero_name, ability_num)
	if(ability == nil) then return "Ability Not Found" end
	
	local rows = ''
	for info_section_num=1, 10 do
		local info_section = ability['Info'..info_section_num]
		if info_section == nil then break end
		
		-- display props from info sections first
		for prop in info_section.Main.Props do
			local scale_value = prop.Scale and prop.Scale.Value or nil
			local scale_type = prop.Scale and prop.Scale.Type or nil
			rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value)	
		end
		
		for prop in info_section.Alt.Props do
			local scale_value = prop.Scale and prop.Scale.Value or nil
			local scale_type = prop.Scale and prop.Scale.Type or nil
			rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value)	
		end
		
	-- then any header data, cooldowns, charges, range etc.

	-- then other data that is hidden on the ability card
	return rows
end

function create_row(key, value, scale_type, scale_value)
	local row = '|' .. label .. '||' .. value
	
	if scale_type and scale_value then
		row = row .. '||' .. scale_type .. '||' .. scale_value 	
	end
	
	return row
end

end