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