chore: use getter to get stat
This commit is contained in:
parent
c7b9d97c96
commit
7db0ad1b28
13 changed files with 43 additions and 29 deletions
|
@ -164,7 +164,7 @@ end
|
|||
function CharacterManager:sendDamageFromMap(name, damageRatio)
|
||||
local character = self.list[name]
|
||||
if (character.hp > 0) then
|
||||
local newHP = math.floor(character.hp - (character.stats.hpmax * damageRatio))
|
||||
local newHP = math.floor(character.hp - (character.stats:get(character.stats.HPMAX) * damageRatio))
|
||||
if (not game.difficulty:get("hazardMakesKo")) then
|
||||
newHP = math.max(1, newHP)
|
||||
end
|
||||
|
|
|
@ -35,10 +35,11 @@ function HealEffect:getCurrentValue()
|
|||
end
|
||||
|
||||
function HealEffect:getMaxValue()
|
||||
local stats = self.character.stats
|
||||
if (self.effect.healType == "hp") then
|
||||
return self.character.stats.hpmax
|
||||
return stats:get(stats.HPMAX)
|
||||
elseif (self.effect.healType == "mp") then
|
||||
return self.character.stats.ppmax
|
||||
return stats:get(stats.PPMAX)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ end
|
|||
function StatusBar:drawStatusArea(x, y)
|
||||
self.assets.images["statusbar"]:draw(x, y)
|
||||
|
||||
local hpmax = self.stats.hpmax
|
||||
local ppmax = self.stats.ppmax
|
||||
local hpmax = self.stats:get(self.stats.HPMAX)
|
||||
local ppmax = self.stats:get(self.stats.PPMAX)
|
||||
|
||||
self.assets.fonts["hudnbrs_small"]:set()
|
||||
self.hpbar:drawWithLabels(x + 6, y + 9, self.hp, hpmax)
|
||||
|
|
|
@ -5,9 +5,9 @@ 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
|
||||
damages = damages * stats:get(stats.POWER)
|
||||
else
|
||||
damages = damages * stats.attack
|
||||
damages = damages * stats:get(stats.ATTACK)
|
||||
end
|
||||
return damages
|
||||
end
|
||||
|
@ -15,9 +15,9 @@ end
|
|||
function BattleUtils.computeReceivingDamages(base, stats, isSpecial, isDefending)
|
||||
local damages = base
|
||||
if (isSpecial) then
|
||||
damages = damages / stats.mind
|
||||
damages = damages / stats:get(stats.MIND)
|
||||
else
|
||||
damages = damages / stats.defense
|
||||
damages = damages / stats:get(stats.DEFENSE)
|
||||
end
|
||||
|
||||
if (isDefending) then
|
||||
|
|
|
@ -30,8 +30,10 @@ end
|
|||
function EnnemyController:getHighestSpeed()
|
||||
local highestSpeed = 0
|
||||
for i, villain in ipairs(self.list) do
|
||||
if (villain.abstract.stats.speed > highestSpeed) then
|
||||
highestSpeed = villain.abstract.stats.speed
|
||||
local stats = villain.abstract.stats
|
||||
local currentSpeed = stats:get(stats.SPEED)
|
||||
if (currentSpeed > highestSpeed) then
|
||||
highestSpeed = currentSpeed
|
||||
end
|
||||
end
|
||||
return highestSpeed
|
||||
|
|
|
@ -11,13 +11,15 @@ end
|
|||
|
||||
function FleeAction:startAction()
|
||||
core.debug:print("cbs/action", "Starting flee action")
|
||||
local stats = self.fighter.abstract.stats
|
||||
|
||||
if (self.fighter.abstract.name == "shadow") then
|
||||
self.fighter.turns.hud:showMessage("You won't flee the battle")
|
||||
self:finishAction()
|
||||
return
|
||||
end
|
||||
|
||||
local chanceToFlee = self.fighter.turnSystem:getChanceTooFlee(self.fighter.abstract.stats.speed)
|
||||
local chanceToFlee = self.fighter.turnSystem:getChanceTooFlee(stats:get(stats.SPEED))
|
||||
if (math.random(100) < chanceToFlee) then
|
||||
self.fighter.turnSystem.hud:showMessage("You flee the battle")
|
||||
self.fighter.turnSystem:fleeBattle()
|
||||
|
|
|
@ -8,8 +8,8 @@ maputils.CONST.STARTY = 90
|
|||
function maputils.sortBattlers(a, b)
|
||||
local astats = a.fighter:getStats()
|
||||
local bstats = b.fighter:getStats()
|
||||
local aspeed = astats.speed / (3 ^ (a.number-1))
|
||||
local bspeed = bstats.speed / (3 ^ (b.number-1))
|
||||
local aspeed = astats:get(astats.SPEED) / (3 ^ (a.number-1))
|
||||
local bspeed = bstats:get(astats.SPEED) / (3 ^ (b.number-1))
|
||||
|
||||
|
||||
if (aspeed == bspeed) then
|
||||
|
|
|
@ -7,18 +7,25 @@ function CharacterPanel:new(character)
|
|||
end
|
||||
|
||||
function CharacterPanel:drawContent(x, y)
|
||||
local stats = self.character.stats
|
||||
|
||||
local debugString = "# DEBUG - " .. self.character.name .. "(" .. "Lvl " .. self.character.level .. ")" .. "\n"
|
||||
local debugString = debugString .. "EXP: " .. self.character.exp .. " / " .. self.character.exp_next .. "\n"
|
||||
local debugString = debugString .. "HP: " .. self.character.hp .. " / " .. self.character.stats.hpmax .. "\n"
|
||||
local debugString = debugString .. "PP: " .. self.character.pp .. " / " .. self.character.stats.ppmax .. "\n"
|
||||
local debugString = debugString .. "ATK: " .. self.character.stats.attack
|
||||
local debugString = debugString .. " DEF: " .. self.character.stats.defense
|
||||
local debugString = debugString .. " SPD: " .. self.character.stats.speed .. "\n"
|
||||
local debugString = debugString .. "POW: " .. self.character.stats.power
|
||||
local debugString = debugString .. " MND: " .. self.character.stats.mind
|
||||
local debugString = debugString .. " TEK: " .. self.character.stats.technic .. "\n"
|
||||
local debugString = debugString .. "HP: " .. self.character.hp .. " / " .. stats:get(stats.HPMAX) .. "\n"
|
||||
local debugString = debugString .. "PP: " .. self.character.pp .. " / " .. stats:get(stats.PPMAX) .. "\n"
|
||||
local debugString = debugString .. self:addToDebugString(stats, stats.ATTACK)
|
||||
local debugString = debugString .. " " .. self:addToDebugString(stats, stats.DEFENSE)
|
||||
local debugString = debugString .. " " .. self:addToDebugString(stats, stats.SPEED) .. "\n"
|
||||
local debugString = debugString .. self:addToDebugString(stats, stats.POWER)
|
||||
local debugString = debugString .. " " .. self:addToDebugString(stats, stats.MIND)
|
||||
local debugString = debugString .. " " .. self:addToDebugString(stats, stats.TECHNIC) .. "\n"
|
||||
|
||||
love.graphics.print(debugString, x, y)
|
||||
end
|
||||
|
||||
function CharacterPanel:addToDebugString(stats, statname)
|
||||
local stats = stats
|
||||
return stats.CONST.SIMPLENAME[statname] .. ": " .. stats:get(statname)
|
||||
end
|
||||
|
||||
return CharacterPanel
|
||||
|
|
|
@ -17,7 +17,7 @@ function PlayerHealth:drawHealth(x, y)
|
|||
local yy = y + (i * 17)
|
||||
local character = game.characters.list[name]
|
||||
self.scene.assets.fonts["hudnbrs_small"]:set()
|
||||
self.hpbar:drawWithLabels(x + 18, yy, character.hp, character.stats.hpmax)
|
||||
self.hpbar:drawWithLabels(x + 18, yy, character.hp, character.stats:get(character.stats.HPMAX))
|
||||
self.assets.tileset["charicons"]:drawTile(character.data.icon, x, yy - 3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,10 +42,11 @@ function BasicPage:drawIdentity(x, y)
|
|||
end
|
||||
|
||||
function BasicPage:drawHPPP(x, y)
|
||||
local stats = self.character.stats
|
||||
self.view.scene.assets.fonts["hudnbrs_small"]:set()
|
||||
self.hpbar:drawWithLabels(x, y - 4, self.character.hp, self.character.stats.hpmax)
|
||||
self.hpbar:drawWithLabels(x, y - 4, self.character.hp, stats:get(stats.HPMAX))
|
||||
local xx = x + const.CHARPAGESIZE - HPBAR_SIZE - 7
|
||||
self.ppbar:drawWithLabels(xx, y - 4, self.character.pp, self.character.stats.ppmax)
|
||||
self.ppbar:drawWithLabels(xx, y - 4, self.character.pp, stats:get(stats.PPMAX))
|
||||
end
|
||||
|
||||
function BasicPage:drawLevel(x, y)
|
||||
|
|
|
@ -36,7 +36,7 @@ function StatPage:drawStats(x, y)
|
|||
local xStat = x + (((i - 1) % 2) * (const.CHARPAGESIZE/2)) + 6
|
||||
local yStat = y + (math.floor((i-1)/2) * 16) + 4
|
||||
local middle = xStat + 10 + const.CHARPAGESIZE/4
|
||||
local stat = char.stats[statName]
|
||||
local stat = char.stats:get(statName)
|
||||
self.view.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, const.CHARPAGESIZE, "left")
|
||||
self.view.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9)
|
||||
self.view.scene.assets.fonts["small"]:draw(stat, middle, yStat, -1, "center")
|
||||
|
|
|
@ -53,8 +53,9 @@ function CharacterWidget:draw(x, y)
|
|||
local xDebut = x + 52
|
||||
local yDebut = y + 15
|
||||
self.scene.assets.fonts["hudnbrs_small"]:set()
|
||||
self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, character.stats.hpmax)
|
||||
self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, character.stats.ppmax)
|
||||
local stats = character.stats
|
||||
self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, stats:get(stats.HPMAX))
|
||||
self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, stats:get(stats.PPMAX))
|
||||
end
|
||||
if self.canvas.texture ~= nil then
|
||||
love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy)
|
||||
|
|
|
@ -52,7 +52,7 @@ function EquipScreen:drawDescription(x, y)
|
|||
local xStat = xx + (((i - 1) % 2) * (ww/2))
|
||||
local yStat = yy + (math.floor((i-1)/2) * 16) + 24
|
||||
local middle = xStat + 10 + ww/4
|
||||
local stat = char.stats[statName]
|
||||
local stat = char.stats:get(statName)
|
||||
local newStat = char:predictStat(statName, self.category, self.item.name)
|
||||
self.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, ww, "left")
|
||||
self.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9)
|
||||
|
|
Loading…
Reference in a new issue