From 142dd3d784336b859c072c9b3c8cc96a535980a2 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Sat, 21 Aug 2010 00:39:38 +0000 Subject: [PATCH] Each achievement now have three versions, one for each difficulty level git-svn-id: http://svn.net-core.org/repos/t-engine4@1034 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/dialogs/ShowAchievements.lua | 6 ++- game/modules/tome/class/World.lua | 9 ++-- .../class/interface/WorldAchievements.lua | 43 +++++++++++++++++++ game/modules/tome/load.lua | 2 +- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 game/modules/tome/class/interface/WorldAchievements.lua diff --git a/game/engine/dialogs/ShowAchievements.lua b/game/engine/dialogs/ShowAchievements.lua index 14df49b483..b25d5b8354 100644 --- a/game/engine/dialogs/ShowAchievements.lua +++ b/game/engine/dialogs/ShowAchievements.lua @@ -23,7 +23,11 @@ require "engine.Dialog" module(..., package.seeall, class.inherit(engine.Dialog)) function _M:init(title) - engine.Dialog.init(self, title or "Achievements", game.w * 0.8, game.h * 0.8, nil, nil, nil, core.display.newFont("/data/font/VeraMono.ttf", 12)) + local total = #world.achiev_defs + local nb = 0 + for id, data in pairs(world.achieved) do nb = nb + 1 end + + engine.Dialog.init(self, (title or "Achievements").." ("..nb.."/"..total..")", game.w * 0.8, game.h * 0.8, nil, nil, nil, core.display.newFont("/data/font/VeraMono.ttf", 12)) self:generateList() diff --git a/game/modules/tome/class/World.lua b/game/modules/tome/class/World.lua index 836495abdd..ea2cc0b54e 100644 --- a/game/modules/tome/class/World.lua +++ b/game/modules/tome/class/World.lua @@ -19,10 +19,10 @@ require "engine.class" require "engine.World" -require "engine.interface.WorldAchievements" +require "mod.class.interface.WorldAchievements" local Savefile = require "engine.Savefile" -module(..., package.seeall, class.inherit(engine.World, engine.interface.WorldAchievements)) +module(..., package.seeall, class.inherit(engine.World, mod.class.interface.WorldAchievements)) function _M:init() engine.World.init(self) @@ -54,5 +54,8 @@ function _M:gainAchievement(id, src, ...) -- Do not unlock things in easy mode if not a or (game.difficulty == game.DIFFICULTY_EASY and not a.tutorial) then return end - engine.interface.WorldAchievements.gainAchievement(self, id, src, ...) + if game.difficulty == game.DIFFICULTY_NIGHTMARE then id = "NIGHTMARE_"..id end + if game.difficulty == game.DIFFICULTY_INSANE then id = "INSANE_"..id end + + mod.class.interface.WorldAchievements.gainAchievement(self, id, src, ...) end diff --git a/game/modules/tome/class/interface/WorldAchievements.lua b/game/modules/tome/class/interface/WorldAchievements.lua new file mode 100644 index 0000000000..8eeac2b0fa --- /dev/null +++ b/game/modules/tome/class/interface/WorldAchievements.lua @@ -0,0 +1,43 @@ +-- TE4 - T-Engine 4 +-- Copyright (C) 2009, 2010 Nicolas Casalini +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. +-- +-- Nicolas Casalini "DarkGod" +-- darkgod@te4.org + +require "engine.class" +local WA = require "engine.interface.WorldAchievements" +local table = table + +--- Handles archievements in a world +module(..., package.seeall, class.inherit({}, WA)) + +--- Make a new achivement with a name and desc +function _M:newAchievement(t) + t.id = t.id or t.name + t.id = t.id:upper():gsub("[ ]", "_") + + WA.newAchievement(self, t) + + local t2 = table.clone(t) + t2.id = "NIGHTMARE_"..t2.id + t2.name = t2.name.." (Nightmare difficulty)" + WA.newAchievement(self, t2) + + local t2 = table.clone(t) + t2.id = "INSANE_"..t2.id + t2.name = t2.name.." (Insane difficulty)" + WA.newAchievement(self, t2) +end diff --git a/game/modules/tome/load.lua b/game/modules/tome/load.lua index 3d5cc4e41d..e8e0469694 100644 --- a/game/modules/tome/load.lua +++ b/game/modules/tome/load.lua @@ -35,7 +35,7 @@ local ActorInventory = require "engine.interface.ActorInventory" local ActorLevel = require "engine.interface.ActorLevel" local Birther = require "engine.Birther" local Store = require "mod.class.Store" -local WorldAchievements = require "engine.interface.WorldAchievements" +local WorldAchievements = require "mod.class.interface.WorldAchievements" local Quest = require "engine.Quest" config.settings.tome = config.settings.tome or {} -- GitLab