From 148dd5532c2536b5f1b8cc00923164efdf953e19 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Fri, 21 May 2010 13:24:58 +0000
Subject: [PATCH] cannot unlock and gain achievements in easy mode

git-svn-id: http://svn.net-core.org/repos/t-engine4@666 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Game.lua  |  5 ++++-
 game/modules/tome/class/World.lua | 10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 3e20bb80ef..334e9e7d23 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -218,7 +218,7 @@ function _M:setupMiniMap()
 end
 
 function _M:save()
-	return class.save(self, self:defaultSavedFields{}, true)
+	return class.save(self, self:defaultSavedFields{difficulty=true}, true)
 end
 
 function _M:getSaveDescription()
@@ -821,6 +821,9 @@ function _M:saveGame()
 end
 
 function _M:setAllowedBuild(what, notify)
+	-- Do not unlock things in easy mode
+	if game.difficulty == game.DIFFICULTY_EASY then return end
+
 	config.settings.tome = config.settings.tome or {}
 	config.settings.tome.allow_build = config.settings.tome.allow_build or {}
 	if config.settings.tome.allow_build[what] then return false end
diff --git a/game/modules/tome/class/World.lua b/game/modules/tome/class/World.lua
index a2d4addabe..2d109ce952 100644
--- a/game/modules/tome/class/World.lua
+++ b/game/modules/tome/class/World.lua
@@ -42,3 +42,13 @@ end
 function _M:achievementWho(src)
 	return src.name.." the "..game.player.descriptor.subrace.." "..game.player.descriptor.subclass
 end
+
+--- Gain an achievement
+-- @param id the achivement to gain
+-- @param src who did it
+function _M:gainAchievement(id, src, ...)
+	-- Do not unlock things in easy mode
+	if game.difficulty == game.DIFFICULTY_EASY then return end
+
+	engine.interface.WorldAchievements.gainAchievement(self, id, src, ...)
+end
-- 
GitLab