improvement(game): rework internal sorting of skill

It'll make us able to sort them by acquisition level
This commit is contained in:
Kazhnuz 2019-08-17 00:55:29 +02:00
parent c7e771542b
commit fcd1288ebf
2 changed files with 18 additions and 6 deletions

View file

@ -139,11 +139,23 @@ function CharacterManager:getSkillList(id)
for i, v in ipairs(character.skills) do
local tech_name, tech_level, isLearned = v[1], v[2], false
if tech_level <= character.stats.level then
local canLearn = true
for i, learnedSkill in ipairs(learnedlist) do
if learnedlist[tech_name] == nil then
learnedlist[tech_name] = 1
else
learnedlist[tech_name] = learnedlist[tech_name] + 1
-- We check if the skill have already been learned, to level-up it
if learnedSkill.name == tech_name then
canLearn = false
learnedSkill.level = learnedSkill.level + 1
end
end
if (canLearn) then
local skilldata = {}
skilldata.name = tech_name
skilldata.level = 1
skilldata.learnedAt = tech_level
table.insert(learnedlist, skilldata)
end
end

View file

@ -49,8 +49,8 @@ end
function MenuConstructor:buildSkillMenu(character)
CharacterMenu(self.controller, "SkillMenu", MENUPOS_X1 - 16, MENUPOS_Y)
local list = game.characters:getSkillList(character.charid)
for k,v in pairs(list) do
SkillWidget(self.controller, "SkillMenu", k, "", character)
for k, skill in pairs(list) do
SkillWidget(self.controller, "SkillMenu", skill.name, "", character)
end
SubMenuWidget(self.controller, "SkillMenu", "back", "BaseMenu", character)