Module:Parse

From Aethermancer Wiki
Jump to navigation Jump to search

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

local p = { }

local colorStyles = {
	["TRIGGERS"] = {
		color	= "#f5bf5e",
		text	= {
			[1]  = {"%[on action%]", "On Action:", "Actions"},
			[2]  = {"%[on attack%]", "On Attack:", "Damage Actions"},
			[3]  = {"%[on single attack%]", "On Single-Target Attack:", "Damage Actions"},
			[4]  = {"%[on support action%]", "On Support Action:", "Support Actions"},
			[5]  = {"%[on interrupt%]", "On Interrupt:", "Interrupt"},
			[6]  = {"%[on crit%]", "On Crit:", "Critical Hits"},
			[7]  = {"%[on copied action%]", "On Copied Action:", ""},
			[8]  = {"%[retaliate%]", "Retaliate:", "Retaliate"},
			[9]  = {"%[shield]", "Shield", "Shield (Effect)"},
			[10] = {"%[shields]", "Shields", "Shield (Effect)"},
			[11] = {"%[purge%]", "Purge", "Purge (Effect)"},
			[12] = {"%[purges%]", "Purges", "Purge (Effect)"},
			[13] = {"%[purged%]", "purged", "Purge (Effect)"},
			[14] = {"%[steal%]", "Steal", "Steal (Effect)"},
			[15] = {"%[steals%]", "Steals", "Steal (Effect)"},
			[16] = {"%[stolen%]", "stolen", "Steal (Effect)"},
			[17] = {"%[trigger aether%]", "Trigger Aether Generation", "Aether"},
			[18] = {"%[triggers aether%]", "Triggers Aether Generation", "Aether"},
			[19] = {"%[reactivate%]", "Reactivate", "Reactivate (Effect)"},
			[20] = {"%[reactivates%]", "Reactivates", "Reactivate (Effect)"},
			[21] = {"%[critical%]", "Critical", "Critical Hits"},
			[22] = {"%[critical hit%]", "Critical Hit", "Critical Hits"},
			[23] = {"%[critical hits%]", "Critical Hits", "Critical Hits"},
			[24] = {"%[aging%]", "Aging", "Age (Status)"},
			[25] = {"%[affliction%]", "Affliction", "Affliction (Effect)"},
			[26] = {"%[target enemy%]", "Target Enemy", ""},
			[27] = {"%[corruption%]", "Corruption", "Corruption"},
			[28] = {"%[poise damage%]", "Poise Damage", "Poise"},
			[29] = {"%[stagger%]", "Stagger", "Poise"},
			[30] = {"%[free action%]", "Free Action", "Free Actions"},
			[31] = {"%[wild%]", "Wild", ""},
			[32] = {"%[wild aether%]", "Wild Aether", ""},
			[33] = {"%[wild damage%]", "Wild Damage", ""}
		}
	},
	["BUFFS"] = {
		color	= "#abddaf",
		text	= {
			[1]  = {"%[age%]", "Age", "Age (Status)"},
			[2]  = {"%[dodge%]", "Dodge", "Dodge (Status)"},
			[3]  = {"%[force%]", "Force", "Force (Status)"},
			[4]  = {"%[power%]", "Power", "Power (Status)"},
			[5]  = {"%[temp power%]", "Temporary Power", "Power (Status)"},
			[6]  = {"%[temporary power%]", "Temporary Power", "Power (Status)#Temporary Power"},
			[7]  = {"%[redirect%]", "Redirect", "Redirect (Status)"},
			[8]  = {"%[regen%]", "Regeneration", "Regeneration (Status)"},
			[9]  = {"%[regeneration%]", "Regeneration", "Regeneration (Status)"},
			[10] = {"%[sidekick%]", "Sidekick", "Sidekick (Status)"}
		}
	},
	["DEBUFFS"] = {
		color	= "#db7c7f",
		text	= {
			[1] = {"%[poison%]", "Poison", "Poison (Status)"},
			[2] = {"%[burn%]", "Burn", "Burn (Status)"},
			[3] = {"%[terror%]", "Terror", "Terror (Status)"}
		}
	},
	["WEAKNESS"] = {
		color	= "#e1545a",
		text	= {
			[1] = {"%[weakness%]", "Weakness", "Weakness (Status)"}
		}
	},
	["TERMS"] = {
		color	= "#83c1d3",
		text	= {
			[1]  = {"%[aether%]", "Aether", ""},
			[2]  = {"%[corruption cleanse%]", "Corruption Cleanse", ""},
			[3]  = {"%[crit%]", "Crit Chance", ""},
			[4]  = {"%[crit chance%]", "Crit Chance", ""},
			[5]  = {"%[crit damage%]", "Crit Damage", ""},
			[6]  = {"%[damage%]", "Damage", ""},
			[7]  = {"%[defense%]", "Defense", ""},
			[8]  = {"%[evasion%]", "Evasion", ""},
			[9]  = {"%[healing%]", "Healing", ""},
			[10] = {"%[hit%]", "Hit", ""},
			[11] = {"%[shielding%]", "Shielding", ""},
			[12] = {"%[terror application%]", "Terror Application", ""}
		}
	},
	["HIGHLIGHT"] = {
		color = "#ffdb00",
		text	= {
			[1]  = {"%{earth%}", "Earth", "Earth (Element)"},
			[2]  = {"%{fire%}", "Fire", "Fire (Element)"},
			[3]  = {"%{water%}", "Water", "Water (Element)"},
			[4]  = {"%{wind%}", "Wind", "Wind (Element)"},
			[5]  = {"%{wild%}", "Wild", ""},
			[6]  = {"%{cooking%}", "Cooking", "Cooking (Status)"},
			[7]  = {"%{consumes%}", "Consumes", ""},
			[8]  = {"%{debuff%}", "debuff", "Debuffs"},
			[9]  = {"%{debuffs%}", "Debuffs", "Debuffs"},
			[10] = {"%{critical hits%}", "Critical Hits", "Critical Hits"},
			[11] = {"%{poise%}", "Poise", "Poise"},
			[12] = {"%{second%}", "second", ""},
			[13] = {"%{third%}", "third", ""},
			[14] = {"%{(%d+)%}", "%1", ""},
			[15] = {"%{(%d+%%)%}", "%1", ""},
			[16] = {"%{XXX%}", "XXX", ""}
		}
	},
	["AURA"] = {
		color	= "#a96dcb",
		text	= {
			[1] = {"%[aura%]", "Aura:", "Auras"}
		}
	},
	["EARTH"] = {
		color	= "#ae7b3c",
		text	= {
			[1] = {"%[earth%]", "Earth", "Earth (Element)"}
		}
	},
	["FIRE"] = {
		color	= "#d96d46",
		text	= {
			[1] = {"%[fire%]", "Fire", "Fire (Element)"}
		}
	},
	["WATER"] = {
		color	= "#658fe5",
		text	= {
			[1] = {"%[water%]", "Water", "Water (Element)"}
		}
	},
	["WIND"] = {
		color	= "#84c66e",
		text	= {
			[1] = {"%[wind%]", "Wind", "Wind (Element)"}
		}
	},
	["ITALICS"] = {
		color	= "#625556",
		text	= {
			[1] = {"<i>(.+)</i>", "<i>%1</i>", ""}
		}
	},
	["NUMBERS"] = {
		color = "#ff9700",
		text	= {
			[1] = {"%[(%d+)%]", "%1", ""},
			[2] = {"%[(%d+%%)%]", "%1", ""},
			[3] = {"%[%*%]", "*", ""}
		}
	},
}

