41 lines
1 KiB
Lua
41 lines
1 KiB
Lua
local BattleUtils = {}
|
|
local CONSTS = require "datas.consts.battle"
|
|
|
|
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
|
|
|
|
return BattleUtils
|