From 00396522fb73bcd27269387ded6a105ac3e6fe50 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jul 2020 13:20:24 +0200 Subject: [PATCH] chore: prepare for AbstractCharacter extraction --- sonic-radiance.love/game/characters.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sonic-radiance.love/game/characters.lua b/sonic-radiance.love/game/characters.lua index 32bb403..3a0a9ee 100644 --- a/sonic-radiance.love/game/characters.lua +++ b/sonic-radiance.love/game/characters.lua @@ -36,15 +36,19 @@ function CharacterManager:new(controller) end function CharacterManager:init() - for k, v in pairs(self.namelist) do - local dir = "datas/gamedata/characters/" .. v .. "/init.lua" - local fileinfo = love.filesystem.getInfo(dir) - if fileinfo ~= nil then - self:initCharacter(v) + for k, name in pairs(self.namelist) do + if (self:charDataExists(name)) then + self:initCharacter(name) end end end +function CharacterManager:charDataExists(name) + local dir = "datas/gamedata/characters/" .. name .. "/init.lua" + local fileinfo = love.filesystem.getInfo(dir) + return (fileinfo ~= nil) +end + function CharacterManager:getCharacterData(charname) -- va eprmettre de récupérer les données d'un personnage local charfolder = "datas.gamedata.characters." .. charname