From 05c4e4de81f0d395e411aaa0083795d0a75a3c2b Mon Sep 17 00:00:00 2001 From: logsol Date: Mon, 10 Oct 2016 23:10:43 +0200 Subject: [PATCH] Refactoring of Options. Renamed to OptionsHelper Because that is what it is. --- app/Game/Channel/Channel.js | 6 +++--- app/Game/Core/GameObjects/Item.js | 6 +++--- app/Game/Core/GameObjects/Items/RagDoll.js | 8 ++++---- app/Game/Core/Loader/TiledLevel.js | 6 +++--- app/Lib/Utilities/Options.js | 14 +++++++------- app/Server/Api.js | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/Game/Channel/Channel.js b/app/Game/Channel/Channel.js index 12f192b..2682fb4 100755 --- a/app/Game/Channel/Channel.js +++ b/app/Game/Channel/Channel.js @@ -3,11 +3,11 @@ "Lib/Utilities/NotificationCenter", "Game/Channel/User", "Lib/Utilities/Protocol/Helper", - "Lib/Utilities/Options", + "Lib/Utilities/OptionsHelper", "Game/Config/Settings" ], - function (GameController, nc, User, ProtocolHelper, Options, Settings) { + function (GameController, nc, User, ProtocolHelper, OptionsHelper, Settings) { "use strict"; @@ -21,7 +21,7 @@ this.levelListIndex = -1; this.gameController = null; - this.options = options = Options.merge(options, { + this.options = options = OptionsHelper.merge(options, { levelUids: Settings.CHANNEL_DEFAULT_LEVELS }); diff --git a/app/Game/Core/GameObjects/Item.js b/app/Game/Core/GameObjects/Item.js index fd15946..0787a05 100644 --- a/app/Game/Core/GameObjects/Item.js +++ b/app/Game/Core/GameObjects/Item.js @@ -1,14 +1,14 @@ define([ "Game/" + GLOBALS.context + "/GameObjects/GameObject", "Lib/Vendor/Box2D", - "Lib/Utilities/Options", + "Lib/Utilities/OptionsHelper", "Game/Config/Settings", "Lib/Utilities/Exception", "Lib/Utilities/NotificationCenter", "Lib/Utilities/Assert" ], -function (Parent, Box2D, Options, Settings, Exception, nc, Assert) { +function (Parent, Box2D, OptionsHelper, Settings, Exception, nc, Assert) { "use strict"; @@ -26,7 +26,7 @@ function (Parent, Box2D, Options, Settings, Exception, nc, Assert) { y: parseFloat(options.y) }; - this.options = Options.merge(floatOptions, options); + this.options = OptionsHelper.merge(floatOptions, options); if(!this.options.category) { // FIXME add more validation diff --git a/app/Game/Core/GameObjects/Items/RagDoll.js b/app/Game/Core/GameObjects/Items/RagDoll.js index e47c5d6..51bdb3e 100644 --- a/app/Game/Core/GameObjects/Items/RagDoll.js +++ b/app/Game/Core/GameObjects/Items/RagDoll.js @@ -4,11 +4,11 @@ define([ "Game/Config/Settings", "Lib/Utilities/NotificationCenter", "Lib/Utilities/Assert", - "Lib/Utilities/Options", + "Lib/Utilities/OptionsHelper", "Game/Config/ItemSettings", ], -function (Parent, Box2D, Settings, nc, Assert, Options, ItemSettings) { +function (Parent, Box2D, Settings, nc, Assert, OptionsHelper, ItemSettings) { "use strict"; @@ -96,8 +96,8 @@ function (Parent, Box2D, Settings, nc, Assert, Options, ItemSettings) { // FIXME - var ragdollOptions = Options.merge(ItemSettings.RagDoll, ItemSettings.Default); - options = Options.merge(options, ragdollOptions); + var ragdollOptions = OptionsHelper.merge(ItemSettings.RagDoll, ItemSettings.Default); + options = OptionsHelper.merge(options, ragdollOptions); Parent.call(this, physicsEngine, uid, options); //this.createSensor(); diff --git a/app/Game/Core/Loader/TiledLevel.js b/app/Game/Core/Loader/TiledLevel.js index 8f26b11..3990efc 100755 --- a/app/Game/Core/Loader/TiledLevel.js +++ b/app/Game/Core/Loader/TiledLevel.js @@ -3,7 +3,7 @@ define([ "Game/Config/Settings", "Game/Config/ItemSettings", "Lib/Vendor/Box2D", - "Lib/Utilities/Options", + "Lib/Utilities/OptionsHelper", "Lib/Utilities/Exception", "Lib/Utilities/NotificationCenter", "Lib/Utilities/Assert", @@ -13,7 +13,7 @@ define([ "Game/" + GLOBALS.context + "/GameObjects/Item", "Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard", -], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) { +], function (Parent, Settings, ItemSettings, Box2D, OptionsHelper, Exception, nc, Assert, AbstractLayer, CollisionDetector, Tile, Item, Skateboard) { "use strict"; @@ -187,7 +187,7 @@ define([ throw new Exception("Item name (" + name + ") cannot be found in item list"); } - return Options.merge(ItemSettings[name], ItemSettings.Default); + return OptionsHelper.merge(ItemSettings[name], ItemSettings.Default); }; TiledLevel.prototype.getTileImagePath = function(gid) { diff --git a/app/Lib/Utilities/Options.js b/app/Lib/Utilities/Options.js index 1616f77..ff21290 100644 --- a/app/Lib/Utilities/Options.js +++ b/app/Lib/Utilities/Options.js @@ -6,18 +6,18 @@ function (Exception) { "use strict"; - function Options() { + function OptionsHelper() { } - Options.prototype.merge = function(options, preset) { + OptionsHelper.prototype.merge = function(options, preset) { if(!preset && !options) { - throw new Exception("Options requires objects"); + throw new Exception("OptionsHelper requires objects"); } if(preset.constructor !== Object && options.constructor !== Object) { - throw new Exception("Options requires objects"); + throw new Exception("OptionsHelper requires objects"); } if(!preset || preset.constructor !== Object) { @@ -43,7 +43,7 @@ function (Exception) { if(options[key].constructor !== Object) { preset[key] = options[key]; } else { - preset[key] = Options.prototype.merge.call(this, options[key], preset[key]); + preset[key] = OptionsHelper.prototype.merge.call(this, options[key], preset[key]); } } } @@ -51,6 +51,6 @@ function (Exception) { return preset; } - return new Options(); - + return new OptionsHelper(); + }); \ No newline at end of file diff --git a/app/Server/Api.js b/app/Server/Api.js index 489a998..a0186a3 100644 --- a/app/Server/Api.js +++ b/app/Server/Api.js @@ -2,12 +2,12 @@ define([ "Lib/Utilities/NotificationCenter", "Lib/Utilities/Protocol/Helper", "Lib/Utilities/Validate", - "Lib/Utilities/Options", + "Lib/Utilities/OptionsHelper", "Game/Config/Settings", "fs" ], -function (nc, ProtocolHelper, validate, Options, Settings, FileSystem) { +function (nc, ProtocolHelper, validate, OptionsHelper, Settings, FileSystem) { "use strict"; @@ -121,7 +121,7 @@ function (nc, ProtocolHelper, validate, Options, Settings, FileSystem) { scoreLimit: Settings.CHANNEL_DEFAULT_SCORE_LIMIT }; - options = Options.merge(options, defaultOptions); + options = OptionsHelper.merge(options, defaultOptions); var result = this.coordinator.createChannel(options); if(result !== false) {