Module:DiceUtils

From bg3.wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:DiceUtils/doc

local p = {}

function p.calculateDamage(frame)
	args = frame.args
	
	result = {}
	damage = {
		Acid = {},
		Cold = {},
		Fire = {},
		Force = {},
		Healing = {},
		Lightning = {},
		Necrotic = {},
		Poison = {},
		Radiant = {},
		Thunder = {},
		Psychic = {},
		Physical = {},
		Piercing = {},
		Bludgeoning = {},
		Slashing = {}
	}
	tmp = {}
	for damage_die in string.gmatch(args.dice, "([^,]+)") do
		idx = string.find(damage_die, ":")
		die = string.sub(damage_die, 1, idx - 1)
		d_type = string.sub(damage_die, idx + 1)
		
		table.insert(tmp, d_type)
	end
	return table.concat(tmp, "<br>")

end

return p