2021-04-03 10:39:34 +02:00
|
|
|
local BattleUtils = {}
|
2021-05-16 08:33:41 +02:00
|
|
|
local CONSTS = require "datas.cbs"
|
|
|
|
|
|
|
|
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, protectype)
|
|
|
|
if (utils.table.contain(protectype, "aerial") and type == "basic") then
|
|
|
|
value = value * CONSTS.ATKWRONGTYPE
|
|
|
|
end
|
|
|
|
return value
|
|
|
|
end
|
|
|
|
|
|
|
|
function BattleUtils.isAttackSuccess(statutList)
|
|
|
|
local accuracy = 100
|
|
|
|
return (math.random(100) <= accuracy)
|
|
|
|
end
|
2020-08-04 17:50:03 +02:00
|
|
|
|
|
|
|
return BattleUtils
|