This commit is contained in:
Kazhnuz 2021-06-02 08:41:25 +02:00
commit 6f642b4f33
27 changed files with 199 additions and 108 deletions

View file

@ -1,6 +0,0 @@
local CONST = {}
CONST.ACCURACY = 100
CONST.ATKWRONGTYPE = 0.66
return CONST

View file

@ -0,0 +1,10 @@
local CONST = {}
CONST.ACCURACY = 100
CONST.ATKWRONGTYPE = 0.66
CONST.DAMAGE = {}
CONST.DAMAGE.DIVISOR = 10
CONST.DAMAGE.DEFFACTOR = 0.66
return CONST

View file

@ -0,0 +1,42 @@
return {
["none"] = {
fullname = "None",
weakTo = {},
resists = {}
},
["water"] = {
fullname = "Water",
weakTo = {"light"},
resists = {"fire", "water"}
},
["fire"] = {
fullname = "Fire",
weakTo = {"water"},
resists = {"ice", "fire"}
},
["ice"] = {
fullname = "Fire",
weakTo = {"fire"},
resists = {"wind", "ice"}
},
["wind"] = {
fullname = "Fire",
weakTo = {"ice"},
resists = {"earth", "wind"}
},
["earth"] = {
fullname = "Fire",
weakTo = {"wind"},
resists = {"light", "earth"}
},
["light"] = {
fullname = "Fire",
weakTo = {"earth"},
resists = {"water", "light"}
},
["chaos"] = {
fullname = "Chaos",
weakTo = {"chaos"},
resists = {}
}
}

View file

@ -0,0 +1,22 @@
return {
["basic"] = {
resistTo = {},
backDamage = {}
},
["aerial"] = {
resistTo = {"basic"},
backDamage = {}
},
["shielded"] = {
resistTo = {"basic", "projectile"},
backDamage = {}
},
["spiked"] = {
resistTo = {"basic", "aerial"},
backDamage = {"basic", "aerial"}
},
["backspiked"] = {
resistTo = {"aerial"},
backDamage = {"aerial"}
},
}

View file