-- Replaces some terms in descriptions, giving proper formatting and links.
function p.replaceTerm (text)
	for k, v in pairs(colorStyles) do
		for _, i in pairs(v["text"]) do
			local format = "<span style=\"color: " .. v["color"] .. "\">" .. i[2] .. "</span>"
			if (i[3] or "") ~= "" then format = "[[" .. i[3] .. "|" .. format .. "]]" end 
			text = text:gsub(i[1], format)
	end end
	return text
end

-- Splits each element in an array with the Tag template.
function p.tag (frame, array, seperator, category, size)
	local data = ""
	local i = 0
	for k, v in ipairs(array) do
		if seperator == "slash" and i > 0 then data = data .. " / " end
		if seperator == "plus" and i > 0 then data = data .. " + " end
		
		if seperator == "linebreak icons" then
			if category == "types" then data = data .. frame:expandTemplate{title = "Types", args = {v, icon = true} } .. " " end
		end
		
		if category == "types" then data = data .. "<b>" .. frame:expandTemplate{title = "Types", args = {v} } .. "</b>"
		else data = data .. frame:expandTemplate{title = "Tag", args = {v, category = category, size = size} } end
		i = i + 1
		
		if (seperator == "linebreak" or seperator == "linebreak icons") then data = data .. "<br/>" else data = data .. " " end
	end
	return data
end

return p