Merge branch 'master' of https://git.kobold.cafe/sonic/sonic-radiance
This commit is contained in:
commit
6f642b4f33
27 changed files with 199 additions and 108 deletions
|
@ -1,6 +0,0 @@
|
|||
local CONST = {}
|
||||
|
||||
CONST.ACCURACY = 100
|
||||
CONST.ATKWRONGTYPE = 0.66
|
||||
|
||||
return CONST
|
10
sonic-radiance.love/datas/consts/battle.lua
Normal file
10
sonic-radiance.love/datas/consts/battle.lua
Normal 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
|
42
sonic-radiance.love/datas/gamedata/battles/elements.lua
Normal file
42
sonic-radiance.love/datas/gamedata/battles/elements.lua
Normal 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 = {}
|
||||
}
|
||||
}
|
22
sonic-radiance.love/datas/gamedata/battles/protectypes.lua
Normal file
22
sonic-radiance.love/datas/gamedata/battles/protectypes.lua
Normal 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"}
|
||||
},
|
||||
}
|
|
@ -13,6 +13,9 @@ return {
|
|||
canGoSuper = true,
|
||||
canBreakCraft = false,
|
||||
|
||||
weakTo = {},
|
||||
resists = {},
|
||||
|
||||
icon = 3,
|
||||
charset = "perso",
|
||||
charId = 3,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local CONST = require "datas.stats"
|
||||
local CONST = require "datas.consts.stats"
|
||||
|
||||
return {
|
||||
hpmax = CONST.RANK_A, --
|
||||
|
|
|
@ -13,6 +13,9 @@ return {
|
|||
canGoSuper = true,
|
||||
canBreakCraft = false,
|
||||
|
||||
weakTo = {"water"},
|
||||
resists = {"wind"},
|
||||
|
||||
icon = 1,
|
||||
charset = "perso",
|
||||
charId = 1,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local CONST = require "datas.stats"
|
||||
local CONST = require "datas.consts.stats"
|
||||
|
||||
return {
|
||||
hpmax = CONST.RANK_B, --
|
||||
|
|
|
@ -13,6 +13,9 @@ return {
|
|||
canGoSuper = true,
|
||||
canBreakCraft = false,
|
||||
|
||||
weakTo = {"light"},
|
||||
resists = {"earth"},
|
||||
|
||||
icon = 2,
|
||||
charset = "perso",
|
||||
charId = 2,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local CONST = require "datas.stats"
|
||||
local CONST = require "datas.consts.stats"
|
||||
|
||||
return {
|
||||
hpmax = CONST.RANK_C, --
|
||||
|
|
|
@ -7,4 +7,12 @@ function CharacterData:getCommonData()
|
|||
self.turns = self.data.turns
|
||||
end
|
||||
|
||||
function CharacterData:getWeaknesses()
|
||||
return self.data.weakTo
|
||||
end
|
||||
|
||||
function CharacterData:getResistences()
|
||||
return self.data.resists
|
||||
end
|
||||
|
||||
return CharacterData
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local CharacterLevel = Object:extend()
|
||||
|
||||
local charutils = require "game.utils.characters"
|
||||
local STATS = require "datas.stats"
|
||||
local STATS = require "datas.consts.stats"
|
||||
|
||||
function CharacterLevel:initLevel()
|
||||
self.level = self.data.startlevel
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
local AbstractMobParent = require "game.abstractmobs.parent"
|
||||
|
||||
local AbstractEnnemy = AbstractMobParent:extend()
|
||||
local elements = require "datas.gamedata.battles.elements"
|
||||
|
||||
function AbstractEnnemy:new(directory, name)
|
||||
self.simplename = name
|
||||
|
@ -8,6 +9,16 @@ function AbstractEnnemy:new(directory, name)
|
|||
self.super.new(self)
|
||||
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)
|
||||
return utils.table.contain(self.data.protectypes, protectype)
|
||||
end
|
||||
|
|
|
@ -28,7 +28,6 @@ local Serializer = require "birb.classes.serializable.serializer"
|
|||
local Game = Serializer:extend()
|
||||
local Characters = require "game.characters"
|
||||
local Ennemies = require "game.ennemies"
|
||||
local Skills = require "game.skills"
|
||||
local Loot = require "game.loot"
|
||||
local CBSCore = require "game.battle"
|
||||
local Difficulty = require "game.difficulty"
|
||||
|
@ -92,7 +91,6 @@ function Game:reset()
|
|||
|
||||
self.characters = Characters(self)
|
||||
self.ennemies = Ennemies(self)
|
||||
self.skills = Skills(self)
|
||||
self.loot = Loot(self)
|
||||
self.cbs = CBSCore(self)
|
||||
self.difficulty = Difficulty(self)
|
||||
|
|
|
@ -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
|
|
@ -1,3 +1,63 @@
|
|||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local CharUtils = {}
|
||||
|
||||
local CONST = require "datas.stats"
|
||||
local CONST = require "datas.consts.stats"
|
||||
|
||||
function CharUtils.getExpValue(level)
|
||||
return math.floor( ( CONST.EXP_MULTIPLICATOR * ( level ^ 3 ) ) / CONST.EXP_RATIO )
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
local FighterParent = Object:extend()
|
||||
|
||||
local CONST = require "datas.cbs"
|
||||
local battleutils = require "game.utils.battle"
|
||||
|
||||
function FighterParent:new(owner, isHero, id)
|
||||
self.owner = owner
|
||||
|
@ -75,50 +75,34 @@ function FighterParent:haveProtecType(type)
|
|||
end
|
||||
|
||||
function FighterParent:sendDamage(target, value, type, element, isSpecial)
|
||||
local stats = self:getStats()
|
||||
local value = value / 10
|
||||
local damage = battleutils.computeLaunchingDamages(value, self:getStats(), isSpecial)
|
||||
|
||||
if (isSpecial) then
|
||||
value = value * stats.power
|
||||
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)
|
||||
core.debug:print("cbs/battler", "Sending " .. damage .." damage at " .. target.name)
|
||||
return target:receiveDamage(damage, type, element, isSpecial, self)
|
||||
end
|
||||
|
||||
function FighterParent:receiveDamage(value, type, element, isSpecial, fromWho)
|
||||
local accuracy = 100
|
||||
local stats = self:getStats()
|
||||
local isSuccess = true
|
||||
local damages = battleutils.computeReceivingDamages(value, self:getStats(), isSpecial, self.isDefending)
|
||||
damages = battleutils.applyProtectTypes(damages, type, self.abstract:getProtecTypes())
|
||||
damages = battleutils.applyResistences(damages, element, self.abstract:getResistences())
|
||||
damages = battleutils.applyWeaknesses(damages, element, self.abstract:getWeaknesses())
|
||||
|
||||
if (isSpecial) then
|
||||
value = value / stats.mind
|
||||
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
|
||||
if (battleutils.isAttackSuccess(nil)) then
|
||||
self:applyDamage(damages)
|
||||
else
|
||||
self.actor:avoidedAttack()
|
||||
return false
|
||||
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
|
||||
|
||||
function FighterParent:getAbstract()
|
||||
|
|
|
@ -17,7 +17,7 @@ function ActionParent:update(dt)
|
|||
end
|
||||
|
||||
function ActionParent:loadChoregraphy(skillname)
|
||||
local skill = game.skills:getSkillData(skillname)
|
||||
local skill = core.datas:get("skills", skillname)
|
||||
self.choregraphy = ChoregraphySystem(self, skill.choregraphy)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.a
|
|||
local SkillAction = ActionParent:extend()
|
||||
|
||||
function SkillAction:new(fighter, skill)
|
||||
self.data = game.skills:getSkillData(skill)
|
||||
self.data = core.datas:get("skills", skill)
|
||||
SkillAction.super.new(self, fighter)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.a
|
|||
local EnnemyAction = ActionParent:extend()
|
||||
|
||||
function EnnemyAction:new(fighter, skill)
|
||||
self.data = game.skills:getEnnemySkillData(skill)
|
||||
self.data = core.datas:get("badskills", skill)
|
||||
EnnemyAction.super.new(self, fighter)
|
||||
end
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ function widgets.SkillWidget:new(character, menu_name, skill)
|
|||
self.skillname = skill
|
||||
local label2 = "00"
|
||||
|
||||
self.skilldata = game.skills:getSkillData(skill)
|
||||
self.skilldata = core.datas:get("skills", skill)
|
||||
|
||||
if self.skilldata ~= nil then
|
||||
label2 = self.skilldata.cost or 0
|
||||
|
|
|
@ -35,7 +35,7 @@ function ChoregraphyViewer:buildCharacterMenu()
|
|||
self:addSubMenu("characters", "MainMenu", "Rivals")
|
||||
for k, character in pairs(game.characters.list) do
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
@ -51,8 +51,8 @@ function ChoregraphyViewer:buildEnnemySkillMenu(category, ennemy)
|
|||
self:addSubMenu(ennemy, category, ennemy)
|
||||
local data = core.datas:get("ennemies", ennemy)
|
||||
for j,skillName in ipairs(data.skills) do
|
||||
if (game.skills:ennemySkillDataExists(skillName)) then
|
||||
menu.EnnemyChoregraphyWidget(self, category, ennemy, game.skills:getEnnemySkillData(skillName))
|
||||
if (core.datas:exists("badskills", skillName)) then
|
||||
menu.EnnemyChoregraphyWidget(self, category, ennemy, core.datas:get("badskills", skillName))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -64,8 +64,8 @@ function ChoregraphyViewer:buildSkillMenu(charName)
|
|||
local skillName = skill[1]
|
||||
if (skillTreated[skillName] ~= true) then
|
||||
skillTreated[skillName] = true
|
||||
if (game.skills:skillDataExists(skillName)) then
|
||||
menu.HeroChoregraphyWidget(self, charName, game.skills:getSkillData(skillName))
|
||||
if (core.datas:exists("skills", skillName)) then
|
||||
menu.HeroChoregraphyWidget(self, charName, core.datas:get("skills", skillName))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,7 +60,7 @@ end
|
|||
|
||||
function SkillWidget:new(page, skill)
|
||||
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))
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ local const = require "scenes.overworld.screens.mainmenu.const"
|
|||
local EquipMenu = menu.ListMenu:extend()
|
||||
local EquipWidget = menu.DualTextWidget:extend()
|
||||
|
||||
local STATS = require "datas.stats"
|
||||
local STATS = require "datas.consts.stats"
|
||||
|
||||
function StatPage:new(view, character)
|
||||
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40 + 32)
|
||||
|
|
|
@ -10,7 +10,7 @@ local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.ch
|
|||
local CharacterMenu = baseCharacterMenu:extend()
|
||||
local CharacterWidget = baseCharacterWidget:extend()
|
||||
|
||||
local STATS = require "datas.stats"
|
||||
local STATS = require "datas.consts.stats"
|
||||
|
||||
local DESC_SIZE = 32 * 6
|
||||
|
||||
|
|
Loading…
Reference in a new issue