Instructions Jenkins Doxygen

[Added] withActiveArea method to Object Manager in lua. 70/1470/1
authorLoshult <loshult@swgemu.com>
Sun, 9 Mar 2014 06:19:11 +0000 (06:19 +0000)
committerLoshult <loshult@swgemu.com>
Sun, 9 Mar 2014 06:30:50 +0000 (06:30 +0000)
Change-Id: I14e4c78903d840e5478cbc2514c55f662eb634cb

MMOCoreORB/bin/scripts/managers/object/object_manager.lua
MMOCoreORB/bin/scripts/managers/object/tests/object_manager_Test.lua
MMOCoreORB/bin/scripts/screenplays/mocks/director_manager_mocks.lua

index 30e3618..808639b 100644 (file)
@@ -116,4 +116,16 @@ function ObjectManager.withSceneObjectFromId(objectId, performThisFunction)
        return ObjectManager.withSceneObject(getSceneObject(objectId), performThisFunction)
 end
 
+-- Perform the supplied function with an active area.
+-- @param pActiveArea pointer to the active area.
+-- @param performThisFunction a function that takes an active area as argument.
+-- @return whatever performThisFunction returns or nil if the pActiveArea is nil.
+function ObjectManager.withActiveArea(pActiveArea, performThisFunction)
+       if pActiveArea == nil then
+               return nil
+       end
+       local activeArea = LuaActiveArea(pActiveArea)
+       return performThisFunction(activeArea)
+end
+
 return ObjectManager
index 2e97953..03659c6 100644 (file)
@@ -8,12 +8,14 @@ describe("Object Manager", function()
        local pPlayerObject = { "playerObjectPointer" }
        local pSceneObject = { "sceneObjectPointer" }
        local pCityRegion = { "cityRegionPointer" }
+       local pActiveArea = { "activeAreaPointer" }
        local aiAgent = { "aiAgent" }
        local sceneObject = { "sceneObject" }
        local creatureObject = { "creatureObject" }
        local playerObject = { "playerObject" }
        local cityRegion = { "cityRegion" }
        local pInventory = { "inventoryPointer" }
+       local activeArea = { "activeArea" }
        local objectId = 12345
 
        setup(function()
@@ -31,6 +33,7 @@ describe("Object Manager", function()
                DirectorManagerMocks.sceneObjects[pSceneObject] = sceneObject
                DirectorManagerMocks.playerObjects[pPlayerObject] = playerObject
                DirectorManagerMocks.cityRegions[pCityRegion] = cityRegion
+               DirectorManagerMocks.activeAreas[pActiveArea] = activeArea
 
                creatureObject.getPlayerObject = spy.new(function() return pPlayerObject end)
                creatureObject.getSlottedObject = spy.new(function() return pInventory end)
@@ -211,4 +214,17 @@ describe("Object Manager", function()
                        end)
                end)
        end)
+
+       describe("withActiveAreaObject", function()
+               it("Should return nil if the scene object pointer is nil to the withSActiveAreaObject function.", function()
+                       assert.is.Nil(ObjectManager.withActiveArea(nil, function(activeArea) end))
+               end)
+
+               it("Should call the supplied lambda expression with the ActiveArea when calling the withSceneObject function.", function()
+                       local activeAreaArgument = nil
+
+                       ObjectManager.withActiveArea(pActiveArea, function(activeArea) activeAreaArgument = activeArea end)
+                       assert.same(activeAreaArgument, activeArea)
+               end)
+       end)
 end)
index fc69925..e68a915 100644 (file)
@@ -7,6 +7,7 @@ DirectorManagerMocks.creatureObjects = {}
 DirectorManagerMocks.playerObjects = {}
 DirectorManagerMocks.sceneObjects = {}
 DirectorManagerMocks.stringIds = {}
+DirectorManagerMocks.activeAreas = {}
 
 WAYPOINTWHITE = 0
 
@@ -74,6 +75,14 @@ function DirectorManagerMocks.mocks.before_each()
                return DirectorManagerMocks.sceneObjects[pSceneObject]
        end)
 
+       LuaActiveArea = spy.new(function(pActiveArea)
+               if pActiveArea == nil then
+                       assert.not_nil(pActiveArea)
+                       return nil
+               end
+               return DirectorManagerMocks.activeAreas[pActiveArea]
+       end)
+
        LuaStringIdChatParameter = spy.new(function(stringId)
                return DirectorManagerMocks.stringIds[stringId]
        end)