2020-07-19 15:07:35 +02:00
|
|
|
local FighterControllerParent = require "scenes.battlesystem.controllers.parent"
|
|
|
|
local EnnemyController = FighterControllerParent:extend()
|
|
|
|
|
|
|
|
local Villain = require "scenes.battlesystem.controllers.fighters.villain"
|
2021-07-03 11:17:57 +02:00
|
|
|
local STATS = require "datas.consts.stats"
|
2020-07-19 15:07:35 +02:00
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function EnnemyController:new(owner, battleData)
|
2020-07-19 15:07:35 +02:00
|
|
|
self.super.new(self, owner)
|
2020-08-04 17:50:03 +02:00
|
|
|
self:initVillains(battleData)
|
|
|
|
end
|
|
|
|
|
|
|
|
function EnnemyController:initVillains(battleData)
|
|
|
|
for i,ennemyBaseData in ipairs(battleData.ennemies) do
|
2021-05-15 22:48:25 +02:00
|
|
|
local ennData = core.datas:parse("ennemytype", ennemyBaseData)
|
2020-08-04 17:50:03 +02:00
|
|
|
if (ennData.type == "normal") then
|
|
|
|
self:addVillain(ennData)
|
|
|
|
elseif (ennData.type == "boss") then
|
|
|
|
self:addBoss(ennData)
|
|
|
|
else
|
2021-04-11 15:18:47 +02:00
|
|
|
core.debug:warning("unknown type " .. ennData.type)
|
2020-08-04 17:50:03 +02:00
|
|
|
end
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function EnnemyController:addVillain(ennData)
|
|
|
|
for i=1, ennData.number do
|
|
|
|
self:add(Villain(self, ennData.category, ennData.name, self:count() + 1))
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2021-03-13 18:00:39 +01:00
|
|
|
function EnnemyController:getHighestSpeed()
|
|
|
|
local highestSpeed = 0
|
|
|
|
for i, villain in ipairs(self.list) do
|
2021-07-03 11:17:57 +02:00
|
|
|
local currentSpeed = villain:getStat(STATS.SPEED)
|
2021-07-03 09:51:19 +02:00
|
|
|
if (currentSpeed > highestSpeed) then
|
|
|
|
highestSpeed = currentSpeed
|
2021-03-13 18:00:39 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return highestSpeed
|
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function EnnemyController:addBoss(ennData)
|
|
|
|
local boss = Villain(self, ennData.category, ennData.name, self:count() + 1)
|
|
|
|
boss:setBonus(ennData.pvFactor, ennData.statFactor)
|
|
|
|
boss.isBoss = true
|
2020-08-07 13:15:04 +02:00
|
|
|
boss:setCheapEffect(ennData.cheapEffect)
|
2021-03-14 10:15:16 +01:00
|
|
|
self.turnSystem.canFleeBattle = false
|
2020-08-04 17:50:03 +02:00
|
|
|
self:add(boss)
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2021-03-11 23:47:32 +01:00
|
|
|
function EnnemyController:draw()
|
|
|
|
for i, villain in ipairs(self.list) do
|
|
|
|
villain:drawHUD()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
return EnnemyController
|