From c9a56048ca5d52f06942b629e819a618f546542b Mon Sep 17 00:00:00 2001
From: Darredevil <alex.darredevil@gmail.com>
Date: Sun, 9 Mar 2014 20:35:33 +0200
Subject: [PATCH 1/4] Update GoalManager.coffee

---
 app/lib/world/GoalManager.coffee | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/lib/world/GoalManager.coffee b/app/lib/world/GoalManager.coffee
index 850b06859..13bf7e9d9 100644
--- a/app/lib/world/GoalManager.coffee
+++ b/app/lib/world/GoalManager.coffee
@@ -1,6 +1,6 @@
 CocoClass = require 'lib/CocoClass'
 utils = require 'lib/utils'
-
+#test
 module.exports = class GoalManager extends CocoClass
   # The Goal Manager is created both on the main thread and
   # each time the world is generated. The one in world generation

From 012c25a8177d3b81930df512cd3da81344f7e50e Mon Sep 17 00:00:00 2001
From: Darredevil <alex.darredevil@gmail.com>
Date: Wed, 12 Mar 2014 01:57:30 +0200
Subject: [PATCH 2/4] Added GetALLToLocations and KeepALLFromLocations

---
 app/lib/world/GoalManager.coffee | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/app/lib/world/GoalManager.coffee b/app/lib/world/GoalManager.coffee
index 13bf7e9d9..b017482b8 100644
--- a/app/lib/world/GoalManager.coffee
+++ b/app/lib/world/GoalManager.coffee
@@ -1,6 +1,6 @@
 CocoClass = require 'lib/CocoClass'
 utils = require 'lib/utils'
-#test
+
 module.exports = class GoalManager extends CocoClass
   # The Goal Manager is created both on the main thread and
   # each time the world is generated. The one in world generation
@@ -105,7 +105,6 @@ module.exports = class GoalManager extends CocoClass
   notifyGoalChanges: ->
     overallStatus = @checkOverallStatus()
     event = {goalStates: @goalStates, goals: @goals, overallStatus: overallStatus}
-    #console.log JSON.stringify(event), "new goal states"
     Backbone.Mediator.publish('goal-manager:new-goal-states', event)
 
   checkOverallStatus: (ignoreIncomplete=false) ->
@@ -126,6 +125,10 @@ module.exports = class GoalManager extends CocoClass
         keyFrame: 0 # when it became a 'success' or 'failure'
       }
       @initGoalState(state, [goal.killThangs, goal.saveThangs], 'killed')
+      for getTo in goal.getAllToLocations ? [] 
+        @initGoalState(state,[ getTo.getToLocation?.who , [] ], 'arrived')
+      for keepFrom in goal.keepAllFromLocations ? [] 
+        @initGoalState(state,[ [] , keepFrom.keepFromLocation?.who], 'arrived')
       @initGoalState(state, [goal.getToLocations?.who, goal.keepFromLocations?.who], 'arrived')
       @initGoalState(state, [goal.leaveOffSides?.who, goal.keepFromLeavingOffSides?.who], 'left')
       @initGoalState(state, [goal.collectThangs?.who, goal.keepFromCollectingThangs?.who], 'collected')
@@ -143,7 +146,13 @@ module.exports = class GoalManager extends CocoClass
   onThangTouchedGoal: (e, frameNumber) ->
     for goal in @goals ? []
       @checkArrived(goal.id, goal.getToLocations.who, goal.getToLocations.targets, e.actor, e.touched.id, frameNumber) if goal.getToLocations?
+      if goal.getAllToLocations?    
+        for getTo in goal.getAllToLocations
+          @checkArrived(goal.id, getTo.getToLocation.who, getTo.getToLocation.targets, e.actor, e.touched.id, frameNumber)
       @checkArrived(goal.id, goal.keepFromLocations.who, goal.keepFromLocations.targets, e.actor, e.touched.id, frameNumber) if goal.keepFromLocations?
+      if goal.keepAllFromLocations? 
+        for keepFrom in goal.keepAllFromLocations
+          @checkArrived(goal.id, keepFrom.keepFromLocation.who , keepFrom.keepFromLocation.targets, e.actor, e.touched.id, frameNumber )
 
   checkArrived: (goalID, who, targets, thang, touchedID, frameNumber) ->
     return unless touchedID in targets
@@ -191,6 +200,7 @@ module.exports = class GoalManager extends CocoClass
   initGoalState: (state, whos, progressObjectName) ->
     # 'whos' is an array of goal 'who' values.
     # This inits the progress object for the goal tracking.
+    
     arrays = (prop for prop in whos when prop?.length)
     return unless arrays.length
     state[progressObjectName] = {}
