sonic-radiance/sonic-radiance.love/game/abstractmobs/utils.lua

49 lines
1.3 KiB
Lua

local CharUtils = {}
local CONST = {}
CONST.EXP_MULTIPLICATOR = 4
CONST.EXP_RATIO = 5
CONST.BASE_STAT = 5
CONST.BASE_HP = 15
CONST.BASE_MP = 8
CONST.MULT_STAT = 2
CONST.MULT_HP = 2.7
CONST.MULT_MP = 1.5
function CharUtils.getExpValue(level)
return math.floor( ( CONST.EXP_MULTIPLICATOR * ( level ^ 3 ) ) / CONST.EXP_RATIO )
end
function CharUtils.getStatValue(level, base)
return math.floor( (((base * CONST.MULT_STAT) * level)/100) ) + CONST.BASE_STAT
end
function CharUtils.getHPValue(level, base)
return math.floor( (((base * CONST.MULT_HP) * level)/100) ) + CONST.BASE_HP + level
end
function CharUtils.getPPValue(level, base)
return math.floor( (((base * CONST.MULT_MP) * level)/100) ) + CONST.BASE_MP
end
function CharUtils.charDataExists(name)
local dir = "datas/gamedata/characters/" .. name .. "/init.lua"
local fileinfo = love.filesystem.getInfo(dir)
return (fileinfo ~= nil)
end
function CharUtils.getCharacterData(charname)
-- va eprmettre de récupérer les données d'un personnage
local charfolder = "datas.gamedata.characters." .. charname
local character = require(charfolder)
character.base_stats = require(charfolder .. ".stats")
character.inventory = require(charfolder .. ".inventory")
character.skills = require(charfolder .. ".skills")
return character
end
return CharUtils