Module:Sandbox/Aurelain/SkillSynergies: Difference between revisions
From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
local SkillsOverview = require("Module:Sandbox/Aurelain/SkillsOverview") | local SkillsOverview = require("Module:Sandbox/Aurelain/SkillsOverview") | ||
local PATCH_NAME = { | |||
['Summon Avatar'] = 'Summon Avatar (Skill)', | |||
} | |||
------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ||
-- Debugs a variable | -- Debugs a variable | ||
| Line 8: | Line 10: | ||
local function dump(target) | local function dump(target) | ||
return '<pre>' .. mw.dumpObject(target) .. '</pre>' | return '<pre>' .. mw.dumpObject(target) .. '</pre>' | ||
end | |||
------------------------------------------------------------------------------------------------------------------------ | |||
-- Creates a "Foo/XX|" string based on the first quoted word in a text | |||
------------------------------------------------------------------------------------------------------------------------ | |||
local function repairPunctuation(text) | |||
local allQuotes = [=["„“”‘’«»「」『』]=] | |||
local punctuation = "%,%.%!%?" | |||
local pattern = "([" .. punctuation .. "])([" .. allQuotes .. "])" | |||
text = mw.ustring.gsub(text, pattern, "%2%1") | |||
return text | |||
end | |||
------------------------------------------------------------------------------------------------------------------------ | |||
-- Creates a "Foo/XX|" string based on the first quoted word in a text | |||
------------------------------------------------------------------------------------------------------------------------ | |||
local function generateRoboticLink(descriptionInEnglish, lang) | |||
local name = descriptionInEnglish:match("“(.-)”") | |||
if name and name ~= '' then | |||
name = PATCH_NAME[name] or name | |||
return name .. '/' .. lang .. '|' | |||
end | |||
return nil | |||
end | |||
------------------------------------------------------------------------------------------------------------------------ | |||
-- Debugs a variable | |||
------------------------------------------------------------------------------------------------------------------------ | |||
local function findSynergies(allSkills, skill, lang) | |||
local synergies = {} | |||
for _, group in ipairs(allSkills) do | |||
for _, rank in ipairs(group.ranks) do | |||
for _, subSkill in pairs(rank.subSkills) do | |||
if lang == 'en' then | |||
--local description = repairEnglishPunctuation() | |||
else | |||
--local enDescription = repairEnglishPunctuation(subSkill.en) | |||
--local roboticLink = generateSpecificRoboticLink(enDescription, lang, skill) | |||
--if checkMentionsSkill(enDescription, skill) then | |||
-- end | |||
--end | |||
end | |||
end | |||
end | |||
end | |||
return synergies | |||
end | |||
------------------------------------------------------------------------------------------------------------------------ | |||
-- Debugs a variable | |||
------------------------------------------------------------------------------------------------------------------------ | |||
local function findEnglishName(allSkills, skill) | |||
for _, group in ipairs(allSkills) do | |||
if group.id == skill then | |||
return group.nameEn | |||
end | |||
end | |||
end | end | ||
| Line 14: | Line 74: | ||
------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ||
function p.display(frame) | function p.display(frame) | ||
-- Args | |||
local args = frame.args | local args = frame.args | ||
local lang = args.lang or 'en' | local lang = args.lang or 'en' | ||
local skill = args.skill | local skill = args.skill | ||
if not skill or skill == '' then | if not skill or skill == '' then return 'You must provide a skill id' end | ||
lang = 'fr' | |||
--skill = 'skill_formation' | --skill = 'skill_formation' | ||
local allSkills = SkillsOverview.getSkillsFromCargo(lang) | local allSkills = SkillsOverview.getSkillsFromCargo(lang) | ||
if 1 then return dump( | local nameEn = findEnglishName(allSkills, skill) | ||
if not nameEn then return 'Cannot find name for skill' end | |||
--local synergies = findSynergies(allSkills, skill, lang) | |||
if 1 then return dump(nameEn) end | |||
return 'hello' | return 'hello' | ||
Revision as of 06:59, 9 June 2026
Documentation for this module may be created at Module:Sandbox/Aurelain/SkillSynergies/doc
-- Usage: {{#invoke:SkillSynergies|display|lang=en|skill=skill_assault}}
local p = {}
local SkillsOverview = require("Module:Sandbox/Aurelain/SkillsOverview")
local PATCH_NAME = {
['Summon Avatar'] = 'Summon Avatar (Skill)',
}
------------------------------------------------------------------------------------------------------------------------
-- Debugs a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end
------------------------------------------------------------------------------------------------------------------------
-- Creates a "Foo/XX|" string based on the first quoted word in a text
------------------------------------------------------------------------------------------------------------------------
local function repairPunctuation(text)
local allQuotes = [=["„“”‘’«»「」『』]=]
local punctuation = "%,%.%!%?"
local pattern = "([" .. punctuation .. "])([" .. allQuotes .. "])"
text = mw.ustring.gsub(text, pattern, "%2%1")
return text
end
------------------------------------------------------------------------------------------------------------------------
-- Creates a "Foo/XX|" string based on the first quoted word in a text
------------------------------------------------------------------------------------------------------------------------
local function generateRoboticLink(descriptionInEnglish, lang)
local name = descriptionInEnglish:match("“(.-)”")
if name and name ~= '' then
name = PATCH_NAME[name] or name
return name .. '/' .. lang .. '|'
end
return nil
end
------------------------------------------------------------------------------------------------------------------------
-- Debugs a variable
------------------------------------------------------------------------------------------------------------------------
local function findSynergies(allSkills, skill, lang)
local synergies = {}
for _, group in ipairs(allSkills) do
for _, rank in ipairs(group.ranks) do
for _, subSkill in pairs(rank.subSkills) do
if lang == 'en' then
--local description = repairEnglishPunctuation()
else
--local enDescription = repairEnglishPunctuation(subSkill.en)
--local roboticLink = generateSpecificRoboticLink(enDescription, lang, skill)
--if checkMentionsSkill(enDescription, skill) then
-- end
--end
end
end
end
end
return synergies
end
------------------------------------------------------------------------------------------------------------------------
-- Debugs a variable
------------------------------------------------------------------------------------------------------------------------
local function findEnglishName(allSkills, skill)
for _, group in ipairs(allSkills) do
if group.id == skill then
return group.nameEn
end
end
end
------------------------------------------------------------------------------------------------------------------------
-- Main public function
------------------------------------------------------------------------------------------------------------------------
function p.display(frame)
-- Args
local args = frame.args
local lang = args.lang or 'en'
local skill = args.skill
if not skill or skill == '' then return 'You must provide a skill id' end
lang = 'fr'
--skill = 'skill_formation'
local allSkills = SkillsOverview.getSkillsFromCargo(lang)
local nameEn = findEnglishName(allSkills, skill)
if not nameEn then return 'Cannot find name for skill' end
--local synergies = findSynergies(allSkills, skill, lang)
if 1 then return dump(nameEn) end
return 'hello'
end
return p