@@ -240,7 +250,9 @@ module.exports = class GoalManager extends CocoClass
     killThangs: 1
     saveThangs: 0
     getToLocations: 1
+    getAllToLocations: 1
     keepFromLocations: 0
+    keepAllFromLocations: 0
     leaveOffSides: 1
     keepFromLeavingOffSides: 0
     collectThangs: 1

From b1d61d368104b29e49c414f737e01c63e7e19d99 Mon Sep 17 00:00:00 2001
From: Darredevil <alex.darredevil@gmail.com>
Date: Wed, 12 Mar 2014 02:11:22 +0200
Subject: [PATCH 3/4] Added GetALLToLocations and KeepALLFromLocations schemas

---
 server/levels/level_schema.coffee | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/server/levels/level_schema.coffee b/server/levels/level_schema.coffee
index 86f774ad0..ae895fc1c 100644
--- a/server/levels/level_schema.coffee
+++ b/server/levels/level_schema.coffee
@@ -36,9 +36,19 @@ GoalSchema = c.object {title: "Goal", description: "A goal that the player can a
   getToLocations: c.object {title: "Get To Locations", description: "Will be set off when any of the \"who\" touch any of the \"targets\" ", required: ["who", "targets"]},
     who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
     targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
+  getAllToLocations: c.array {title: "Get all to locations", description: "Similar to getToLocations but now a specific \"who\" can have a specific \"target\"",required: ["getToLocation"]},
+  c.object {title: "", description: ""},
+    getToLocation: c.object {title: "Get To Locations", description: "TODO: explain", required: ["who", "targets"]},
+      who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
+      targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
   keepFromLocations: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
     who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang
     targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang
+  keepAllFromLocations: c.array {title: "Keep ALL From Locations", description: "Similar to keepFromLocations but now a specific \"who\" can have a specific \"target\"", required: ["keepFromLocation"]},
+  c.object {title: "", description: ""},
+    keepFromLocation: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
+      who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang
+      targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang
   leaveOffSides: c.object {title: "Leave Off Sides", description: "Sides of the level to get some Thangs to leave across.", required: ["who", "sides"]},
     who: c.array {title: "Who", description: "The Thangs which must leave off the sides of the level.", minItems: 1}, thang
     sides: c.array {title: "Sides", description: "The sides off which the Thangs must leave.", minItems: 1}, side
@@ -242,3 +252,4 @@ module.exports = LevelSchema
 # 3. tv4.addSchema(metaschema.id, metaschema)
 # 4. S = <paste big schema here>
 # 5. tv4.validateMultiple(S, metaschema)   and look for errors
+

From a6c508a442f14a7a3bf92c70285ff8cd0432afda Mon Sep 17 00:00:00 2001
From: Darredevil <alex.darredevil@gmail.com>
Date: Wed, 12 Mar 2014 02:20:28 +0200
Subject: [PATCH 4/4] Added descripton

---
 server/levels/level_schema.coffee | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/levels/level_schema.coffee b/server/levels/level_schema.coffee
index ae895fc1c..c9bff8628 100644
--- a/server/levels/level_schema.coffee
+++ b/server/levels/level_schema.coffee
@@ -36,15 +36,15 @@ GoalSchema = c.object {title: "Goal", description: "A goal that the player can a
   getToLocations: c.object {title: "Get To Locations", description: "Will be set off when any of the \"who\" touch any of the \"targets\" ", required: ["who", "targets"]},
     who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
     targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
-  getAllToLocations: c.array {title: "Get all to locations", description: "Similar to getToLocations but now a specific \"who\" can have a specific \"target\"",required: ["getToLocation"]},
-  c.object {title: "", description: ""},
-    getToLocation: c.object {title: "Get To Locations", description: "TODO: explain", required: ["who", "targets"]},
-      who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
-      targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
+  getAllToLocations: c.array {title: "Get all to locations", description: "Similar to getToLocations but now a specific \"who\" can have a specific \"target\", also must be used with the HowMany property for desired effect",required: ["getToLocation"]},
+  c.object {title: "", description: ""},
+    getToLocation: c.object {title: "Get To Locations", description: "TODO: explain", required: ["who", "targets"]},
+      who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
+      targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
   keepFromLocations: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
     who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang
     targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang
-  keepAllFromLocations: c.array {title: "Keep ALL From Locations", description: "Similar to keepFromLocations but now a specific \"who\" can have a specific \"target\"", required: ["keepFromLocation"]},
+  keepAllFromLocations: c.array {title: "Keep ALL From Locations", description: "Similar to keepFromLocations but now a specific \"who\" can have a specific \"target\", also must be used with the HowMany property for desired effect", required: ["keepFromLocation"]},
   c.object {title: "", description: ""},
     keepFromLocation: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
       who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang