From 4d5d82fc87c92ce2cc0d51f3d349d4ca7b493b1e Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sat, 28 Nov 2009 18:45:19 +0000 Subject: [PATCH] boom git-svn-id: http://svn.net-core.org/repos/t-engine4@62 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/tome/class/Actor.lua | 5 ++++ game/modules/tome/class/Game.lua | 26 +++++++++++++------ game/modules/tome/class/Player.lua | 2 ++ .../tome/data/zones/ancient_ruins/zone.lua | 4 +-- game/modules/tome/dialogs/LevelupDialog.lua | 21 +++++++++++++++ 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 game/modules/tome/dialogs/LevelupDialog.lua diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 8ebdaa7ceb..c6bf5691d2 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -24,6 +24,9 @@ function _M:init(t) engine.interface.ActorLevel.init(self, t) engine.interface.ActorStats.init(self, t) engine.interface.ActorAbilities.init(self, t) + + self.unused_stats = 0 + self.unused_abilities = 0 end function _M:move(x, y, force) @@ -67,6 +70,8 @@ function _M:die(src) end function _M:levelup() + self.unused_stats = self.unused_stats + 3 + self.unused_abilities = self.unused_abilities + 1 end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index d2eb00188f..ba5898ce42 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -1,26 +1,31 @@ require "engine.class" require "engine.GameTurnBased" require "engine.KeyCommand" -local LogDisplay = require "engine.LogDisplay" local Savefile = require "engine.Savefile" -local DebugConsole = require "engine.DebugConsole" -local FlyingText = require "engine.FlyingText" -local Tooltip = require "engine.Tooltip" -local QuitDialog = require "mod.dialogs.Quit" -local Calendar = require "engine.Calendar" local DamageType = require "engine.DamageType" local Zone = require "engine.Zone" local Map = require "engine.Map" local Target = require "engine.Target" local Level = require "engine.Level" + local Grid = require "engine.Grid" local Actor = require "mod.class.Actor" local ActorStats = require "engine.interface.ActorStats" local ActorAbilities = require "engine.interface.ActorAbilities" local Player = require "mod.class.Player" -local PlayerDisplay = require "mod.class.PlayerDisplay" local NPC = require "mod.class.NPC" +local PlayerDisplay = require "mod.class.PlayerDisplay" + +local LogDisplay = require "engine.LogDisplay" +local DebugConsole = require "engine.DebugConsole" +local FlyingText = require "engine.FlyingText" +local Tooltip = require "engine.Tooltip" +local Calendar = require "engine.Calendar" + +local QuitDialog = require "mod.dialogs.Quit" +local LevelupDialog = require "mod.dialogs.LevelupDialog" + module(..., package.seeall, class.inherit(engine.GameTurnBased)) function _M:init() @@ -70,7 +75,7 @@ end function _M:newGame() self.zone = Zone.new("ancient_ruins") - self.player = Player.new{name=self.player_name, image='player.png', display='@', color_r=230, color_g=230, color_b=230} + self.player = Player.new{name=self.player_name, max_life=10000, image='player.png', display='@', color_r=230, color_g=230, color_b=230} self:changeLevel(1) end @@ -242,6 +247,11 @@ function _M:setupCommands() self.player:useAbility(ActorAbilities.AB_PHASE_DOOR) end, + [{"_g","shift"}] = function() + local levelup_dialog = LevelupDialog.new(self.player) + self:registerDialog(levelup_dialog) + end, + _LEFT = function() self.player:move(self.player.x - 1, self.player.y ) end, _RIGHT = function() self.player:move(self.player.x + 1, self.player.y ) end, _UP = function() self.player:move(self.player.x , self.player.y - 1) end, diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index d0e8f9a7a5..7ed1d99567 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -33,6 +33,8 @@ function _M:setName(name) end function _M:levelup() + mod.class.Actor.levelup(self) + local x, y = game.level.map:getTileToScreen(self.x, self.y) game.flyers:add(x, y, 80, 0.5, -2, "LEVEL UP!", {0,255,255}) game.log("#00ffff#Welcome to level %d", self.level) diff --git a/game/modules/tome/data/zones/ancient_ruins/zone.lua b/game/modules/tome/data/zones/ancient_ruins/zone.lua index 087b1349d1..e253252da9 100644 --- a/game/modules/tome/data/zones/ancient_ruins/zone.lua +++ b/game/modules/tome/data/zones/ancient_ruins/zone.lua @@ -7,7 +7,7 @@ return { -- persistant = true, generator = { map = { - class= "engine.generator.map.Rooms", + class= "engine.generator.map.Empty", floor = "FLOOR", wall = "WALL", up = "UP", @@ -16,7 +16,7 @@ return { }, actor = { class = "engine.generator.actor.Random", - nb_npc = {40, 40}, + nb_npc = {400, 400}, levelup = {5, 10}, }, } diff --git a/game/modules/tome/dialogs/LevelupDialog.lua b/game/modules/tome/dialogs/LevelupDialog.lua new file mode 100644 index 0000000000..72d325187e --- /dev/null +++ b/game/modules/tome/dialogs/LevelupDialog.lua @@ -0,0 +1,21 @@ +require "engine.class" +require "engine.Dialog" + +module(..., package.seeall, class.inherit(engine.Dialog)) + +function _M:init(actor) + self.actor = actor + engine.Dialog.init(self, "Levelup: "..actor.name, game.w, game.h) + +-- self. + + self:keyCommands{ + _ESCAPE = function() + game:unregisterDialog(self) + end, + } +end + +function _M:drawDialog(s, w, h) + s:drawColorStringCentered(self.font, "Stats points left: "..self.actor.unused_stats, 2, 2, self.iw - 2, self.ih - 2) +end -- GitLab