Module:Sandbox: Difference between revisionsGive feedback
Jump to navigation
Jump to search
get_released_heroes_list |
get_all_abilities_list |
||
| Line 37: | Line 37: | ||
-- Combine into a comma-separated string | -- Combine into a comma-separated string | ||
return table.concat(released_heroes, ", ") | return table.concat(released_heroes, ", ") | ||
end | |||
-- Функция для получения всех способностей вышедших героев | |||
function p.get_all_abilities_list() | |||
local abilities = {} | |||
for hero_key, hero_data in pairs(heroes_data) do | |||
-- Проверяем, что герой выпущен | |||
if heroes_data_release.get_hero_release_status(hero_key) == "Released" then | |||
-- Проверяем наличие BoundAbilities у героя | |||
if hero_data['BoundAbilities'] then | |||
for _, ability_data in pairs(hero_data['BoundAbilities']) do | |||
if ability_data['Name'] then | |||
table.insert(abilities, ability_data['Name']) | |||
end | |||
end | |||
end | |||
end | |||
end | |||
-- Удаляем дубликаты способностей | |||
local unique_abilities = {} | |||
for _, ability in ipairs(abilities) do | |||
unique_abilities[ability] = true | |||
end | |||
-- Собираем уникальные способности обратно в таблицу | |||
local result = {} | |||
for ability, _ in pairs(unique_abilities) do | |||
table.insert(result, ability) | |||
end | |||
-- Сортируем по алфавиту | |||
table.sort(result) | |||
-- Объединяем через запятую | |||
return table.concat(result, ", ") | |||
end | end | ||
return p | return p | ||
Revision as of 23:37, 21 April 2025
Documentation for this module may be created at Module:Sandbox/doc
local p = {}
local items_data = mw.loadJsonData("Data:ItemData.json")
local heroes_data = mw.loadJsonData('Data:HeroData.json')
local heroes_data_release = require('Module:HeroData/release')
function p.get_all_item_names(frame)
local item_names = {}
-- Collect all the names of the items
for item_key, item_data in pairs(items_data) do
if item_data["Name"] and item_data["IsDisabled"] == false then
table.insert(item_names, item_data["Name"])
end
end
-- Sort alphabetically
table.sort(item_names)
-- Merge with commas
return table.concat(item_names, ", ")
end
-- Function to get the list of all released heroes
function p.get_released_heroes_list()
local released_heroes = {}
for hero_key, hero_data in pairs(heroes_data) do
if heroes_data_release.get_hero_release_status(hero_key) == "Released" then
table.insert(released_heroes, hero_data['Name'])
end
end
-- Sort hero names alphabetically
table.sort(released_heroes)
-- Combine into a comma-separated string
return table.concat(released_heroes, ", ")
end
-- Функция для получения всех способностей вышедших героев
function p.get_all_abilities_list()
local abilities = {}
for hero_key, hero_data in pairs(heroes_data) do
-- Проверяем, что герой выпущен
if heroes_data_release.get_hero_release_status(hero_key) == "Released" then
-- Проверяем наличие BoundAbilities у героя
if hero_data['BoundAbilities'] then
for _, ability_data in pairs(hero_data['BoundAbilities']) do
if ability_data['Name'] then
table.insert(abilities, ability_data['Name'])
end
end
end
end
end
-- Удаляем дубликаты способностей
local unique_abilities = {}
for _, ability in ipairs(abilities) do
unique_abilities[ability] = true
end
-- Собираем уникальные способности обратно в таблицу
local result = {}
for ability, _ in pairs(unique_abilities) do
table.insert(result, ability)
end
-- Сортируем по алфавиту
table.sort(result)
-- Объединяем через запятую
return table.concat(result, ", ")
end
return p