parent
e2df082d92
commit
703d11d8b7
5 changed files with 62 additions and 8 deletions
|
@ -10,16 +10,20 @@ function AbstractCharacter:new(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function AbstractCharacter:initBasicElements()
|
function AbstractCharacter:initBasicElements()
|
||||||
self.data = charutils.getCharacterData(self.simplename)
|
self:getCommonData(self.simplename)
|
||||||
self.name = self.data.name
|
|
||||||
self.fullname = self.data.fullname
|
|
||||||
self.turns = self.data.turns
|
|
||||||
|
|
||||||
self.level = self.data.startlevel
|
self.level = self.data.startlevel
|
||||||
self.exp = charutils.getExpValue(self.level)
|
self.exp = charutils.getExpValue(self.level)
|
||||||
self.exp_next = charutils.getExpValue(self.level + 1)
|
self.exp_next = charutils.getExpValue(self.level + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function AbstractCharacter:getCommonData(simplename)
|
||||||
|
self.data = charutils.getCharacterData(self.simplename)
|
||||||
|
self.name = self.data.name
|
||||||
|
self.fullname = self.data.fullname
|
||||||
|
self.turns = self.data.turns
|
||||||
|
end
|
||||||
|
|
||||||
function AbstractCharacter:createStats()
|
function AbstractCharacter:createStats()
|
||||||
local stats = {}
|
local stats = {}
|
||||||
local base_stats = self.data.stats
|
local base_stats = self.data.stats
|
||||||
|
@ -89,4 +93,31 @@ function AbstractCharacter:heal()
|
||||||
self:initLife()
|
self:initLife()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function AbstractCharacter:getData()
|
||||||
|
local data = {}
|
||||||
|
data.simplename = self.simplename
|
||||||
|
data.level = self.level
|
||||||
|
data.exp = self.exp
|
||||||
|
data.exp_next = self.exp_next
|
||||||
|
data.hp = self.hp
|
||||||
|
data.pp = self.pp
|
||||||
|
data.statuts = self.statuts
|
||||||
|
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractCharacter:setData(data)
|
||||||
|
self.simplename = data.simplename
|
||||||
|
self:getCommonData(self.simplename)
|
||||||
|
|
||||||
|
self.level = data.level
|
||||||
|
self.exp = data.exp
|
||||||
|
self.exp_next = data.exp_next
|
||||||
|
self:createStats()
|
||||||
|
|
||||||
|
self.hp = data.hp
|
||||||
|
self.pp = data.pp
|
||||||
|
self.statuts = data.statuts
|
||||||
|
end
|
||||||
|
|
||||||
return AbstractCharacter
|
return AbstractCharacter
|
||||||
|
|
|
@ -70,15 +70,23 @@ end
|
||||||
|
|
||||||
function CharacterManager:getData()
|
function CharacterManager:getData()
|
||||||
local data = {}
|
local data = {}
|
||||||
data.list = self.list
|
|
||||||
data.team = self.team
|
data.team = self.team
|
||||||
|
data.list = {}
|
||||||
|
for name, character in pairs(self.list) do
|
||||||
|
data.list[name] = character:getData()
|
||||||
|
end
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharacterManager:setData(data)
|
function CharacterManager:setData(data)
|
||||||
local data = data
|
local data = data
|
||||||
self.list = data.list
|
|
||||||
self.team = data.team
|
self.team = data.team
|
||||||
|
self.list = {}
|
||||||
|
for name, charData in pairs(data.list) do
|
||||||
|
local character = AbstractCharacter(name)
|
||||||
|
character:setData(charData)
|
||||||
|
self.list[name] = character
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharacterManager:heal(name)
|
function CharacterManager:heal(name)
|
||||||
|
|
|
@ -72,12 +72,14 @@ function Game:setData(data)
|
||||||
self.flags = data.flags
|
self.flags = data.flags
|
||||||
self.position = data.position
|
self.position = data.position
|
||||||
self.characters:setData(data.characters)
|
self.characters:setData(data.characters)
|
||||||
|
self.loot:setData(data.loot)
|
||||||
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()
|
data.characters = self.characters:getData()
|
||||||
|
data.loot = self.loot:getData()
|
||||||
data.flags = self.flags
|
data.flags = self.flags
|
||||||
data.destroyedGizmo = self.destroyedGizmo
|
data.destroyedGizmo = self.destroyedGizmo
|
||||||
data.variables = self.variables
|
data.variables = self.variables
|
||||||
|
|
|
@ -17,14 +17,19 @@ end
|
||||||
function LootManager:getData()
|
function LootManager:getData()
|
||||||
local data = {}
|
local data = {}
|
||||||
data.rings = self.rings
|
data.rings = self.rings
|
||||||
data.inventory = self.inventory
|
data.inventory = {}
|
||||||
|
for i, pocket in ipairs(self.inventory) do
|
||||||
|
data.inventory[i] = pocket:getData()
|
||||||
|
end
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
function LootManager:setData(data)
|
function LootManager:setData(data)
|
||||||
local data = data
|
local data = data
|
||||||
self.rings = data.rings
|
self.rings = data.rings
|
||||||
self.inventory = data.inventory
|
for i, pocket in ipairs(self.inventory) do
|
||||||
|
pocket:setData(data.inventory[i])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function LootManager:generatePockets()
|
function LootManager:generatePockets()
|
||||||
|
|
|
@ -8,6 +8,14 @@ function Pocket:new(pocketdata)
|
||||||
self.list = {}
|
self.list = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Pocket:getData()
|
||||||
|
return self.list
|
||||||
|
end
|
||||||
|
|
||||||
|
function Pocket:setData(data)
|
||||||
|
self.list = data
|
||||||
|
end
|
||||||
|
|
||||||
function Pocket:addItem(item, number)
|
function Pocket:addItem(item, number)
|
||||||
local success = false
|
local success = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue