chore: add a basic abstractmob system

This commit is contained in:
Kazhnuz 2020-07-19 13:13:54 +02:00
parent 6c409cc1ba
commit 698d6697fb
3 changed files with 74 additions and 5 deletions

View 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

View 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

View file

@ -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