chore: add a basic abstractmob system
This commit is contained in:
parent
6c409cc1ba
commit
698d6697fb
3 changed files with 74 additions and 5 deletions
26
sonic-radiance.love/game/abstractmobs/ennemy.lua
Normal file
26
sonic-radiance.love/game/abstractmobs/ennemy.lua
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
AbstractMobParent = require "game.abstractmobs.parent"
|
||||||
|
|
||||||
|
AbstractEnnemy = AbstractMobParent:extend()
|
||||||
|
|
||||||
|
function AbstractEnnemy:new(name)
|
||||||
|
self.simplename = name
|
||||||
|
self.super.new(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractEnnemy:initBasicElements()
|
||||||
|
self.data = require("datas.gamedata.ennemies." .. self.simplename)
|
||||||
|
self.name = self.data.name
|
||||||
|
self.fullname = self.data.fullname
|
||||||
|
self.turns = self.data.turns
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractEnnemy:createStats()
|
||||||
|
return require("datas.gamedata.ennemies." .. self.simplename .. ".stats")
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractEnnemy:createSkills()
|
||||||
|
return require("datas.gamedata.ennemies." .. self.simplename .. ".skills")
|
||||||
|
end
|
||||||
|
|
||||||
|
return AbstractEnnemy
|
45
sonic-radiance.love/game/abstractmobs/parent.lua
Normal file
45
sonic-radiance.love/game/abstractmobs/parent.lua
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
local AbstractMobParent = Object:extend()
|
||||||
|
|
||||||
|
function AbstractMobParent:new()
|
||||||
|
self:initBasicElements()
|
||||||
|
self.stats = self:createStats()
|
||||||
|
self.skills = self:createSkills()
|
||||||
|
self:initLife()
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractMobParent:initBasicElements()
|
||||||
|
self.name = "PlaceHolder"
|
||||||
|
self.fullname = "PlaceHolder"
|
||||||
|
self.turns = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractMobParent:createStats()
|
||||||
|
local stats = {}
|
||||||
|
|
||||||
|
stats.hpmax = 0
|
||||||
|
stats.ppmax = 0
|
||||||
|
stats.attack = 0
|
||||||
|
stats.power = 0
|
||||||
|
stats.defense = 0
|
||||||
|
stats.technic = 0
|
||||||
|
stats.mind = 0
|
||||||
|
stats.speed = 0
|
||||||
|
|
||||||
|
return stats
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractMobParent:createSkills()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractMobParent:initLife()
|
||||||
|
self.hp = self.stats.hpmax
|
||||||
|
self.mp = self.stats.mpmax
|
||||||
|
self.status = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function AbstractMobParent:getStats()
|
||||||
|
return self.stats
|
||||||
|
end
|
||||||
|
|
||||||
|
return AbstractMobParent
|
|
@ -1,15 +1,13 @@
|
||||||
local EnnemyManager = Object:extend()
|
local EnnemyManager = Object:extend()
|
||||||
|
|
||||||
|
local AbstractEnnemy = require "game.abstractmobs.ennemy"
|
||||||
|
|
||||||
function EnnemyManager:new(controller)
|
function EnnemyManager:new(controller)
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
end
|
end
|
||||||
|
|
||||||
function EnnemyManager:getEnnemyData(ennemy)
|
function EnnemyManager:getEnnemyData(ennemy)
|
||||||
local data = require("datas.gamedata.ennemies." .. ennemy)
|
return AbstractEnnemy(ennemy)
|
||||||
data.skills = require("datas.gamedata.ennemies." .. ennemy .. ".skills")
|
|
||||||
data.stats = require("datas.gamedata.ennemies." .. ennemy .. ".stats")
|
|
||||||
|
|
||||||
return data
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return EnnemyManager
|
return EnnemyManager
|
||||||
|
|
Loading…
Reference in a new issue