parent
1935659378
commit
58264e2a19
14 changed files with 256 additions and 29 deletions
|
@ -0,0 +1,12 @@
|
|||
return {
|
||||
music = "battle1",
|
||||
ennemies = {
|
||||
{"normal", "classics", "motobug", 2},
|
||||
{"normal", "classics", "motobug", 1}}
|
||||
}
|
||||
|
||||
-- There are three possible type of ennemies
|
||||
|
||||
-- NORMAL {"normal", category, name, number}
|
||||
-- BOSS : {"boss", category, pvbonus, statbonus}
|
||||
-- RIVALS : {"rival", charname, level, pvbonus}
|
13
sonic-radiance.love/datas/gamedata/battles/test/testBoss.lua
Normal file
13
sonic-radiance.love/datas/gamedata/battles/test/testBoss.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
return {
|
||||
music = "battle1",
|
||||
ennemies = {
|
||||
{"normal", "classics", "motobug", 1},
|
||||
{"boss", "classics", "motobug", 2, 1.2, true},
|
||||
{"normal", "classics", "motobug", 1}}
|
||||
}
|
||||
|
||||
-- There are three possible type of ennemies
|
||||
|
||||
-- NORMAL {"normal", category, name, number}
|
||||
-- BOSS : {"boss", category, pvbonus, statbonus}
|
||||
-- RIVALS : {"rival", charname, level, pvbonus}
|
|
@ -2,29 +2,27 @@ AbstractMobParent = require "game.abstractmobs.parent"
|
|||
|
||||
AbstractEnnemy = AbstractMobParent:extend()
|
||||
|
||||
local ennutils = require "game.utils.ennemies"
|
||||
|
||||
function AbstractEnnemy:new(directory, name)
|
||||
self.simplename = name
|
||||
self.directory = directory
|
||||
self.super.new(self)
|
||||
end
|
||||
|
||||
function AbstractEnnemy:getDirectory()
|
||||
return "datas.gamedata.ennemies." .. self.directory .. "."
|
||||
end
|
||||
|
||||
function AbstractEnnemy:initBasicElements()
|
||||
self.data = require(self:getDirectory() .. self.simplename)
|
||||
self.data = ennutils.getData(self.directory, self.simplename)
|
||||
self.name = self.data.name
|
||||
self.fullname = self.data.fullname
|
||||
self.turns = self.data.turns
|
||||
end
|
||||
|
||||
function AbstractEnnemy:createStats()
|
||||
return require(self:getDirectory() .. self.simplename .. ".stats")
|
||||
return self.data.stats
|
||||
end
|
||||
|
||||
function AbstractEnnemy:createSkills()
|
||||
return require(self:getDirectory() .. self.simplename .. ".skills")
|
||||
return self.data.skills
|
||||
end
|
||||
|
||||
return AbstractEnnemy
|
||||
|
|
|
@ -65,4 +65,18 @@ function AbstractMobParent:getStats()
|
|||
return self.stats
|
||||
end
|
||||
|
||||
-- Bonus stuff
|
||||
|
||||
function AbstractMobParent:setBonus(pvFactor, statFactor)
|
||||
self.stats.hpmax = self.stats.hpmax * pvFactor
|
||||
self.hp = self.stats.hpmax
|
||||
|
||||
self.stats.attack = self.stats.attack * statFactor
|
||||
self.stats.power = self.stats.power * statFactor
|
||||
self.stats.defense = self.stats.defense * statFactor
|
||||
self.stats.mind = self.stats.mind * statFactor
|
||||
self.stats.technic = self.stats.technic * statFactor
|
||||
self.stats.speed = self.stats.speed * statFactor
|
||||
end
|
||||
|
||||
return AbstractMobParent
|
||||
|
|
|
@ -6,8 +6,8 @@ function EnnemyManager:new(controller)
|
|||
self.controller = controller
|
||||
end
|
||||
|
||||
function EnnemyManager:getEnnemyData(ennemy)
|
||||
return AbstractEnnemy("classics", ennemy)
|
||||
function EnnemyManager:getEnnemyData(category, ennemy)
|
||||
return AbstractEnnemy(category, ennemy)
|
||||
end
|
||||
|
||||
return EnnemyManager
|
||||
|
|
5
sonic-radiance.love/game/utils/battle/arguments.lua
Normal file
5
sonic-radiance.love/game/utils/battle/arguments.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
["normal"] = {"category", "name", "number"},
|
||||
["boss"] = {"category", "name", "pvFactor", "statFactor", "cheapEffect"},
|
||||
["rival"] = {"character", "level", "pvFactor"}
|
||||
}
|
74
sonic-radiance.love/game/utils/battle/init.lua
Normal file
74
sonic-radiance.love/game/utils/battle/init.lua
Normal file
|
@ -0,0 +1,74 @@
|
|||
BattleUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local DIR = "battles"
|
||||
|
||||
function BattleUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function BattleUtils.listCategories()
|
||||
return love.filesystem.getDirectoryItems(BattleUtils.getBaseDirectory(false))
|
||||
end
|
||||
|
||||
function BattleUtils.getCategoryDirectory(directory, lua)
|
||||
local baseDir = BattleUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatFolder(baseDir, directory, lua)
|
||||
end
|
||||
|
||||
function BattleUtils.getDirectoryLuaStyle(directory)
|
||||
return REQUIREDIR .. "." .. directory
|
||||
end
|
||||
|
||||
function BattleUtils.getBattleFromCategory(directory)
|
||||
local folder = BattleUtils.getCategoryDirectory(directory, false)
|
||||
return datasutils.luaFileListToModuleList(love.filesystem.getDirectoryItems(folder))
|
||||
end
|
||||
|
||||
function BattleUtils.getBattleData(directory, battlename)
|
||||
local categoryDir = BattleUtils.getCategoryDirectory(directory, true)
|
||||
return datasutils.require(categoryDir, battlename)
|
||||
end
|
||||
|
||||
-- ENNEMY FUNCTIONS
|
||||
|
||||
function BattleUtils.getEnnemyTypeStructure(type)
|
||||
local typeList = require "game.utils.battle.arguments"
|
||||
return typeList[type]
|
||||
end
|
||||
|
||||
function BattleUtils.ennemyTypeExists(type)
|
||||
return (BattleUtils.getEnnemyTypeStructure(type) ~= nil)
|
||||
end
|
||||
|
||||
function BattleUtils.validateEnnemyType(ennemyBaseData)
|
||||
local structure = BattleUtils.getEnnemyTypeStructure(ennemyBaseData[1])
|
||||
if (structure == nil) then
|
||||
return false
|
||||
else
|
||||
return ((#structure + 1) == #ennemyBaseData)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUtils.getEnnemyData(ennemyBaseData)
|
||||
local ennemyData = {}
|
||||
ennemyData.type = ennemyBaseData[1]
|
||||
|
||||
if (BattleUtils.validateEnnemyType(ennemyBaseData)) then
|
||||
local structure = BattleUtils.getEnnemyTypeStructure(ennemyData.type)
|
||||
|
||||
for i, argumentName in ipairs(structure) do
|
||||
local argumentContent = ennemyBaseData[i + 1]
|
||||
ennemyData[argumentName] = argumentContent
|
||||
end
|
||||
|
||||
return ennemyData
|
||||
else
|
||||
error("Le type d'ennemy " .. ennemyData.type .. " à un nbr d'argument incorrect")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
return BattleUtils
|
45
sonic-radiance.love/game/utils/ennemies.lua
Normal file
45
sonic-radiance.love/game/utils/ennemies.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
local EnnemyUtils = {}
|
||||
|
||||
local datasutils = require "game.utils.datas"
|
||||
|
||||
local DIR = "ennemies"
|
||||
|
||||
function EnnemyUtils.getBaseDirectory(lua)
|
||||
return datasutils.concatDataFolder(DIR, lua)
|
||||
end
|
||||
|
||||
function EnnemyUtils.listCategories()
|
||||
return require(EnnemyUtils.getBaseDirectory(true))
|
||||
end
|
||||
|
||||
function EnnemyUtils.getCategoryDirectory(directory, lua)
|
||||
return datasutils.concatFolder(EnnemyUtils.getBaseDirectory(lua), directory, lua)
|
||||
end
|
||||
|
||||
function EnnemyUtils.getEnnemyFolder(directory, ennemy, lua)
|
||||
local categoryDirectory = EnnemyUtils.getCategoryDirectory(directory, lua)
|
||||
return datasutils.concatFolder(categoryDirectory, ennemy, lua)
|
||||
end
|
||||
|
||||
function EnnemyUtils.getEnnemiesFromCategory(directory)
|
||||
local folder = EnnemyUtils.getCategoryDirectory(directory, false)
|
||||
return love.filesystem.getDirectoryItems(folder)
|
||||
end
|
||||
|
||||
function EnnemyUtils.dataExists(directory, name)
|
||||
local dir = datasutils.concatFolder(EnnemyUtils.getEnnemyFolder(directory, name, false), "init.lua", false)
|
||||
local fileinfo = love.filesystem.getInfo(dir)
|
||||
return (fileinfo ~= nil)
|
||||
end
|
||||
|
||||
function EnnemyUtils.getData(directory, name)
|
||||
-- va eprmettre de récupérer les données d'un personnage
|
||||
local folder = EnnemyUtils.getEnnemyFolder(directory, name, true)
|
||||
local ennemy = require(folder)
|
||||
ennemy.stats = datasutils.require(folder, "stats")
|
||||
ennemy.skills = datasutils.require(folder, "skills")
|
||||
|
||||
return ennemy
|
||||
end
|
||||
|
||||
return EnnemyUtils
|
|
@ -3,19 +3,38 @@ local EnnemyController = FighterControllerParent:extend()
|
|||
|
||||
local Villain = require "scenes.battlesystem.controllers.fighters.villain"
|
||||
|
||||
function EnnemyController:new(owner)
|
||||
local battleutils = require "game.utils.battle"
|
||||
|
||||
function EnnemyController:new(owner, battleData)
|
||||
self.super.new(self, owner)
|
||||
self:initVillains()
|
||||
self:initVillains(battleData)
|
||||
end
|
||||
|
||||
function EnnemyController:initVillains()
|
||||
self:addVillain("motobug")
|
||||
self:addVillain("motobug")
|
||||
self:addVillain("motobug")
|
||||
function EnnemyController:initVillains(battleData)
|
||||
for i,ennemyBaseData in ipairs(battleData.ennemies) do
|
||||
local ennData = battleutils.getEnnemyData(ennemyBaseData)
|
||||
if (ennData.type == "normal") then
|
||||
self:addVillain(ennData)
|
||||
elseif (ennData.type == "boss") then
|
||||
self:addBoss(ennData)
|
||||
else
|
||||
print("unknown type " .. ennData.type)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function EnnemyController:addVillain(name)
|
||||
self:add(Villain(self, name, self:count() + 1))
|
||||
function EnnemyController:addVillain(ennData)
|
||||
for i=1, ennData.number do
|
||||
self:add(Villain(self, ennData.category, ennData.name, self:count() + 1))
|
||||
end
|
||||
end
|
||||
|
||||
function EnnemyController:addBoss(ennData)
|
||||
local boss = Villain(self, ennData.category, ennData.name, self:count() + 1)
|
||||
boss:setBonus(ennData.pvFactor, ennData.statFactor)
|
||||
boss.isBoss = true
|
||||
boss.cheapEffect = ennData.cheapEffect
|
||||
self:add(boss)
|
||||
end
|
||||
|
||||
return EnnemyController
|
||||
|
|
|
@ -6,11 +6,13 @@ local SimpleHPBar = require "game.modules.gui.simplehpbar"
|
|||
local POSITIONS = {1, 3, 5}
|
||||
local ENNEMY_LINE = 11;
|
||||
|
||||
function VillainFighter:new(owner, ennemy, id)
|
||||
function VillainFighter:new(owner, category, ennemy, id)
|
||||
self.name = ennemy
|
||||
self.category = category
|
||||
self.super.new(self, owner, false, id)
|
||||
|
||||
self.hpbar = SimpleHPBar(self.abstract.hp)
|
||||
self.isBoss = false
|
||||
end
|
||||
|
||||
function VillainFighter:updateAssets(dt)
|
||||
|
@ -19,7 +21,7 @@ end
|
|||
|
||||
|
||||
function VillainFighter:getAbstract()
|
||||
return game.ennemies:getEnnemyData(self.name)
|
||||
return game.ennemies:getEnnemyData(self.category, self.name)
|
||||
end
|
||||
|
||||
function VillainFighter:createActor()
|
||||
|
@ -40,6 +42,10 @@ function FighterParent:die()
|
|||
self.actor:destroy()
|
||||
end
|
||||
|
||||
function VillainFighter:setBonus(pvFactor, statFactor)
|
||||
self.abstract:setBonus(pvFactor, statFactor)
|
||||
end
|
||||
|
||||
-- LIFE FUNCTIONS
|
||||
function VillainFighter:setHP(value, relative)
|
||||
VillainFighter.super.setHP(self, value, relative)
|
||||
|
@ -54,7 +60,9 @@ function VillainFighter:drawIcon(x, y)
|
|||
end
|
||||
|
||||
function VillainFighter:drawHUD(x, y)
|
||||
if (not self.isBoss) then
|
||||
self.hpbar:draw(x, y)
|
||||
end
|
||||
end
|
||||
|
||||
return VillainFighter
|
||||
|
|
|
@ -7,7 +7,7 @@ local HUD = require "scenes.battlesystem.gui.hud"
|
|||
|
||||
local maputils = require "scenes.battlesystem.utils"
|
||||
|
||||
function TurnController:new(scene)
|
||||
function TurnController:new(scene, battleData)
|
||||
self.scene = scene
|
||||
self.world = scene.world
|
||||
|
||||
|
@ -27,7 +27,7 @@ function TurnController:new(scene)
|
|||
self.hud = HUD(self)
|
||||
|
||||
self.player = Player(self)
|
||||
self.ennemies = Ennemy(self)
|
||||
self.ennemies = Ennemy(self, battleData)
|
||||
end
|
||||
|
||||
function TurnController:startBattle()
|
||||
|
|
|
@ -8,15 +8,14 @@ local Turns = require "scenes.battlesystem.controllers"
|
|||
|
||||
local VictoryScreen = require "scenes.battlesystem.screens.victory"
|
||||
|
||||
function BattleSystem:new()
|
||||
function BattleSystem:new(battleData)
|
||||
BattleSystem.super.new(self)
|
||||
|
||||
self.assets:batchImport("scenes.battlesystem.assets")
|
||||
|
||||
self.assets:setMusic("assets/music/battle1.mp3")
|
||||
self.assets:playMusic()
|
||||
self:playMusic(battleData.music)
|
||||
|
||||
self:initManagers()
|
||||
self:initManagers(battleData)
|
||||
|
||||
self:register()
|
||||
|
||||
|
@ -25,11 +24,16 @@ function BattleSystem:new()
|
|||
self.screen = nil
|
||||
end
|
||||
|
||||
function BattleSystem:initManagers()
|
||||
function BattleSystem:playMusic(music)
|
||||
self.assets:setMusic("assets/music/" .. music .. ".mp3")
|
||||
self.assets:playMusic()
|
||||
end
|
||||
|
||||
function BattleSystem:initManagers(battleData)
|
||||
self.datas = {}
|
||||
self.world = World(self)
|
||||
self.menu = MenuSystem(self)
|
||||
self.turns = Turns(self)
|
||||
self.turns = Turns(self, battleData)
|
||||
end
|
||||
|
||||
function BattleSystem:startBattle()
|
||||
|
|
|
@ -3,6 +3,7 @@ local menu = require "scenes.debug.menu.menu"
|
|||
|
||||
local DebugMenu = Scene:extend()
|
||||
local panels = require "scenes.debug.menu.infopanel"
|
||||
local battleutils = require "game.utils.battle"
|
||||
|
||||
function DebugMenu:new()
|
||||
DebugMenu.super.new(self)
|
||||
|
@ -30,11 +31,30 @@ end
|
|||
|
||||
function DebugMenu:buildBattleMenu()
|
||||
self:addSubMenu("combat", "BaseMenu", "Battle System")
|
||||
menu.commons.SceneWidget(self, "combat", scenes.cbs, "Launch Battle")
|
||||
self:addSubMenu("launchBattle", "combat", "Launch Battle")
|
||||
|
||||
local listCat = battleutils.listCategories()
|
||||
for i,battleCat in ipairs(listCat) do
|
||||
self:addBattles(battleCat)
|
||||
end
|
||||
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.battleBack, "Background Viewer")
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.choregraphy, "Ennemies' Action Viewer")
|
||||
|
||||
menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back")
|
||||
menu.commons.SubMenuWidget(self, "launchBattle", "combat", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:addBattles(battleCat)
|
||||
local menuName = "b_" .. battleCat
|
||||
self:addSubMenu(menuName, "launchBattle", battleCat)
|
||||
|
||||
for i,battleName in ipairs(battleutils.getBattleFromCategory(battleCat)) do
|
||||
local data = battleutils.getBattleData(battleCat, battleName)
|
||||
menu.commons.SceneWidget(self, menuName, scenes.cbs, "Launch " .. battleName, data)
|
||||
end
|
||||
|
||||
menu.commons.SubMenuWidget(self, menuName, "launchBattle", "Back")
|
||||
end
|
||||
|
||||
function DebugMenu:buildSaveMenu()
|
||||
|
|
|
@ -6,6 +6,7 @@ local ChoregraphyViewer = Scene:extend()
|
|||
local World = require "scenes.battlesystem.world"
|
||||
local Fighter = require "scenes.debug.viewers.choregraphy.mocks.fighter"
|
||||
|
||||
local ennutils = require "game.utils.ennemies"
|
||||
|
||||
function ChoregraphyViewer:new()
|
||||
ChoregraphyViewer.super.new(self)
|
||||
|
@ -28,6 +29,10 @@ function ChoregraphyViewer:buildMenu()
|
|||
end
|
||||
|
||||
function ChoregraphyViewer:buildCharacterMenu()
|
||||
for i,category in ipairs(ennutils.listCategories()) do
|
||||
self:buildEnnemyListMenu(category)
|
||||
end
|
||||
|
||||
self:addSubMenu("characters", "MainMenu", "Rivals")
|
||||
for k, character in pairs(game.characters.list) do
|
||||
self:addSubMenu(k, "characters", character.fullname)
|
||||
|
@ -38,6 +43,16 @@ function ChoregraphyViewer:buildCharacterMenu()
|
|||
menu.commons.SubMenuWidget(self, "characters", "MainMenu", "Back")
|
||||
end
|
||||
|
||||
function ChoregraphyViewer:buildEnnemyListMenu(category)
|
||||
self:addSubMenu(category, "MainMenu", category)
|
||||
for i,ennemy in ipairs(ennutils.getEnnemiesFromCategory(category)) do
|
||||
self:addSubMenu(ennemy, category, ennemy)
|
||||
|
||||
menu.commons.SubMenuWidget(self, ennemy, category, "Back")
|
||||
end
|
||||
menu.commons.SubMenuWidget(self, category, "MainMenu", "Back")
|
||||
end
|
||||
|
||||
function ChoregraphyViewer:buildSkillMenu(charName)
|
||||
local skillList = require("datas.gamedata.characters." .. charName .. ".skills")
|
||||
local skillTreated = {}
|
||||
|
|
Loading…
Reference in a new issue