improvement(game): rework internal sorting of skill
It'll make us able to sort them by acquisition level
This commit is contained in:
parent
c7e771542b
commit
fcd1288ebf
2 changed files with 18 additions and 6 deletions
|
@ -139,11 +139,23 @@ function CharacterManager:getSkillList(id)
|
||||||
for i, v in ipairs(character.skills) do
|
for i, v in ipairs(character.skills) do
|
||||||
local tech_name, tech_level, isLearned = v[1], v[2], false
|
local tech_name, tech_level, isLearned = v[1], v[2], false
|
||||||
if tech_level <= character.stats.level then
|
if tech_level <= character.stats.level then
|
||||||
|
local canLearn = true
|
||||||
|
for i, learnedSkill in ipairs(learnedlist) do
|
||||||
|
|
||||||
if learnedlist[tech_name] == nil then
|
-- We check if the skill have already been learned, to level-up it
|
||||||
learnedlist[tech_name] = 1
|
if learnedSkill.name == tech_name then
|
||||||
else
|
canLearn = false
|
||||||
learnedlist[tech_name] = learnedlist[tech_name] + 1
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,8 +49,8 @@ end
|
||||||
function MenuConstructor:buildSkillMenu(character)
|
function MenuConstructor:buildSkillMenu(character)
|
||||||
CharacterMenu(self.controller, "SkillMenu", MENUPOS_X1 - 16, MENUPOS_Y)
|
CharacterMenu(self.controller, "SkillMenu", MENUPOS_X1 - 16, MENUPOS_Y)
|
||||||
local list = game.characters:getSkillList(character.charid)
|
local list = game.characters:getSkillList(character.charid)
|
||||||
for k,v in pairs(list) do
|
for k, skill in pairs(list) do
|
||||||
SkillWidget(self.controller, "SkillMenu", k, "", character)
|
SkillWidget(self.controller, "SkillMenu", skill.name, "", character)
|
||||||
end
|
end
|
||||||
SubMenuWidget(self.controller, "SkillMenu", "back", "BaseMenu", character)
|
SubMenuWidget(self.controller, "SkillMenu", "back", "BaseMenu", character)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue