game: load at start character module

This commit is contained in:
Kazhnuz 2019-03-10 13:41:37 +01:00
parent 824fcb866b
commit 9a828197e5
2 changed files with 11 additions and 7 deletions

View file

@ -26,16 +26,16 @@ local CharacterManager = Object:extend()
function CharacterManager:new(controller) function CharacterManager:new(controller)
self.controller = controller self.controller = controller
self.namelist = require "datas.characters" self.namelist = require "datas.gamedata.characters"
self.list = {} self.list = {}
self.team = require "datas.characters.baseteam" self.team = require "datas.gamedata.characters.baseteam"
self.active = 1 self.active = 1
self:init() self:init()
end end
function CharacterManager:init() function CharacterManager:init()
for k, v in pairs(self.namelist) do for k, v in pairs(self.namelist) do
local dir = "datas/characters/" .. v .. ".lua" local dir = "datas/gamedata/characters/" .. v .. ".lua"
local fileinfo = love.filesystem.getInfo(dir) local fileinfo = love.filesystem.getInfo(dir)
if fileinfo ~= nil then if fileinfo ~= nil then
self:initCharacter(v) self:initCharacter(v)
@ -45,7 +45,7 @@ end
function CharacterManager:getCharacterData(charname) function CharacterManager:getCharacterData(charname)
-- va eprmettre de récupérer les données d'un personnage -- va eprmettre de récupérer les données d'un personnage
return require("datas.characters." .. charname) return require("datas.gamedata.characters." .. charname)
end end
function CharacterManager:initCharacter(id) function CharacterManager:initCharacter(id)

View file

@ -24,23 +24,27 @@
]] ]]
local Game = Object:extend() local Game = Object:extend()
local Characters = require "game.characters"
local binser = require "libs.binser" local binser = require "libs.binser"
function Game:new() function Game:new()
self.slot = -1 self.slot = -1
self.gametime = 0 self.gametime = 0
self.characters = Characters(self)
end end
function Game:setData(data) function Game:setData(data)
local data = data local data = data
self.gametime = data.gametime self.gametime = data.gametime
self.characters:setData(data.characters)
end end
function Game:getData() function Game:getData()
local data = {} local data = {}
data.gametime = self.gametime data.gametime = self.gametime
data.characters = self.characters:getData()
return data return data
end end