new Utils()
- Source - utils/Utils.js, line 11
Classes
Methods
-
<static> extend(deep, target) → {object}
-
This is a slightly modified version of http://api.jquery.com/jQuery.extend/
Parameters:
Name Type Description deepboolean Perform a deep copy?
targetobject The target object to copy to.
Returns:
object -The extended object.
- Source - utils/Utils.js, line 225
-
<static> getProperty(obj, prop) → {*}
-
Gets an objects property by string.
Parameters:
Name Type Description objobject The object to traverse.
propstring The property whose value will be returned.
Returns:
* -the value of the property or null if property isn't found .
- Source - utils/Utils.js, line 13
-
<static> isPlainObject(obj) → {boolean}
-
This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
Parameters:
Name Type Description objobject The object to inspect.
Returns:
boolean -- true if the object is plain, otherwise false.
- Source - utils/Utils.js, line 189
-
<static> mixin(from, to) → {object}
-
Mixes the source object into the destination object, returning the newly modified destination object. Based on original code by @mudcube
Parameters:
Name Type Description fromobject The object to copy (the source object).
toobject The object to copy to (the destination object).
Returns:
object -The modified destination object.
- Source - utils/Utils.js, line 357
-
<static> mixinPrototype(target, mixin, replace)
-
Mixes in an existing mixin object with the target.
Values in the mixin that have either
getorsetfunctions are created as properties viadefinePropertyexcept if they also define aclonemethod - if a clone method is defined that is called instead and the result is assigned directly.Parameters:
Name Type Argument Default Description targetobject The target object to receive the new functions.
mixinobject The object to copy the functions from.
replaceboolean <optional>
false If the target object already has a matching function should it be overwritten or not?
- Source - utils/Utils.js, line 305
-
<static> pad(str, len, pad, dir) → {string}
-
JavaScript string pad http://www.webtoolkit.info/.
Parameters:
Name Type Argument Default Description strstring The target string.
leninteger <optional>
0 The number of characters to be added.
padstring <optional>
" " The string to pad it out with (defaults to a space).
dirinteger <optional>
3 The direction dir = 1 (left), 2 (right), 3 (both).
Returns:
string -The padded string
- Source - utils/Utils.js, line 147
-
<static> parseDimension(size, dimension) → {number}
-
Get a unit dimension from a string.
Parameters:
Name Type Description sizestring | number The size to parse.
dimensionnumber The window dimension to check.
Returns:
number -The parsed dimension.
- Source - utils/Utils.js, line 104
-
<static> setProperty(obj, prop) → {object}
-
Sets an objects property by string.
Parameters:
Name Type Description objobject The object to traverse
propstring The property whose value will be changed
Returns:
object -The object on which the property was set.
- Source - utils/Utils.js, line 46
-
chanceRoll(chance) → {boolean}
-
Generate a random bool result based on the chance value.
Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
Parameters:
Name Type Description chancenumber The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).
Returns:
boolean -True if the roll passed, or false otherwise.
- Source - utils/Utils.js, line 77
-
randomChoice(choice1, choice2) → {any}
-
Choose between one of two values randomly.
Parameters:
Name Type Description choice1any choice2any Returns:
any -The randomly selected choice
- Source - utils/Utils.js, line 92
