Instructions Jenkins Doxygen

[Removed] old old man files. 95/1295/2
authorLoshult <loshult@swgemu.com>
Thu, 26 Dec 2013 15:29:53 +0000 (15:29 +0000)
committerLoshult <loshult@swgemu.com>
Thu, 26 Dec 2013 18:44:18 +0000 (18:44 +0000)
Change-Id: I76d53c3b8a2bd568e9807a0072d76cbfbef7454a

MMOCoreORB/bin/scripts/managers/jedi/village/mocks/old_man_mocks.lua [deleted file]
MMOCoreORB/bin/scripts/managers/jedi/village/old_man.lua [deleted file]
MMOCoreORB/bin/scripts/managers/jedi/village/tests/old_man_Test.lua [deleted file]
MMOCoreORB/bin/scripts/managers/jedi/village/tests/village_jedi_manager_Test.lua

diff --git a/MMOCoreORB/bin/scripts/managers/jedi/village/mocks/old_man_mocks.lua b/MMOCoreORB/bin/scripts/managers/jedi/village/mocks/old_man_mocks.lua
deleted file mode 100755 (executable)
index 6fb3450..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-local OldMan = require("managers.jedi.village.old_man")
-
-local realCreateSpawnOldManEvent
-local realOldManBelongsToThePlayer
-local realScheduleDespawnOfOldMan
-local realGiveForceCrystalToPlayer
-
-local OldManMocks = OldMan
-OldManMocks.mocks = {}
-
-function OldManMocks.mocks.setup()
-       realCreateSpawnOldManEvent = OldMan.createSpawnOldManEvent
-       realOldManBelongsToThePlayer = OldMan.oldManBelongsToThePlayer
-       realScheduleDespawnOfOldMan = OldMan.scheduleDespawnOfOldMan
-       realGiveForceCrystalToPlayer = OldMan.giveForceCrystalToPlayer
-end
-
-function OldManMocks.mocks.teardown()
-       OldMan.createSpawnOldManEvent = realCreateSpawnOldManEvent
-       OldMan.oldManBelongsToThePlayer = realOldManBelongsToThePlayer
-       OldMan.scheduleDespawnOfOldMan = realScheduleDespawnOfOldMan
-       OldMan.giveForceCrystalToPlayer = realGiveForceCrystalToPlayer
-end
-
-function OldManMocks.mocks.before_each()
-       OldMan.createSpawnOldManEvent = spy.new(function() end)
-       OldMan.oldManBelongsToThePlayer = spy.new(function() return false end)
-       OldMan.scheduleDespawnOfOldMan = spy.new(function() end)
-       OldMan.giveForceCrystalToPlayer = spy.new(function() end)
-end
-
-function OldManMocks.mocks.after_each()
-end
-
-return OldManMocks
diff --git a/MMOCoreORB/bin/scripts/managers/jedi/village/old_man.lua b/MMOCoreORB/bin/scripts/managers/jedi/village/old_man.lua
deleted file mode 100755 (executable)
index 9302be1..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-local ObjectManager = require("managers.object.object_manager")
-local QuestManager = require("managers.quest.quest_manager")
-local VillageJediManagerCommon = require("managers.jedi.village.village_jedi_manager_common")
-
-local OldMan = {}
-OldManPublicEventsAndObservers = {}
-local OldManPrivate = {}
-
--- Expose private functions for testing.
-function OldMan.exposePrivateFunctions()
-       if BUSTED_TEST then
-               OldMan.private = OldManPrivate
-               OldMan.global = OldManPublicEventsAndObservers
-       end
-end
-
--- Hide private functions.
-function OldMan.hidePrivateFunctions()
-       OldMan.private = {}
-       OldMan.global = {}
-end
-
-OLD_MAN_MIN_SPAWN_DISTANCE = 32
-OLD_MAN_MAX_SPAWN_DISTANCE = 64
-OLD_MAN_TEMPLATE = "old_man"
-OLD_MAN_RESPAWN_TIME = 0
-OLD_MAN_HEADING = 0
-OLD_MAN_ID_STRING = ":old_man_id"
-OLD_MAN_EVENT_SCHEDULED_STRING = "old_man_event_scheduled"
-OLD_MAN_NOT_SCHEDULED = 0
-OLD_MAN_SCHEDULED = 1
-OLD_MAN_SPAWNED = 2
---OLD_MAN_SPAWN_TIME = 12 * 60 * 60 * 1000 -- 12 hours as base
-OLD_MAN_DESPAWN_TIME = 5 * 60 * 1000 -- 5 minutes
---OLD_MAN_SPAWN_TIME = 12 * 60 * 1000 -- 12 minutes as base for testing
-OLD_MAN_SPAWN_TIME = 30 * 1000 -- 12 seconds as base for testing
---OLD_MAN_DESPAWN_TIME = 30 * 1000 -- 30 seconds as base for testing
-OLD_MAN_STOP_FOLLOW_TIME = 15 * 1000 -- 15 seconds
-OLD_MAN_SPATIAL_CHAT_TIME = 5 * 1000 -- 5 seconds
-OLD_MAN_GREETING_STRING = "@quest/force_sensitive/intro:oldman_greeting"
-OLD_MAN_NO_OLD_MAN_SPAWNED = 0
-OLD_MAN_INVENTORY_STRING = "inventory"
-OLD_MAN_FORCE_CRYSTAL_STRING = "object/tangible/loot/quest/force_sensitive/force_crystal.iff"
-
--- Spawn the old man near the player.
--- @pCreatureObject pointer to the creature object of the player.
-function OldManPrivate.spawnOldMan(pCreatureObject)
-       return ObjectManager.withSceneObject(pCreatureObject, function(sceneObject)
-               local spawnPoint = getSpawnPoint(pCreatureObject, sceneObject:getWorldPositionX(), sceneObject:getWorldPositionY(), OLD_MAN_MIN_SPAWN_DISTANCE, OLD_MAN_MAX_SPAWN_DISTANCE)
-               if spawnPoint ~= nil then
-                       return spawnMobile(sceneObject:getZoneName(), OLD_MAN_TEMPLATE, OLD_MAN_RESPAWN_TIME, spawnPoint[1], spawnPoint[2], spawnPoint[3], OLD_MAN_HEADING, sceneObject:getParentID())
-               end
-               return nil
-       end)
-end
-
--- Read persitent data from the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @param key the key to read the value from.
--- @return the value written on the key.
-function OldManPrivate.getScreenPlayStateFromPlayer(pCreatureObject, key)
-       return ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               return creatureObject:getScreenPlayState(key)
-       end)
-end
-
--- Read transient data from the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @param key the key to read the value from.
--- @return the value written on the key.
-function OldManPrivate.readTransientDataFromThePlayer(pCreatureObject, key)
-       return ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               return readData(creatureObject:getObjectID() .. key)
-       end)
-end
-
--- Read the id of the old man from the player he was spawned for.
--- @param pCreatureObject pointer to the creature object of the player who got the old man spawned.
--- @return the id of the old man stored on the player.
-function OldManPrivate.readOldManIdFromPlayer(pCreatureObject)
-       return OldManPrivate.readTransientDataFromThePlayer(pCreatureObject, OLD_MAN_ID_STRING)
-end
-
--- Write persistent data to the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @param key the key to write the value to.
--- @param value the value to write.
-function OldManPrivate.setScreenPlayStateOnPlayer(pCreatureObject, key, value)
-       ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               creatureObject:setScreenPlayState(value, key)
-       end)
-end
-
--- Clear persistent data to the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @param key the key to clear the value in.
--- @param value the value to clear.
-function OldManPrivate.removeScreenPlayStateOnPlayer(pCreatureObject, key, value)
-       ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               creatureObject:removeScreenPlayState(value, key)
-       end)
-end
-
--- Write transient data to the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @param key the key to write the value to.
--- @param value the value to write.
-function OldManPrivate.writeTransientDataToThePlayer(pCreatureObject, key, value)
-       ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               writeData(creatureObject:getObjectID() .. key, value)
-       end)
-end
-
--- Save the id of the old man to only enable the old man for the player he was spawned for.
--- @param pCreatureObject pointer to the creature object of the player who got the old man spawned.
--- @param pOldMan pointer to the creature object of the spawned old man.
-function OldManPrivate.saveOldManIdOnPlayer(pCreatureObject, pOldMan)
-       ObjectManager.withCreatureObject(pOldMan, function(oldManCreatureObject)
-               OldManPrivate.writeTransientDataToThePlayer(pCreatureObject, OLD_MAN_ID_STRING, oldManCreatureObject:getObjectID())
-       end)
-end
-
--- Check if the player is online.
--- @param pCreatureObject pointer to the creature object of the player who should be checked if online.
--- @return true if the player is online.
-function OldManPrivate.isPlayerOnline(pCreatureObject)
-       return ObjectManager.withCreaturePlayerObject(pCreatureObject, function(playerObject)
-               return playerObject:isOnline()
-       end) == true
-end
-
--- Check if the player is in a building or not.
--- @param pCreatureObject pointer to the creature object of the player that should be checked for being in a building or not.
--- @return true if the player is in a building.
-function OldManPrivate.isPlayerInABuilding(pCreatureObject)
-       return ObjectManager.withSceneObject(pCreatureObject, function(sceneObject)
-               return not (sceneObject:getParentID() == NOTINABUILDING)
-       end) == true
-end
-
--- Check if the player is in a NPC city.
--- @param pCreatureObject pointer to the creature object of the player who should be checked for being in a NPC city.
--- return true if the player is within a NPC city.
-function OldManPrivate.isPlayerInNpcCity(pCreatureObject)
-       return ObjectManager.withSceneObject(pCreatureObject, function(sceneObject)
-               local pCityRegion = getCityRegionAt(sceneObject:getZoneName(), sceneObject:getWorldPositionX(), sceneObject:getWorldPositionY())
-               local inNpcCity = ObjectManager.withCityRegion(pCityRegion, function(cityRegion)
-                       return not cityRegion:isClientRegion()
-               end)
-               return inNpcCity == true
-       end) == true
-end
-
--- Check if the player is in a postion where the old man can be spawned.
--- @param pCreatureObject pointer to the creature object of the player.
--- @return true if the player is in a position where the old man can be spawned.
-function OldManPrivate.canOldManBeSpawned(pCreatureObject)
-       return (OldManPrivate.isPlayerOnline(pCreatureObject) and not OldManPrivate.isPlayerInABuilding(pCreatureObject) and not OldManPrivate.isPlayerInNpcCity(pCreatureObject))
-end
-
--- Set a creature to follow another creature.
--- @param pCreatureObject pointer to the creature who should follow another creature.
--- @param pFollowObject pointer to the creature object of the creature to follow.
-function OldManPrivate.setToFollow(pCreatureObject, pFollowObject)
-       ObjectManager.withCreatureAiAgent(pCreatureObject, function(aiAgent)
-               aiAgent:setFollowObject(pFollowObject)
-       end)
-end
-
--- Function to handle the stop follow player event for the old man.
--- @param pCreatureObject pointer to the creature object of the player who got an old man that should stop following.
-function OldManPublicEventsAndObservers:handleStopFollowPlayerEvent(pCreatureObject)
-       local oldManId = OldManPrivate.readOldManIdFromPlayer(pCreatureObject)
-       local pOldMan = getSceneObject(oldManId)
-       OldManPrivate.setToFollow(pOldMan, nil)
-end
-
--- Get the first name of the player.
--- @param pCreatureObject pointer to the creature object of the player.
--- @return the first name of the player.
-function OldManPrivate.getPlayerFirstName(pCreatureObject)
-       local firstName = ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               return creatureObject:getFirstName()
-       end)
-
-       if firstName == nil then
-               return ""
-       end
-
-       return firstName
-end
-
--- FUnction that sends the greeting string to the player from the old man.
--- @param pOldMan pointer to the creature object of the old man.
--- @param pCreatureObject pointer to the creature object of the player.
-function OldManPrivate.sendGreetingString(pOldMan, pCreatureObject)
-       local greetingString = LuaStringIdChatParameter(OLD_MAN_GREETING_STRING)
-       local firstName = OldManPrivate.getPlayerFirstName(pCreatureObject)
-       greetingString:setTT(firstName)
-       spatialChat(pOldMan, greetingString:_getObject())
-end
-
--- Function to handle the spatial chat event for the old man.
--- @param pCreatureObject pointer to the creature object of the player who got an old man that should say something in spatial chat.
-function OldManPublicEventsAndObservers:handleSpatialChatEvent(pCreatureObject)
-       local oldManId = OldManPrivate.readOldManIdFromPlayer(pCreatureObject)
-       local pOldMan = getSceneObject(oldManId)
-       OldManPrivate.sendGreetingString(pOldMan, pCreatureObject)
-       QuestManager.activateQuest(pCreatureObject, QuestManager.quests.OLD_MAN_INITIAL)
-end
-
--- Despawn the old man.
--- @param pointer to the creature object of the old man.
-function OldManPrivate.despawnOldMan(pOldMan)
-       ObjectManager.withSceneObject(pOldMan, function(sceneObject)
-               sceneObject:destroyObjectFromWorld()
-       end)
-end
-
--- Function to handle the despawn of the old man.
--- @param pCreatureObject pointer to the creature object of the player whos old man should despawn.
-function OldManPublicEventsAndObservers:handleDespawnEvent(pCreatureObject)
-       local oldManId = OldManPrivate.readOldManIdFromPlayer(pCreatureObject)
-       local pOldMan = getSceneObject(oldManId)
-       OldManPrivate.despawnOldMan(pOldMan)
-       OldManPrivate.writeTransientDataToThePlayer(pCreatureObject, OLD_MAN_ID_STRING, OLD_MAN_NO_OLD_MAN_SPAWNED)
-       OldMan.createSpawnOldManEvent(pCreatureObject)
-end
-
--- Schedule despawn of the old man.
--- @param pCreatureObject pointer to the creature object of the player whos old man should be despawned.
--- @param time time until the old man should despawn.
-function OldMan.scheduleDespawnOfOldMan(pCreatureObject, time)
-       createEvent(time, "OldManPublicEventsAndObservers", "handleDespawnEvent", pCreatureObject)
-end
-
--- Try to spawn the old man and create the needed events.
--- @param pCreatureObject pointer to the creature object of the player who should get the old man spawned.
--- @return true if everything were successful.
-function OldManPrivate.tryToSpawnOldMan(pCreatureObject)
-       local pOldMan = OldManPrivate.spawnOldMan(pCreatureObject)
-       if pOldMan ~= nil then
-               OldManPrivate.saveOldManIdOnPlayer(pCreatureObject, pOldMan)
-               OldManPrivate.setToFollow(pOldMan, pCreatureObject)
-               createEvent(OLD_MAN_STOP_FOLLOW_TIME, "OldManPublicEventsAndObservers", "handleStopFollowPlayerEvent", pCreatureObject)
-               createEvent(OLD_MAN_SPATIAL_CHAT_TIME, "OldManPublicEventsAndObservers", "handleSpatialChatEvent", pCreatureObject)
-               OldMan.scheduleDespawnOfOldMan(pCreatureObject, OLD_MAN_DESPAWN_TIME)
-               return true
-       else
-               return false
-       end
-end
-
--- Function to handle the old man event.
--- @param pCreatureObject pointer to the creature object who should have an event created for spawning the old man.
-function OldManPublicEventsAndObservers:handleSpawnOldManEvent(pCreatureObject)
-       OldManPrivate.removeScreenPlayStateOnPlayer(pCreatureObject, OLD_MAN_EVENT_SCHEDULED_STRING, OLD_MAN_SCHEDULED)
-       if OldManPrivate.canOldManBeSpawned(pCreatureObject) then
-               if not OldManPrivate.tryToSpawnOldMan(pCreatureObject) then
-                       OldMan.createSpawnOldManEvent(pCreatureObject)
-               end
-       else
-               OldMan.createSpawnOldManEvent(pCreatureObject)
-       end
-end
-
--- Check if an event has already been scheduled for spawning the old man for this player.
--- @param pCreatureObject pointer to the creature object of the player.
--- return true if an event is already scheduled.
-function OldManPrivate.hasOldManSpawnEventScheduled(pCreatureObject)
-       return OldManPrivate.getScreenPlayStateFromPlayer(pCreatureObject, OLD_MAN_EVENT_SCHEDULED_STRING) == OLD_MAN_SCHEDULED
-end
-
--- Check if the spawn event should be created.
--- @param pCreatureObject pointer to the creature object of the player.
--- @return true if the spawn event should be created.
-function OldManPrivate.shouldSpawnOldManEventBeCreated(pCreatureObject)
-       local eventNotScheduled = not OldManPrivate.hasOldManSpawnEventScheduled(pCreatureObject)
-       local oldManNotSpawned = OldManPrivate.readOldManIdFromPlayer(pCreatureObject) == OLD_MAN_NO_OLD_MAN_SPAWNED
-       local doesNotHaveCrystal = not VillageJediManagerCommon.hasJediProgressionScreenPlayState(pCreatureObject, VILLAGE_JEDI_PROGRESSION_HAS_CRYSTAL)
-       return eventNotScheduled and oldManNotSpawned and doesNotHaveCrystal
-end
-
--- Generate an event to spawn the old man for the player.
--- @param pCreatureObject pointer to the creature object who should have an event created for spawning the old man.
-function OldMan.createSpawnOldManEvent(pCreatureObject)
-       if OldManPrivate.shouldSpawnOldManEventBeCreated(pCreatureObject) then
-               OldManPrivate.setScreenPlayStateOnPlayer(pCreatureObject, OLD_MAN_EVENT_SCHEDULED_STRING, OLD_MAN_SCHEDULED)
-               local time = OLD_MAN_SPAWN_TIME + math.random(OLD_MAN_SPAWN_TIME)
-               createEvent(true, time, "OldManPublicEventsAndObservers", "handleSpawnOldManEvent", pCreatureObject)
-       end
-end
-
--- Check if the old man belongs to the player or not.
--- @param pConversingPlayer pointer to the creature object of the conversing player.
--- @param pConversingNpc pointer to the creature object of the old man.
--- @return true if the old man belongs to the player.
-function OldMan.oldManBelongsToThePlayer(pConversingPlayer, pConversingNpc)
-       return ObjectManager.withCreatureObject(pConversingNpc, function(oldManCreatureObject)
-               return OldManPrivate.readOldManIdFromPlayer(pConversingPlayer) == oldManCreatureObject:getObjectID()
-       end) == true
-end
-
--- Give the force crystal to the player.
--- @param pCreatureObject pointer to the creature object of the player.
-function OldMan.giveForceCrystalToPlayer(pCreatureObject)
-       ObjectManager.withCreatureObject(pCreatureObject, function(creatureObject)
-               local pInventory = creatureObject:getSlottedObject(OLD_MAN_INVENTORY_STRING)
-
-               if pInventory ~= nil then
-                       giveItem(pInventory, OLD_MAN_FORCE_CRYSTAL_STRING, -1)
-                       VillageJediManagerCommon.setJediProgressionScreenPlayState(pCreatureObject, VILLAGE_JEDI_PROGRESSION_HAS_CRYSTAL)
-                       QuestManager.completeQuest(pCreatureObject, QuestManager.quests.OLD_MAN_INITIAL)
-                       QuestManager.completeQuest(pCreatureObject, QuestManager.quests.OLD_MAN_FORCE_CRYSTAL)
-               end
-       end)
-end
-
-return OldMan
diff --git a/MMOCoreORB/bin/scripts/managers/jedi/village/tests/old_man_Test.lua b/MMOCoreORB/bin/scripts/managers/jedi/village/tests/old_man_Test.lua
deleted file mode 100755 (executable)
index 7da3027..0000000
+++ /dev/null
@@ -1,942 +0,0 @@
-BUSTED_TEST = true
-
-local DirectorManagerMocks = require("screenplays.mocks.director_manager_mocks")
-local OldMan = require("managers.jedi.village.old_man")
-local VillageJediManagerCommonMocks = require("managers.jedi.village.mocks.village_jedi_manager_common_mocks")
-local QuestManagerMocks = require("managers.quest.mocks.quest_manager_mocks")
-
-describe("Old Man", function()
-       local pCreatureObject = { "creatureObjectPointer" }
-       local pPlayerObject = { "playerObjectPointer" }
-       local pOldMan = { "oldManPointer" }
-       local pCityRegion = { "cityRegionPointer" }
-       local pGreetingStringId = { "greetingStringIdPointer" }
-       local pPlayerInventory = { "playerInventoryPointer" }
-       local playerId = 12345678
-       local oldManId = 98765432
-       local creatureObjectPlayer
-       local creatureObjectOldMan
-       local playerObject
-       local sceneObjectPlayer
-       local sceneObjectOldMan
-       local playerObject
-       local cityRegion
-       local aiAgent
-       local greetingStringId
-       local playerFirstName = "firstName"
-
-       setup(function()
-               DirectorManagerMocks.mocks.setup()
-               VillageJediManagerCommonMocks.mocks.setup()
-               QuestManagerMocks.mocks.setup()
-
-               OldMan.exposePrivateFunctions()
-       end)
-
-       teardown(function()
-               DirectorManagerMocks.mocks.teardown()
-               VillageJediManagerCommonMocks.mocks.teardown()
-               QuestManagerMocks.mocks.teardown()
-
-               OldMan.hidePrivateFunctions()
-       end)
-
-       before_each(function()
-               DirectorManagerMocks.mocks.before_each()
-               VillageJediManagerCommonMocks.mocks.before_each()
-               QuestManagerMocks.mocks.before_each()
-
-               getCityRegionAt = spy.new(function() return pCityRegion end)
-               getSceneObject = spy.new(function() return pOldMan end)
-               getSpawnPoint = spy.new(function() return { 1, 2, 3 } end)
-               readData = spy.new(function() return oldManId end)
-               spawnMobile = spy.new(function() return pOldMan end)
-
-               creatureObjectPlayer = {}
-               creatureObjectPlayer.getFirstName = spy.new(function() return playerFirstName end)
-               creatureObjectPlayer.getObjectID = spy.new(function() return playerId end)
-               creatureObjectPlayer.getPlayerObject = spy.new(function() return pPlayerObject end)
-               creatureObjectPlayer.getScreenPlayState = spy.new(function() return 0 end)
-               creatureObjectPlayer.setScreenPlayState = spy.new(function() end)
-               creatureObjectPlayer.removeScreenPlayState = spy.new(function() end)
-               creatureObjectPlayer.getSlottedObject = spy.new(function() return pPlayerInventory end)
-               DirectorManagerMocks.creatureObjects[pCreatureObject] = creatureObjectPlayer
-
-               creatureObjectOldMan = {}
-               creatureObjectOldMan.getObjectID = spy.new(function() return oldManId end)
-               DirectorManagerMocks.creatureObjects[pOldMan] = creatureObjectOldMan
-
-               sceneObjectPlayer = {}
-               sceneObjectPlayer.getParentID = spy.new(function() return 0 end)
-               sceneObjectPlayer.getZoneName = spy.new(function() return "testzone" end)
-               sceneObjectPlayer.getWorldPositionX = spy.new(function() return 33 end)
-               sceneObjectPlayer.getWorldPositionY = spy.new(function() return 22 end)
-               DirectorManagerMocks.sceneObjects[pCreatureObject] = sceneObjectPlayer
-
-               sceneObjectOldMan = {}
-               sceneObjectOldMan.destroyObjectFromWorld = spy.new(function() end)
-               DirectorManagerMocks.sceneObjects[pOldMan] = sceneObjectOldMan
-
-               playerObject = {}
-               playerObject.isOnline = spy.new(function() return true end)
-               DirectorManagerMocks.playerObjects[pPlayerObject] = playerObject
-
-               cityRegion = {}
-               cityRegion.isClientRegion = spy.new(function() return false end)
-               DirectorManagerMocks.cityRegions[pCityRegion] = cityRegion
-
-               aiAgent = {}
-               aiAgent.setFollowObject = spy.new(function() end)
-               DirectorManagerMocks.aiAgents[pOldMan] = aiAgent
-
-               greetingStringId = {}
-               greetingStringId._getObject = spy.new(function() return pGreetingStringId end)
-               greetingStringId.setTT = spy.new(function(object, string) assert.same(string, playerFirstName) end)
-               DirectorManagerMocks.stringIds[OLD_MAN_GREETING_STRING] = greetingStringId
-       end)
-
-       describe("Interface methods", function()
-               describe("createSpawnOldManEvent", function()
-                       describe("When called with a player as argument", function()
-                               local realHasOldManSpawnEventScheduled
-                               local realReadOldManIdFromPlayer
-
-                               setup(function()
-                                       realHasOldManSpawnEventScheduled = OldMan.private.hasOldManSpawnEventScheduled
-                                       realReadOldManIdFromPlayer = OldMan.private.readOldManIdFromPlayer
-                               end)
-
-                               teardown(function()
-                                       OldMan.private.hasOldManSpawnEventScheduled = realHasOldManSpawnEventScheduled
-                                       OldMan.private.readOldManIdFromPlayer = realReadOldManIdFromPlayer
-                               end)
-
-                               before_each(function()
-                                       OldMan.private.hasOldManSpawnEventScheduled = spy.new(function() return false end)
-                                       OldMan.private.readOldManIdFromPlayer = spy.new(function() return OLD_MAN_NO_OLD_MAN_SPAWNED end)
-                               end)
-
-                               it("Should check if the player has an event already scheduled.", function()
-                                       OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.hasOldManSpawnEventScheduled).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should check if the player has an old man already spawned.", function()
-                                       OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.readOldManIdFromPlayer).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should check if the player already has the crystal.", function()
-                                       OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(VillageJediManagerCommonMocks.hasJediProgressionScreenPlayState).was.called_with(pCreatureObject, VILLAGE_JEDI_PROGRESSION_HAS_CRYSTAL)
-                               end)
-
-                               describe("and no event is scheduled, no old man has been spawned and the player does not have the crystal.", function()
-                                       it("Should create an event for spawning the old man", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(createEvent).was.called(1)
-                                       end)
-
-                                       it("Should save information about event being scheduled on the player", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(creatureObjectPlayer.setScreenPlayState).was.called_with(creatureObjectPlayer, OLD_MAN_SCHEDULED, OLD_MAN_EVENT_SCHEDULED_STRING)
-                                       end)
-                               end)
-
-                               describe("and an event is already scheduled", function()
-                                       before_each(function()
-                                               OldMan.private.hasOldManSpawnEventScheduled = spy.new(function() return true end)
-                                       end)
-
-                                       it("Should not create an event for spawning the old man.", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(createEvent).was.not_called()
-                                       end)
-
-                                       it("Should not save information about event being scheduled on the player", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(creatureObjectPlayer.setScreenPlayState).was.not_called()
-                                       end)
-                               end)
-
-                               describe("and an old man has already been spawned", function()
-                                       before_each(function()
-                                               OldMan.private.readOldManIdFromPlayer = spy.new(function() return oldManId end)
-                                       end)
-
-                                       it("Should not create an event for spawning the old man.", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(createEvent).was.not_called()
-                                       end)
-
-                                       it("Should not save information about event being scheduled on the player", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(creatureObjectPlayer.setScreenPlayState).was.not_called()
-                                       end)
-                               end)
-
-                               describe("and the player has already gotten the crystal", function()
-                                       before_each(function()
-                                               VillageJediManagerCommonMocks.hasJediProgressionScreenPlayState = spy.new(function() return true end)
-                                       end)
-
-                                       it("Should not create an event for spawning the old man.", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(createEvent).was.not_called()
-                                       end)
-
-                                       it("Should not save information about event being scheduled on the player", function()
-                                               OldMan.createSpawnOldManEvent(pCreatureObject)
-
-                                               assert.spy(creatureObjectPlayer.setScreenPlayState).was.not_called()
-                                       end)
-                               end)
-                       end)
-               end)
-
-               describe("oldManBelongsToThePlayer", function()
-                       describe("When called with a player and his old man", function()
-                               it("Should return true", function()
-                                       assert.is_true(OldMan.oldManBelongsToThePlayer(pCreatureObject, pOldMan))
-
-                                       assert.spy(LuaCreatureObject).was.called(2)
-                                       assert.spy(creatureObjectPlayer.getObjectID).was.called(1)
-                                       assert.spy(creatureObjectOldMan.getObjectID).was.called(1)
-                                       assert.spy(readData).was.called_with(playerId .. OLD_MAN_ID_STRING)
-                               end)
-                       end)
-
-                       describe("When called with a player and an old man of another player", function()
-                               it("Should return false", function()
-                                       readData = spy.new(function() return 0 end)
-
-                                       assert.is_false(OldMan.oldManBelongsToThePlayer(pCreatureObject, pOldMan))
-
-                                       assert.spy(LuaCreatureObject).was.called(2)
-                                       assert.spy(creatureObjectPlayer.getObjectID).was.called(1)
-                                       assert.spy(creatureObjectOldMan.getObjectID).was.called(1)
-                                       assert.spy(readData).was.called_with(playerId .. OLD_MAN_ID_STRING)
-                               end)
-                       end)
-               end)
-
-               describe("scheduleDespawnOfOldMan", function()
-                       describe("When called with a player and a time", function()
-                               it("Should create an event to despawn the old man.", function()
-                                       OldMan.scheduleDespawnOfOldMan(pCreatureObject, OLD_MAN_DESPAWN_TIME)
-
-                                       assert.spy(createEvent).was.called_with(OLD_MAN_DESPAWN_TIME, "OldManPublicEventsAndObservers", "handleDespawnEvent", pCreatureObject)
-                               end)
-                       end)
-               end)
-
-               describe("giveForceCrystalToPlayer", function()
-                       describe("When called with a player as argument", function()
-                               it("Should get the inventory of the player.", function()
-                                       OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                       assert.spy(creatureObjectPlayer.getSlottedObject).was.called_with(creatureObjectPlayer, OLD_MAN_INVENTORY_STRING)
-                               end)
-
-                               describe("and the inventory pointer return is not nil", function()
-                                       it("Should give the player a force crystal.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(giveItem).was.called_with(pPlayerInventory, OLD_MAN_FORCE_CRYSTAL_STRING, -1)
-                                       end)
-
-                                       it("Should update the village jedi progression state on the player.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(VillageJediManagerCommonMocks.setJediProgressionScreenPlayState).was.called_with(pCreatureObject, VILLAGE_JEDI_PROGRESSION_HAS_CRYSTAL)
-                                       end)
-
-                                       it("Should complete the old man initial and the old man force crystal quests.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(QuestManagerMocks.completeQuest).was.called(2)
-                                       end)
-                               end)
-
-                               describe("and the inventory pointer return is not nil", function()
-                                       before_each(function()
-                                               creatureObjectPlayer.getSlottedObject = spy.new(function() return nil end)
-                                       end)
-
-                                       it("Should not give the player a force crystal.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(giveItem).was.not_called()
-                                       end)
-
-                                       it("Should not update the village jedi progression state on the player.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(VillageJediManagerCommonMocks.setJediProgressionScreenPlayState).was.not_called()
-                                       end)
-
-                                       it("Should not complete the old man initial and the old man force crystal quests.", function()
-                                               OldMan.giveForceCrystalToPlayer(pCreatureObject)
-
-                                               assert.spy(QuestManagerMocks.completeQuest).was.not_called()
-                                       end)
-                               end)
-                       end)
-               end)
-       end)
-
-       describe("Events", function()
-               describe("handleSpawnOldManEvent", function()
-                       describe("When event to spawn old man is triggered", function()
-                               local realCanOldManBeSpawned
-                               local realTryToSpawnOldMan
-                               local realCreateSpawnOldManEvent
-                               local realSaveOldManIdOnPlayer
-
-                               setup(function()
-                                       realCanOldManBeSpawned = OldMan.private.canOldManBeSpawned
-                                       realTryToSpawnOldMan = OldMan.private.tryToSpawnOldMan
-                                       realCreateSpawnOldManEvent = OldMan.createSpawnOldManEvent
-                                       realSaveOldManIdOnPlayer = OldMan.private.saveOldManIdOnPlayer
-                               end)
-
-                               teardown(function()
-                                       OldMan.private.canOldManBeSpawned = realCanOldManBeSpawned
-                                       OldMan.private.tryToSpawnOldMan = realTryToSpawnOldMan
-                                       OldMan.createSpawnOldManEvent = realCreateSpawnOldManEvent
-                                       OldMan.private.saveOldManIdOnPlayer = realSaveOldManIdOnPlayer
-                               end)
-
-                               before_each(function()
-                                       OldMan.private.canOldManBeSpawned = spy.new(function() return true end)
-                                       OldMan.private.tryToSpawnOldMan = spy.new(function() return true end)
-                                       OldMan.createSpawnOldManEvent = spy.new(function() end)
-                                       OldMan.private.saveOldManIdOnPlayer = spy.new(function() end)
-                               end)
-
-                               it("Should reset screen play state about old man being scheduled.", function()
-                                       OldMan.global:handleSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(creatureObjectPlayer.removeScreenPlayState).was.called_with(creatureObjectPlayer, OLD_MAN_SCHEDULED, OLD_MAN_EVENT_SCHEDULED_STRING)
-                               end)
-
-                               it("Should try to spawn the old man if the player is in a place where the old man can be spawned.", function()
-                                       OldMan.global:handleSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.canOldManBeSpawned).was.called_with(pCreatureObject)
-                                       assert.spy(OldMan.private.tryToSpawnOldMan).was.called_with(pCreatureObject)
-                                       assert.spy(OldMan.createSpawnOldManEvent).was.not_called()
-                               end)
-
-                               it("Should reschedule the event if the player is not in a place where the old man can be spawned.", function()
-                                       OldMan.private.canOldManBeSpawned = spy.new(function() return false end)
-
-                                       OldMan.global:handleSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.canOldManBeSpawned).was.called_with(pCreatureObject)
-                                       assert.spy(OldMan.private.tryToSpawnOldMan).was.not_called()
-                                       assert.spy(OldMan.createSpawnOldManEvent).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should reschedule the event if the spawning of the old man fails.", function()
-                                       OldMan.private.tryToSpawnOldMan = spy.new(function() return false end)
-
-                                       OldMan.global:handleSpawnOldManEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.canOldManBeSpawned).was.called_with(pCreatureObject)
-                                       assert.spy(OldMan.private.tryToSpawnOldMan).was.called_with(pCreatureObject)
-                                       assert.spy(OldMan.createSpawnOldManEvent).was.called_with(pCreatureObject)
-                               end)
-                       end)
-               end)
-
-               describe("handleStopFollowPlayerEvent", function()
-                       local realSetToFollow
-                       local realReadOldManIdFromPlayer
-
-                       setup(function()
-                               realSetToFollow = OldMan.private.setToFollow
-                               realReadOldManIdFromPlayer = OldMan.private.readOldManIdFromPlayer
-                       end)
-
-                       teardown(function()
-                               OldMan.private.setToFollow = realSetToFollow
-                               OldMan.private.readOldManIdFromPlayer = realReadOldManIdFromPlayer
-                       end)
-
-                       before_each(function()
-                               OldMan.private.setToFollow = spy.new(function() end)
-                               OldMan.private.readOldManIdFromPlayer = spy.new(function() return oldManId end)
-                       end)
-
-                       describe("When called with the player as argument", function()
-                               it("Should read the old man id from the player.", function()
-                                       OldMan.global:handleStopFollowPlayerEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.readOldManIdFromPlayer).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should get a pointer to the old man.", function()
-                                       OldMan.global:handleStopFollowPlayerEvent(pCreatureObject)
-
-                                       assert.spy(getSceneObject).was.called_with(oldManId)
-                               end)
-
-                               it("Should tell the old man to follow no one.", function()
-                                       OldMan.global:handleStopFollowPlayerEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.setToFollow).was.called_with(pOldMan, nil)
-                               end)
-                       end)
-               end)
-
-               describe("handleSpatialChatEvent", function()
-                       local realSendGreetingString
-                       local realReadOldManIdFromPlayer
-
-                       setup(function()
-                               realSendGreetingString = OldMan.private.sendGreetingString
-                               realReadOldManIdFromPlayer = OldMan.private.readOldManIdFromPlayer
-                       end)
-
-                       teardown(function()
-                               OldMan.private.sendGreetingString = realSendGreetingString
-                               OldMan.private.readOldManIdFromPlayer = realReadOldManIdFromPlayer
-                       end)
-
-                       before_each(function()
-                               OldMan.private.sendGreetingString = spy.new(function() end)
-                               OldMan.private.readOldManIdFromPlayer = spy.new(function() return oldManId end)
-                       end)
-
-                       describe("When called with the player as argument", function()
-                               it("Should read the old man id from the player.", function()
-                                       OldMan.global:handleSpatialChatEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.readOldManIdFromPlayer).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should get a pointer to the old man.", function()
-                                       OldMan.global:handleSpatialChatEvent(pCreatureObject)
-
-                                       assert.spy(getSceneObject).was.called_with(oldManId)
-                               end)
-
-                               it("Should send the greeting string.", function()
-                                       OldMan.global:handleSpatialChatEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.sendGreetingString).was.called_with(pOldMan, pCreatureObject)
-                               end)
-
-                               it("Should activate the OLD_MAN_INITIAL quest", function()
-                                       OldMan.global:handleSpatialChatEvent(pCreatureObject)
-
-                                       assert.spy(QuestManagerMocks.activateQuest).was.called_with(pCreatureObject, QuestManagerMocks.quests.OLD_MAN_INITIAL)
-                               end)
-                       end)
-               end)
-
-               describe("handleDespawnEvent", function()
-                       local realDespawnOldMan
-                       local realReadOldManIdFromPlayer
-                       local realCreateSpawnOldManEvent
-
-                       setup(function()
-                               realDespawnOldMan = OldMan.private.despawnOldMan
-                               realReadOldManIdFromPlayer = OldMan.private.readOldManIdFromPlayer
-                               realCreateSpawnOldManEvent = OldMan.createSpawnOldManEvent
-                       end)
-
-                       teardown(function()
-                               OldMan.private.despawnOldMan = realDespawnOldMan
-                               OldMan.private.readOldManIdFromPlayer = realReadOldManIdFromPlayer
-                               OldMan.createSpawnOldManEvent = realCreateSpawnOldManEvent
-                       end)
-
-                       before_each(function()
-                               OldMan.private.despawnOldMan = spy.new(function() end)
-                               OldMan.private.readOldManIdFromPlayer = spy.new(function() return oldManId end)
-                               OldMan.createSpawnOldManEvent = spy.new(function() end)
-                       end)
-
-                       describe("When called with the player as argument", function()
-                               it("Should read the old man id from the player.", function()
-                                       OldMan.global:handleDespawnEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.readOldManIdFromPlayer).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should get a pointer to the old man.", function()
-                                       OldMan.global:handleDespawnEvent(pCreatureObject)
-
-                                       assert.spy(getSceneObject).was.called_with(oldManId)
-                               end)
-
-                               it("Should despawn the old man.", function()
-                                       OldMan.global:handleDespawnEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.private.despawnOldMan).was.called_with(pOldMan)
-                               end)
-
-                               it("Should set the id of the spawned old man to 0 to indicate that he is despawned.", function()
-                                       OldMan.global:handleDespawnEvent(pCreatureObject)
-
-                                       assert.spy(writeData).was.called_with(playerId .. OLD_MAN_ID_STRING, OLD_MAN_NO_OLD_MAN_SPAWNED)
-                               end)
-
-                               it("Should reschedule the old man.", function()
-                                       OldMan.global:handleDespawnEvent(pCreatureObject)
-
-                                       assert.spy(OldMan.createSpawnOldManEvent).was.called_with(pCreatureObject)
-                               end)
-                       end)
-               end)
-       end)
-
-       describe("Private methods", function()
-               describe("canOldManBeSpawned", function()
-                       describe("When called with a creature object as argument", function()
-                               local realIsPlayerOnline
-                               local realIsPlayerInNpcCity
-                               local realIsPlayerInABuilding
-
-                               setup(function()
-                                       realIsPlayerOnline = OldMan.private.isPlayerOnline
-                                       realIsPlayerInNpcCity = OldMan.private.isPlayerInNpcCity
-                                       realIsPlayerInABuilding = OldMan.private.isPlayerInABuilding
-                               end)
-
-                               teardown(function()
-                                       OldMan.private.isPlayerOnline = realIsPlayerOnline
-                                       OldMan.private.isPlayerInNpcCity = realIsPlayerInNpcCity
-                                       OldMan.private.isPlayerInABuilding = realIsPlayerInABuilding
-                               end)
-
-                               before_each(function()
-                                       OldMan.private.isPlayerOnline = spy.new(function() return true end)
-                                       OldMan.private.isPlayerInNpcCity = spy.new(function() return false end)
-                                       OldMan.private.isPlayerInABuilding = spy.new(function() return false end)
-                               end)
-
-                               describe("and the player is outside, not in an npc city and online.", function()
-                                       it("Should return true.", function()
-                                               assert.is_true(OldMan.private.canOldManBeSpawned(pCreatureObject))
-                                       end)
-                               end)
-
-                               describe("and the player is offline", function()
-                                       it("Should return false.", function()
-                                               OldMan.private.isPlayerOnline = spy.new(function() return false end)
-
-                                               assert.is_false(OldMan.private.canOldManBeSpawned(pCreatureObject))
-                                       end)
-                               end)
-
-                               describe("and the player is in a NPC city", function()
-                                       it("Should return false.", function()
-                                               OldMan.private.isPlayerInNpcCity = spy.new(function() return true end)
-
-                                               assert.is_false(OldMan.private.canOldManBeSpawned(pCreatureObject))
-                                       end)
-                               end)
-
-                               describe("and the player is inside a building", function()
-                                       it("Should return false.", function()
-                                               OldMan.private.isPlayerInABuilding = spy.new(function() return true end)
-
-                                               assert.is_false(OldMan.private.canOldManBeSpawned(pCreatureObject))
-                                       end)
-                               end)
-                       end)
-               end)
-
-               describe("isPlayerOnline", function()
-                       describe("When called with a creature object pointer", function()
-                               it("Should return true if the player is online.", function()
-                                       playerObject.isOnline = spy.new(function() return true end)
-
-                                       assert.is_true(OldMan.private.isPlayerOnline(pCreatureObject))
-
-                                       assert.spy(LuaCreatureObject).was.called_with(pCreatureObject)
-                                       assert.spy(LuaPlayerObject).was.called_with(pPlayerObject)
-                                       assert.spy(playerObject.isOnline).was.called(1)
-                               end)
-
-                               it("Should return false if the player is offline.", function()
-                                       playerObject.isOnline = spy.new(function() return false end)
-
-                                       assert.is_false(OldMan.private.isPlayerOnline(pCreatureObject))
-
-                                       assert.spy(LuaCreatureObject).was.called_with(pCreatureObject)
-                                       assert.spy(LuaPlayerObject).was.called_with(pPlayerObject)
-                                       assert.spy(playerObject.isOnline).was.called(1)
-                               end)
-                       end)
-
-                       describe("When called with nil as argument", function()
-                               it("Should return false.", function()
-                                       assert.is_false(OldMan.private.isPlayerOnline(nil))
-                               end)
-                       end)
-               end)
-
-               describe("isPlayerInABuilding", function()
-                       describe("When called with a creature object pointer", function()
-                               it("Should return true if the parent id of the player is not equal to 0", function()
-                                       sceneObjectPlayer.getParentID = spy.new(function() return 1 end)
-
-                                       assert.is_true(OldMan.private.isPlayerInABuilding(pCreatureObject))
-
-                                       assert.spy(LuaSceneObject).was.called(1)
-                                       assert.spy(sceneObjectPlayer.getParentID).was.called(1)
-                               end)
-
-                               it("Should return false if the parent id of the player is equal to 0", function()
-                                       sceneObjectPlayer.getParentID = spy.new(function() return 0 end)
-
-                                       assert.is_false(OldMan.private.isPlayerInABuilding(pCreatureObject))
-
-                                       assert.spy(LuaSceneObject).was.called(1)
-                                       assert.spy(sceneObjectPlayer.getParentID).was.called(1)
-                               end)
-                       end)
-
-                       describe("When called with nil as argument", function()
-                               it("Should return false.", function()
-                                       assert.is_false(OldMan.private.isPlayerInABuilding(nil))
-                               end)
-                       end)
-               end)
-
-               describe("isPlayerInNpcCity", function()
-                       describe("When called with a nil pointer", function()
-                               it("Should return false", function()
-                                       assert.is_false(OldMan.private.isPlayerInNpcCity(nil))
-                               end)
-                       end)
-
-                       describe("When called with a creature object pointer", function()
-                               after_each(function()
-                                       assert.spy(sceneObjectPlayer.getZoneName).was.called(1)
-                                       assert.spy(sceneObjectPlayer.getWorldPositionX).was.called(1)
-                                       assert.spy(sceneObjectPlayer.getWorldPositionY).was.called(1)
-                                       assert.spy(LuaSceneObject).was.called(1)
-                                       assert.spy(getCityRegionAt).was.called_with("testzone", 33, 22)
-                               end)
-
-                               describe("and player is in no region", function()
-                                       it("Should return false.", function()
-                                               getCityRegionAt = spy.new(function() return nil end)
-
-                                               assert.is_false(OldMan.private.isPlayerInNpcCity(pCreatureObject))
-                                       end)
-                               end)
-
-                               describe("and the player is in city region", function()
-                                       it("Should return true if the city region belongs to a NPC city.", function()
-                                               cityRegion.isClientRegion = spy.new(function() return false end)
-
-                                               assert.is_true(OldMan.private.isPlayerInNpcCity(pCreatureObject))
-
-                                               assert.spy(LuaCityRegion).was.called(1)
-                                       end)
-
-                                       it("Should return false if the city region belongs to a player city.", function()
-                                               cityRegion.isClientRegion = spy.new(function() return true end)
-
-                                               assert.is_false(OldMan.private.isPlayerInNpcCity(pCreatureObject))
-
-                                               assert.spy(LuaCityRegion).was.called(1)
-                                       end)
-                               end)
-                       end)
-               end)
-
-               describe("spawnOldMan", function()
-                       after_each(function()
-                               assert.spy(sceneObjectPlayer.getWorldPositionX).was.called(1)
-                               assert.spy(sceneObjectPlayer.getWorldPositionY).was.called(1)
-                               assert.spy(LuaSceneObject).was.called(1)
-                       end)
-
-                       describe("When called with a creature object pointer", function()
-                               it("Should get a spawn point for the old man.", function()
-                                       OldMan.private.spawnOldMan(pCreatureObject)
-
-                                       assert.spy(getSpawnPoint).was.called_with(pCreatureObject, 33, 22, OLD_MAN_MIN_SPAWN_DISTANCE, OLD_MAN_MAX_SPAWN_DISTANCE)
-                               end)
-
-                               describe("and a spawn point is returned", function()
-                                       it("Should spawn the old man.", function()
-                                               OldMan.private.spawnOldMan(pCreatureObject)
-
-                                               assert.spy(sceneObjectPlayer.getZoneName).was.called(1)
-                                               assert.spy(sceneObjectPlayer.getParentID).was.called(1)
-                                               assert.spy(spawnMobile).was.called_with("testzone", OLD_MAN_TEMPLATE, OLD_MAN_RESPAWN_TIME, 1, 2, 3, OLD_MAN_HEADING, 0)
-                                       end)
-
-                                       it("Should return a pointer to the spawned old man.", function()
-                                               assert.same(OldMan.private.spawnOldMan(pCreatureObject), pOldMan)
-                                       end)
-                               end)
-
-                               describe("and no spawn point is returned", function()
-                                       before_each(function()
-                                               getSpawnPoint = spy.new(function() return nil end)
-                                       end)
-
-                                       it("Should not spawn the old man.", function()
-                                               OldMan.private.spawnOldMan(pCreatureObject)
-
-                                               assert.spy(sceneObjectPlayer.getZoneName).was.not_called()
-                                               assert.spy(sceneObjectPlayer.getParentID).was.not_called()
-                                               assert.spy(spawnMobile).was.not_called()
-                                       end)
-
-                                       it("Should return nil.", function()
-                                               assert.is_nil(OldMan.private.spawnOldMan(pCreatureObject))
-                                       end)
-                               end)
-                       end)
-               end)
-
-               describe("saveOldManIdOnPlayer", function()
-                       describe("When called with player and old man", function()
-                               it("Should store the object id of the old man on the player.", function()
-                                       OldMan.private.saveOldManIdOnPlayer(pCreatureObject, pOldMan)
-
-                                       assert.spy(writeData).was.called_with(playerId .. OLD_MAN_ID_STRING, oldManId)
-                                       assert.spy(LuaCreatureObject).was.called(2)
-                                       assert.spy(creatureObjectPlayer.getObjectID).was.called(1)
-                                       assert.spy(creatureObjectOldMan.getObjectID).was.called(1)
-                               end)
-                       end)
-               end)
-
-               describe("tryToSpawnOldMan", function()
-                       describe("When called with a player creature object", function()
-                               local realSpawnOldMan
-                               local realSaveOldManIdOnPlayer
-                               local realSetToFollow
-
-                               setup(function()
-                                       realSpawnOldMan = OldMan.private.spawnOldMan
-                                       realSaveOldManIdOnPlayer = OldMan.private.saveOldManIdOnPlayer
-                                       realSetToFollow = OldMan.private.setToFollow
-                               end)
-
-                               teardown(function()
-                                       OldMan.private.spawnOldMan = realSpawnOldMan
-                                       OldMan.private.saveOldManIdOnPlayer = realSaveOldManIdOnPlayer
-                                       OldMan.private.setToFollow = realSetToFollow
-                               end)
-
-                               before_each(function()
-                                       OldMan.private.spawnOldMan = spy.new(function() end)
-                                       OldMan.private.saveOldManIdOnPlayer = spy.new(function() end)
-                                       OldMan.private.setToFollow = spy.new(function() end)
-                               end)
-
-                               it("Should spawn the old man.", function()
-                                       OldMan.private.tryToSpawnOldMan(pCreatureObject)
-
-                                       assert.spy(OldMan.private.spawnOldMan).was.called_with(pCreatureObject)
-                               end)
-
-                               describe("and spawning the old man was successful", function()
-                                       before_each(function()
-                                               OldMan.private.spawnOldMan = spy.new(function() return pOldMan end)
-                                       end)
-
-                                       it("Should save the id of the old man on the player.", function()
-                                               OldMan.private.tryToSpawnOldMan(pCreatureObject)
-
-                                               assert.spy(OldMan.private.saveOldManIdOnPlayer).was.called_with(pCreatureObject, pOldMan)
-                                       end)
-
-                                       it("Should return true.", function()
-                                               assert.is_true(OldMan.private.tryToSpawnOldMan(pCreatureObject))
-                                       end)
-
-                                       it("Should set the old man to follow the player.", function()
-                                               OldMan.private.tryToSpawnOldMan(pCreatureObject)
-
-                                               assert.spy(OldMan.private.setToFollow).was.called_with(pOldMan, pCreatureObject)
-                                       end)
-
-                                       it("Should create events for the old man to send greeting string, to stop follow the player and for despawning.", function()
-                                               OldMan.private.tryToSpawnOldMan(pCreatureObject)
-
-                                               assert.spy(createEvent).was.called(3)
-                                       end)
-                               end)
-
-                               describe("and spawning the old man failed", function()
-                                       before_each(function()
-                                               OldMan.private.spawnOldMan = spy.new(function() return nil end)
-                                       end)
-
-                                       it("Should not save the id of the old man on the player, not make the old man follow the player nor create an event.", function()
-                                               OldMan.private.tryToSpawnOldMan(pCreatureObject)
-                                               assert.spy(OldMan.private.saveOldManIdOnPlayer).was.not_called()
-                                               assert.spy(OldMan.private.setToFollow).was.not_called()
-                                               assert.spy(createEvent).was.not_called()
-                                       end)
-
-                                       it("Should return false.", function()
-                                               assert.is_false(OldMan.private.tryToSpawnOldMan(pCreatureObject))
-                                       end)
-                               end)
-                       end)
-               end)
-
-               describe("setToFollow", function()
-                       describe("When called with a old man and a player", function()
-                               it("Should set the old man to follow the player", function()
-                                       OldMan.private.setToFollow(pOldMan, pCreatureObject)
-
-                                       assert.spy(aiAgent.setFollowObject).was.called_with(aiAgent, pCreatureObject)
-                               end)
-                       end)
-
-                       describe("When called with old man argument equal to nil", function()
-                               it("Should not do anything.", function()
-                                       OldMan.private.setToFollow(nil, pCreatureObject)
-
-                                       assert.spy(aiAgent.setFollowObject).was.not_called()
-                               end)
-                       end)
-
-                       describe("When called with player argument equal to nil", function()
-                               it("Should not do anything.", function()
-                                       OldMan.private.setToFollow(pOldMan, nil)
-
-                                       assert.spy(aiAgent.setFollowObject).was.called_with(aiAgent, nil)
-                               end)
-                       end)
-               end)
-
-               describe("readOldManIdFromPlayer", function()
-                       describe("When called with a pointer to a creature object of a player as argument", function()
-                               it("Should read the old man id from the player.", function()
-                                       OldMan.private.readOldManIdFromPlayer(pCreatureObject)
-
-                                       assert.spy(readData).was.called_with(playerId .. OLD_MAN_ID_STRING)
-                                       assert.spy(LuaCreatureObject).was.called(1)
-                                       assert.spy(creatureObjectPlayer.getObjectID).was.called(1)
-                               end)
-                       end)
-               end)
-
-               describe("sendGreetingString", function()
-                       describe("When called with old man and player", function()
-                               local realGetPlayerFirstName
-
-                               setup(function()
-                                       realGetPlayerFirstName = OldMan.private.getPlayerFirstName
-                               end)
-
-                               teardown(function()
-                                       OldMan.private.getPlayerFirstName = realGetPlayerFirstName
-                               end)
-
-                               before_each(function()
-                                       OldMan.private.getPlayerFirstName = spy.new(function() return playerFirstName end)
-                               end)
-
-                               it("Should create a string id for the oldman_greeting string.", function()
-                                       OldMan.private.sendGreetingString(pOldMan, pCreatureObject)
-
-                                       assert.spy(LuaStringIdChatParameter).was.called_with(OLD_MAN_GREETING_STRING)
-                               end)
-
-                               it("Should get the name of the player.", function()
-                                       OldMan.private.sendGreetingString(pOldMan, pCreatureObject)
-
-                                       assert.spy(OldMan.private.getPlayerFirstName).was.called_with(pCreatureObject)
-                               end)
-
-                               it("Should set the %TT of the string to the name of the player.", function()
-                                       OldMan.private.sendGreetingString(pOldMan, pCreatureObject)
-
-                                       assert.spy(greetingStringId.setTT).was.called(1)
-                               end)
-
-                               it("Should send the string id to spatial chat.", function()
-                                       OldMan.private.sendGreetingString(pOldMan, pCreatureObject)
-
-                                       assert.spy(spatialChat).was.called_with(pOldMan, pGreetingStringId)
-                               end)
-                       end)
-               end)
-
-               describe("getPlayerFirstName", function()
-                       describe("When called with a player", function()
-                               it("Should return the first name of the player.", function()
-                                       assert.same(OldMan.private.getPlayerFirstName(pCreatureObject), playerFirstName)
-
-                                       assert.spy(creatureObjectPlayer.getFirstName).was.called(1)
-                               end)
-                       end)
-                       describe("When called with nil", function()
-                               it("Should return an empty string.", function()
-                                       assert.same(OldMan.private.getPlayerFirstName(nil), "")
-                               end)
-                       end)
-               end)
-
-               describe("despawnOldMan", function()
-                       describe("When called with an old man as argument", function()
-                               it("Should destroy the old man from the world.", function()
-                                       OldMan.private.despawnOldMan(pOldMan)
-
-                                       assert.spy(sceneObjectOldMan.destroyObjectFromWorld).was.called(1)
-                               end)
-                       end)
-
-                       describe("When called with nil as argument", function()
-                               it("Should not try to destroy the old man from the world.", function()
-                                       OldMan.private.despawnOldMan(nil)
-
-                                       assert.spy(sceneObjectOldMan.destroyObjectFromWorld).was.not_called()
-                               end)
-                       end)
-               end)
-
-               describe("hasOldManSpawnEventScheduled", function()
-                       describe("When called with a player as argument", function()
-                               it("Should read the event scheduled information from the player.", function()
-                                       OldMan.private.hasOldManSpawnEventScheduled(pCreatureObject)
-
-                                       assert.spy(creatureObjectPlayer.getScreenPlayState).was.called_with(creatureObjectPlayer, OLD_MAN_EVENT_SCHEDULED_STRING)
-                               end)
-
-                               describe("and the data stored on the player indicates that the event is scheduled", function()
-                                       it("Should return true.", function()
-                                               creatureObjectPlayer.getScreenPlayState = spy.new(function() return OLD_MAN_SCHEDULED end)
-
-                                               assert.is_true(OldMan.private.hasOldManSpawnEventScheduled(pCreatureObject))
-                                       end)
-                               end)
-
-                               describe("and the data stored on the player indicates that the event is not scheduled", function()
-                                       it("Should return false.", function()
-                                               creatureObjectPlayer.getScreenPlayState = spy.new(function() return OLD_MAN_NOT_SCHEDULED end)
-
-                                               assert.is_false(OldMan.private.hasOldManSpawnEventScheduled(pCreatureObject))
-                                       end)
-                               end)
-                       end)
-               end)
-       end)
-end)
index c232e89..f6b72a3 100755 (executable)
@@ -1,6 +1,5 @@
 local DirectorManagerMocks = require("screenplays.mocks.director_manager_mocks")
 local GlowingMocks = require("managers.jedi.village.mocks.glowing_mocks")
-local OldManMocks = require("managers.jedi.village.mocks.old_man_mocks")
 local VillageJediManager = require("managers.jedi.village.village_jedi_manager")
 local VillageJediManagerHolocronMocks = require("managers.jedi.village.mocks.village_jedi_manager_holocron_mocks")
 
@@ -14,21 +13,18 @@ describe("Village Jedi Manager", function()
        setup(function()
                DirectorManagerMocks.mocks.setup()
                GlowingMocks.mocks.setup()
-               OldManMocks.mocks.setup()
                VillageJediManagerHolocronMocks.setup()
        end)
 
        teardown(function()
                DirectorManagerMocks.mocks.teardown()
                GlowingMocks.mocks.teardown()
-               OldManMocks.mocks.teardown()
                VillageJediManagerHolocronMocks.teardown()
        end)
 
        before_each(function()
                DirectorManagerMocks.mocks.before_each()
                GlowingMocks.mocks.before_each()
-               OldManMocks.mocks.before_each()
                VillageJediManagerHolocronMocks.before_each()
 
                creatureObject = {}