Module:HeroData/release

From Deadlock Wiki
Revision as of 23:32, 23 November 2024 by Sur (talk | contribs) (p.demo added)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Functions

get_hero_release_status

Determines the release-status of a given hero

Parameters

  • hero_key - Key of the hero to check

Output

  • HeroLabs - If the hero is currently playable in Hero Labs
  • Released - If the hero is currently playable in all modes
  • nil - If the hero is neither

Examples

{{#invoke:HeroData/release|get_hero_release_status|hero_synth}} Released

{{#invoke:HeroData/release|get_hero_release_status|hero_trapper}} HeroLabs

{{#invoke:HeroData/release|get_hero_release_status|hero_operative}}


{{#invoke:HeroData/release|get_hero_release_status|hero_madeuphero}} hero_key hero_madeuphero is not a hero


local p = {}
local heroes_data = mw.loadJsonData('Data:HeroData.json')

-- function for if the hero is released, or in herolabs
-- logic may change in the future as Valve adds more flags
function p.get_hero_release_status(hero_key)
	local hero_data = heroes_data[hero_key]
	if (hero_data == nil) then return "hero_key " .. hero_key .. " is not a hero" end
	
	local in_herolabs = hero_data['InHeroLabs'] and hero_data['IsSelectable']
	if in_herolabs == nil then in_herolabs = false end
	if in_herolabs then 
		return "HeroLabs"
	elseif not hero_data['IsDisabled'] and not hero_data['InDevelopment'] and hero_data['IsSelectable'] then
		return "Released"
	end
	
	return nil
end

function p.demo(frame)
	local hero_key = frame.args[1]
	return p.get_hero_release_status(hero_key)
end

return p