Skip to content
Snippets Groups Projects
Commit f271282d authored by dg's avatar dg
Browse files

polish stats levelup dialog

git-svn-id: http://svn.net-core.org/repos/t-engine4@65 51575b47-30f0-44d4-a5cc-537603b46e54
parent 8c4a584e
No related branches found
No related tags found
No related merge requests found
......@@ -76,16 +76,17 @@ end
function _M:getType(t)
if not t or not t.type then return {} end
t.range = t.range or 20
if t.friendlyfire == nil then t.friendlyfire = true end
if t.type == "hit" then
return {range=t.range}
return {range=t.range, friendlyfire=t.friendlyfire}
elseif t.type == "beam" then
return {range=t.range, line=true}
return {range=t.range, friendlyfire=t.friendlyfire, line=true}
elseif t.type == "bolt" then
return {range=t.range, stop_block=true}
return {range=t.range, friendlyfire=t.friendlyfire, stop_block=true}
elseif t.type == "ball" then
return {range=t.range, ball=t.radius}
return {range=t.range, friendlyfire=t.friendlyfire, ball=t.radius}
elseif t.type == "cone" then
return {range=t.range, cone=t.radius}
return {range=t.range, friendlyfire=t.friendlyfire, cone=t.radius}
else
return {}
end
......
......@@ -90,7 +90,14 @@ function _M:project(t, x, y, damtype, dam)
-- Now project on each grid, one type
for px, ys in pairs(grids) do
for py, _ in pairs(ys) do
DamageType:get(damtype).projector(self, px, py, damtype, dam)
-- Friendly fire ?
if px == self.x and py == self.y then
if t.friendlyfire then
DamageType:get(damtype).projector(self, px, py, damtype, dam)
end
else
DamageType:get(damtype).projector(self, px, py, damtype, dam)
end
end
end
end
......@@ -47,7 +47,11 @@ end
-- @param stat the stat id to change
-- @param val the increment to add/substract
function _M:incStat(stat, val)
local old = self.stats[stat]
self.stats[stat] = math.max(math.min(self.stats[stat] + val, _M.stats_def[stat].max), _M.stats_def[stat].min)
if self.stats[stat] - old ~= 0 then
self:onStatChange(stat, self.stats[stat] - old)
end
return self.stats[stat]
end
......@@ -58,3 +62,7 @@ end
function _M:getStat(stat)
return self.stats[stat]
end
--- Notifies a change of stat value
function _M:onStatChange(stat, v)
end
......@@ -72,7 +72,15 @@ end
function _M:levelup()
self.unused_stats = self.unused_stats + 3
self.unused_abilities = self.unused_abilities + 1
end
--- Notifies a change of stat value
function _M:onStatChange(stat, v)
if stat == self.STAT_CON then
self.max_life = self.max_life + 5 * v
elseif stat == self.STAT_MAG then
self.max_mana = self.max_mana + 5 * v
end
end
function _M:attack(target)
......
......@@ -24,7 +24,7 @@ local Tooltip = require "engine.Tooltip"
local Calendar = require "engine.Calendar"
local QuitDialog = require "mod.dialogs.Quit"
local LevelupDialog = require "mod.dialogs.LevelupDialog"
local LevelupStatsDialog = require "mod.dialogs.LevelupStatsDialog"
module(..., package.seeall, class.inherit(engine.GameTurnBased))
......@@ -248,8 +248,8 @@ function _M:setupCommands()
end,
[{"_g","shift"}] = function()
local levelup_dialog = LevelupDialog.new(self.player)
self:registerDialog(levelup_dialog)
local d = LevelupStatsDialog.new(self.player)
self:registerDialog(d)
end,
_LEFT = function() self.player:move(self.player.x - 1, self.player.y ) end,
......
......@@ -6,7 +6,7 @@ module(..., package.seeall, class.inherit(engine.Dialog))
function _M:init(actor)
self.actor = actor
self.actor_dup = actor:clone()
engine.Dialog.init(self, "Levelup: "..actor.name, 600, 400)
engine.Dialog.init(self, "Stats Levelup: "..actor.name, 500, 300)
-- self.statstpl = self:loadDisplayTemplate()
self.statsel = 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment