Module:Sandbox: Difference between revisionsGive feedback
No edit summary |
No edit summary |
||
| Line 39: | Line 39: | ||
end | end | ||
-- | -- Function to get all abilities of released heroes | ||
function p.get_all_released_abilities_list() | function p.get_all_released_abilities_list() | ||
local abilities = {} | local abilities = {} | ||
for hero_key, hero_data in pairs(heroes_data) do | for hero_key, hero_data in pairs(heroes_data) do | ||
-- | -- Check if the hero is released | ||
if heroes_data_release.get_hero_release_status(hero_key) == "Released" then | if heroes_data_release.get_hero_release_status(hero_key) == "Released" then | ||
-- | -- Check if the hero has BoundAbilities | ||
if hero_data['BoundAbilities'] then | if hero_data['BoundAbilities'] then | ||
for _, ability_data in pairs(hero_data['BoundAbilities']) do | for _, ability_data in pairs(hero_data['BoundAbilities']) do | ||
| Line 57: | Line 57: | ||
end | end | ||
-- | -- Remove duplicate abilities | ||
local unique_abilities = {} | local unique_abilities = {} | ||
for _, ability in ipairs(abilities) do | for _, ability in ipairs(abilities) do | ||
| Line 63: | Line 63: | ||
end | end | ||
-- | -- Collect unique abilities back into a table | ||
local result = {} | local result = {} | ||
for ability, _ in pairs(unique_abilities) do | for ability, _ in pairs(unique_abilities) do | ||
| Line 69: | Line 69: | ||
end | end | ||
-- | -- Sort alphabetically | ||
table.sort(result) | table.sort(result) | ||
-- | -- Join with commas | ||
return table.concat(result, ", ") | return table.concat(result, ", ") | ||
end | end | ||
return p | return p | ||