@ -13,6 +13,9 @@ return {
canGoSuper = true, canGoSuper = true,
canBreakCraft = false, canBreakCraft = false,
weakTo = {},
resists = {},
icon = 3, icon = 3,
charset = "perso", charset = "perso",
charId = 3, charId = 3,

View file

@ -1,4 +1,4 @@
local CONST = require "datas.stats" local CONST = require "datas.consts.stats"
return { return {
hpmax = CONST.RANK_A, -- hpmax = CONST.RANK_A, --

View file

@ -13,6 +13,9 @@ return {
canGoSuper = true, canGoSuper = true,
canBreakCraft = false, canBreakCraft = false,
weakTo = {"water"},
resists = {"wind"},
icon = 1, icon = 1,
charset = "perso", charset = "perso",
charId = 1, charId = 1,

View file

@ -1,4 +1,4 @@
local CONST = require "datas.stats" local CONST = require "datas.consts.stats"
return { return {
hpmax = CONST.RANK_B, -- hpmax = CONST.RANK_B, --

View file

@ -13,6 +13,9 @@ return {
canGoSuper = true, canGoSuper = true,
canBreakCraft = false, canBreakCraft = false,
weakTo = {"light"},
resists = {"earth"},
icon = 2, icon = 2,
charset = "perso", charset = "perso",
charId = 2, charId = 2,

View file

@ -1,4 +1,4 @@
local CONST = require "datas.stats" local CONST = require "datas.consts.stats"
return { return {
hpmax = CONST.RANK_C, -- hpmax = CONST.RANK_C, --

View file

@ -7,4 +7,12 @@ function CharacterData:getCommonData()
self.turns = self.data.turns self.turns = self.data.turns
end end
function CharacterData:getWeaknesses()
return self.data.weakTo
end
function CharacterData:getResistences()
return self.data.resists
end
return CharacterData return CharacterData

View file

@ -1,7 +1,7 @@
local CharacterLevel = Object:extend() local CharacterLevel = Object:extend()
local charutils = require "game.utils.characters" local charutils = require "game.utils.characters"
local STATS = require "datas.stats" local STATS = require "datas.consts.stats"
function CharacterLevel:initLevel() function CharacterLevel:initLevel()
self.level = self.data.startlevel self.level = self.data.startlevel

View file

@ -1,6 +1,7 @@
local AbstractMobParent = require "game.abstractmobs.parent" local AbstractMobParent = require "game.abstractmobs.parent"
local AbstractEnnemy = AbstractMobParent:extend() local AbstractEnnemy = AbstractMobParent:extend()
local elements = require "datas.gamedata.battles.elements"
function AbstractEnnemy:new(directory, name) function AbstractEnnemy:new(directory, name)
self.simplename = name self.simplename = name
@ -8,6 +9,16 @@ function AbstractEnnemy:new(directory, name)
self.super.new(self) self.super.new(self)
end end
function AbstractEnnemy:getWeaknesses()
local elementData = elements[self.data.element] or elements["none"]
return elementData.weakTo
end
function AbstractEnnemy:getResistences()
local elementData = elements[self.data.element] or elements["none"]
return elementData.resists
end
function AbstractEnnemy:haveProtecType(protectype) function AbstractEnnemy:haveProtecType(protectype)
return utils.table.contain(self.data.protectypes, protectype) return utils.table.contain(self.data.protectypes, protectype)
end end

View file

@ -28,7 +28,6 @@ local Serializer = require "birb.classes.serializable.serializer"
local Game = Serializer:extend() local Game = Serializer:extend()
local Characters = require "game.characters" local Characters = require "game.characters"
local Ennemies = require "game.ennemies" local Ennemies = require "game.ennemies"
local Skills = require "game.skills"
local Loot = require "game.loot" local Loot = require "game.loot"
local CBSCore = require "game.battle" local CBSCore = require "game.battle"
local Difficulty = require "game.difficulty" local Difficulty = require "game.difficulty"
@ -92,7 +91,6 @@ function Game:reset()
self.characters = Characters(self) self.characters = Characters(self)
self.ennemies = Ennemies(self) self.ennemies = Ennemies(self)
self.skills = Skills(self)
self.loot = Loot(self) self.loot = Loot(self)
self.cbs = CBSCore(self) self.cbs = CBSCore(self)
self.difficulty = Difficulty(self) self.difficulty = Difficulty(self)

View file

@ -1,47 +0,0 @@
local SkillManager = Object:extend()
function SkillManager:new(controller)
self.controller = controller
end
function SkillManager:getSkillData(skillname)
if core.datas:exists("skills", skillname) then
return core.datas:get("skills", skillname)
end
end
function SkillManager:skillDataExists(skillname)
return core.datas:exists("skills", skillname)
end
function SkillManager:getEnnemySkillData(skillname)
if core.datas:exists("badskills", skillname) then
return core.datas:get("badskills", skillname)
end
end
function SkillManager:ennemySkillDataExists(skillname)
return core.datas:exists("badskills", skillname)
end
function SkillManager:getActionArguments(choregraphyAction)
local choregraphyData = require "datas.gamedata.skills"
local args = {}
args.name = choregraphyAction[1]
args.condition = choregraphyAction[2]
local actionData = choregraphyData.actions[args.name]
if actionData ~= nil then
args.type = actionData[1]
local argumentList = actionData[2]
for i, argData in ipairs(choregraphyAction) do
if i > 2 then
local argName = argumentList[i-2] or ""
args[argName] = argData
end
end
end
return args
end
return SkillManager

View file

@ -1,3 +1,63 @@
local BattleUtils = {} local BattleUtils = {}
local CONSTS = require "datas.consts.battle"
local protectypes = require "datas.gamedata.battles.protectypes"
function BattleUtils.computeLaunchingDamages(base, stats, isSpecial)
local damages = base / CONSTS.DAMAGE.DIVISOR
if (isSpecial) then
damages = damages * stats.power
else
damages = damages * stats.attack
end
return damages
end
function BattleUtils.computeReceivingDamages(base, stats, isSpecial, isDefending)
local damages = base
if (isSpecial) then
damages = damages / stats.mind
else
damages = damages / stats.defense
end
if (isDefending) then
damages = damages * CONSTS.DAMAGE.DEFFACTOR
end
return damages
end
function BattleUtils.applyProtectTypes(value, type, protectypeList)
for _, protectype in ipairs(protectypeList) do
local protecttypeData = protectypes[protectype]
if protecttypeData ~= nil then
if (utils.table.contain(protecttypeData.resistTo, type)) then
value = value * CONSTS.ATKWRONGTYPE
end
else
core.debug:warning("battleutils", "protectype " .. protectype .. " doesn't exists ")
end
end
return value
end
function BattleUtils.applyWeaknesses(damages, element, weaknessList)
if (utils.table.contain(weaknessList, element)) then
damages = damages * 1.2
end
return damages
end
function BattleUtils.applyResistences(damages, element, resistsList)
if (utils.table.contain(resistsList, element)) then
damages = damages * 0.8
end
return damages
end
function BattleUtils.isAttackSuccess(statutList)
local accuracy = 100
return (math.random(100) <= accuracy)
end
return BattleUtils return BattleUtils

View file

@ -1,6 +1,6 @@
local CharUtils = {} local CharUtils = {}
local CONST = require "datas.stats" local CONST = require "datas.consts.stats"
function CharUtils.getExpValue(level) function CharUtils.getExpValue(level)
return math.floor( ( CONST.EXP_MULTIPLICATOR * ( level ^ 3 ) ) / CONST.EXP_RATIO ) return math.floor( ( CONST.EXP_MULTIPLICATOR * ( level ^ 3 ) ) / CONST.EXP_RATIO )

View file

@ -1,6 +1,6 @@
local FighterParent = Object:extend() local FighterParent = Object:extend()
local CONST = require "datas.cbs" local battleutils = require "game.utils.battle"
function FighterParent:new(owner, isHero, id) function FighterParent:new(owner, isHero, id)
self.owner = owner self.owner = owner
@ -75,50 +75,34 @@ function FighterParent:haveProtecType(type)
end end
function FighterParent:sendDamage(target, value, type, element, isSpecial) function FighterParent:sendDamage(target, value, type, element, isSpecial)
local stats = self:getStats() local damage = battleutils.computeLaunchingDamages(value, self:getStats(), isSpecial)
local value = value / 10
if (isSpecial) then core.debug:print("cbs/battler", "Sending " .. damage .." damage at " .. target.name)
value = value * stats.power return target:receiveDamage(damage, type, element, isSpecial, self)
else
value = value * stats.attack
end
core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name)
return target:receiveDamage(value, type, element, isSpecial, self)
end end
function FighterParent:receiveDamage(value, type, element, isSpecial, fromWho) function FighterParent:receiveDamage(value, type, element, isSpecial, fromWho)
local accuracy = 100 local damages = battleutils.computeReceivingDamages(value, self:getStats(), isSpecial, self.isDefending)
local stats = self:getStats() damages = battleutils.applyProtectTypes(damages, type, self.abstract:getProtecTypes())
local isSuccess = true damages = battleutils.applyResistences(damages, element, self.abstract:getResistences())
damages = battleutils.applyWeaknesses(damages, element, self.abstract:getWeaknesses())
if (isSpecial) then if (battleutils.isAttackSuccess(nil)) then
value = value / stats.mind self:applyDamage(damages)
else
value = value / stats.defense
end
if (self:haveProtecType("aerial") and type == "basic") then
value = value * CONST.ATKWRONGTYPE
end
isSuccess = (math.random(100) <= accuracy)
if (isSuccess) then
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
if (self.isDefending) then
self:setHP(value * -0.66, true)
else
self:setHP(value * -1, true)
self.actor:getHurt()
end
else else
self.actor:avoidedAttack() self.actor:avoidedAttack()
return false
end end
return isSuccess return true
end
function FighterParent:applyDamage(damage)
core.debug:print("cbs/fighter", "Taken " .. damage .. " damage" )
self:setHP(damage * -1, true)
if (not self.isDefending) then
self.actor:getHurt()
end
end end
function FighterParent:getAbstract() function FighterParent:getAbstract()

View file

@ -17,7 +17,7 @@ function ActionParent:update(dt)
end end
function ActionParent:loadChoregraphy(skillname) function ActionParent:loadChoregraphy(skillname)
local skill = game.skills:getSkillData(skillname) local skill = core.datas:get("skills", skillname)
self.choregraphy = ChoregraphySystem(self, skill.choregraphy) self.choregraphy = ChoregraphySystem(self, skill.choregraphy)
end end

View file

@ -2,7 +2,7 @@ local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.a
local SkillAction = ActionParent:extend() local SkillAction = ActionParent:extend()
function SkillAction:new(fighter, skill) function SkillAction:new(fighter, skill)
self.data = game.skills:getSkillData(skill) self.data = core.datas:get("skills", skill)
SkillAction.super.new(self, fighter) SkillAction.super.new(self, fighter)
end end

View file

@ -2,7 +2,7 @@ local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.a
local EnnemyAction = ActionParent:extend() local EnnemyAction = ActionParent:extend()
function EnnemyAction:new(fighter, skill) function EnnemyAction:new(fighter, skill)
self.data = game.skills:getEnnemySkillData(skill) self.data = core.datas:get("badskills", skill)
EnnemyAction.super.new(self, fighter) EnnemyAction.super.new(self, fighter)
end end

View file

@ -96,7 +96,7 @@ function widgets.SkillWidget:new(character, menu_name, skill)
self.skillname = skill self.skillname = skill
local label2 = "00" local label2 = "00"
self.skilldata = game.skills:getSkillData(skill) self.skilldata = core.datas:get("skills", skill)
if self.skilldata ~= nil then if self.skilldata ~= nil then
label2 = self.skilldata.cost or 0 label2 = self.skilldata.cost or 0

View file

@ -35,7 +35,7 @@ function ChoregraphyViewer:buildCharacterMenu()
self:addSubMenu("characters", "MainMenu", "Rivals") self:addSubMenu("characters", "MainMenu", "Rivals")
for k, character in pairs(game.characters.list) do for k, character in pairs(game.characters.list) do
self:addSubMenu(k, "characters", character.fullname) self:addSubMenu(k, "characters", character.fullname)
menu.HeroChoregraphyWidget(self, k, game.skills:getSkillData("attack")) menu.HeroChoregraphyWidget(self, k, core.datas:get("skills", "attack"))
self:buildSkillMenu(k) self:buildSkillMenu(k)
end end
end end
@ -51,8 +51,8 @@ function ChoregraphyViewer:buildEnnemySkillMenu(category, ennemy)
self:addSubMenu(ennemy, category, ennemy) self:addSubMenu(ennemy, category, ennemy)
local data = core.datas:get("ennemies", ennemy) local data = core.datas:get("ennemies", ennemy)
for j,skillName in ipairs(data.skills) do for j,skillName in ipairs(data.skills) do
if (game.skills:ennemySkillDataExists(skillName)) then if (core.datas:exists("badskills", skillName)) then
menu.EnnemyChoregraphyWidget(self, category, ennemy, game.skills:getEnnemySkillData(skillName)) menu.EnnemyChoregraphyWidget(self, category, ennemy, core.datas:get("badskills", skillName))
end end
end end
end end
@ -64,8 +64,8 @@ function ChoregraphyViewer:buildSkillMenu(charName)
local skillName = skill[1] local skillName = skill[1]
if (skillTreated[skillName] ~= true) then if (skillTreated[skillName] ~= true) then
skillTreated[skillName] = true skillTreated[skillName] = true
if (game.skills:skillDataExists(skillName)) then if (core.datas:exists("skills", skillName)) then
menu.HeroChoregraphyWidget(self, charName, game.skills:getSkillData(skillName)) menu.HeroChoregraphyWidget(self, charName, core.datas:get("skills", skillName))
end end
end end
end end

View file

@ -60,7 +60,7 @@ end
function SkillWidget:new(page, skill) function SkillWidget:new(page, skill)
self.page = page self.page = page
self.skillData = game.skills:getSkillData(skill) self.skillData = core.datas:get("skills", skill)
SkillWidget.super.new(self, self.page.view.scene, "equip", self.skillData.fullname, utils.math.numberToString(self.skillData.cost, 2)) SkillWidget.super.new(self, self.page.view.scene, "equip", self.skillData.fullname, utils.math.numberToString(self.skillData.cost, 2))
end end

View file

@ -8,7 +8,7 @@ local const = require "scenes.overworld.screens.mainmenu.const"
local EquipMenu = menu.ListMenu:extend() local EquipMenu = menu.ListMenu:extend()
local EquipWidget = menu.DualTextWidget:extend() local EquipWidget = menu.DualTextWidget:extend()
local STATS = require "datas.stats" local STATS = require "datas.consts.stats"
function StatPage:new(view, character) function StatPage:new(view, character)
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40 + 32) self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40 + 32)

View file

@ -10,7 +10,7 @@ local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.ch
local CharacterMenu = baseCharacterMenu:extend() local CharacterMenu = baseCharacterMenu:extend()
local CharacterWidget = baseCharacterWidget:extend() local CharacterWidget = baseCharacterWidget:extend()
local STATS = require "datas.stats" local STATS = require "datas.consts.stats"
local DESC_SIZE = 32 * 6 local DESC_SIZE = 32 * 6