@@ -1,2 +1,4 @@ | |||||
node_modules | node_modules | ||||
storage.db | |||||
storage.db | |||||
*.sublime-project | |||||
*.sublime-workspace |
@@ -35,8 +35,23 @@ define([ | |||||
hasFocus: true, | hasFocus: true, | ||||
init: function() { | init: function() { | ||||
client.init(this.onClientReady.bind(this)); | |||||
}, | |||||
onClientReady: function() { | |||||
client.request({ | |||||
module: 'clientConfig', | |||||
method: 'getResourcesList', | |||||
callback: this.onGetResourceList.bind(this) | |||||
}); | |||||
}, | |||||
onGetResourceList: function(list) { | |||||
resources.init(list); | |||||
events.on('onResourcesLoaded', this.start.bind(this)); | events.on('onResourcesLoaded', this.start.bind(this)); | ||||
}, | }, | ||||
start: function() { | start: function() { | ||||
window.onfocus = this.onFocus.bind(this, true); | window.onfocus = this.onFocus.bind(this, true); | ||||
window.onblur = this.onFocus.bind(this, false); | window.onblur = this.onFocus.bind(this, false); | ||||
@@ -46,7 +61,6 @@ define([ | |||||
}); | }); | ||||
objects.init(); | objects.init(); | ||||
client.init(); | |||||
renderer.init(); | renderer.init(); | ||||
input.init(); | input.init(); | ||||
@@ -97,7 +97,13 @@ define([ | |||||
this.stage.addChild(layers[l]) | this.stage.addChild(layers[l]) | ||||
}, this); | }, this); | ||||
['sprites', 'tiles', 'mobs', 'bosses', 'bigObjects', 'objects', 'characters', 'attacks', 'auras', 'walls', 'ui', 'animChar', 'animMob', 'animBoss'].forEach(function(t) { | |||||
var spriteNames = ['sprites', 'tiles', 'mobs', 'bosses', 'bigObjects', 'objects', 'characters', 'attacks', 'auras', 'walls', 'ui', 'animChar', 'animMob', 'animBoss']; | |||||
resources.spriteNames.forEach(function(s) { | |||||
if (s.indexOf('.png') > -1) | |||||
spriteNames.push(s); | |||||
}); | |||||
spriteNames.forEach(function(t) { | |||||
this.textures[t] = new pixi.BaseTexture(resources.sprites[t].image); | this.textures[t] = new pixi.BaseTexture(resources.sprites[t].image); | ||||
this.textures[t].scaleMode = pixi.SCALE_MODES.NEAREST; | this.textures[t].scaleMode = pixi.SCALE_MODES.NEAREST; | ||||
}, this); | }, this); | ||||
@@ -28,13 +28,17 @@ define([ | |||||
], | ], | ||||
sprites: {}, | sprites: {}, | ||||
ready: false, | ready: false, | ||||
init: function() { | |||||
init: function(list) { | |||||
list.forEach(function(l) { | |||||
this.spriteNames.push(l); | |||||
}, this); | |||||
this.spriteNames.forEach(function(s) { | this.spriteNames.forEach(function(s) { | ||||
var sprite = { | var sprite = { | ||||
image: (new Image()), | image: (new Image()), | ||||
ready: false | ready: false | ||||
}; | }; | ||||
sprite.image.src = 'images/' + s + '.png'; | |||||
sprite.image.src = s.indexOf('png') > -1 ? s : 'images/' + s + '.png'; | |||||
sprite.image.onload = this.onSprite.bind(this, sprite); | sprite.image.onload = this.onSprite.bind(this, sprite); | ||||
this.sprites[s] = sprite; | this.sprites[s] = sprite; | ||||
@@ -59,7 +63,5 @@ define([ | |||||
} | } | ||||
}; | }; | ||||
resources.init(); | |||||
return resources; | return resources; | ||||
}); | }); |
@@ -8,7 +8,7 @@ define([ | |||||
var client = { | var client = { | ||||
doneConnect: false, | doneConnect: false, | ||||
init: function() { | |||||
init: function(onReady) { | |||||
var tType = 'websocket'; | var tType = 'websocket'; | ||||
if (window.location.href.indexOf('polling') > -1) | if (window.location.href.indexOf('polling') > -1) | ||||
tType = 'polling'; | tType = 'polling'; | ||||
@@ -17,17 +17,20 @@ define([ | |||||
transports: [ tType ] | transports: [ tType ] | ||||
}); | }); | ||||
this.socket.on('connect', this.onConnected.bind(this)); | |||||
this.socket.on('connect', this.onConnected.bind(this, onReady)); | |||||
this.socket.on('handshake', this.onHandshake.bind(this)); | this.socket.on('handshake', this.onHandshake.bind(this)); | ||||
this.socket.on('event', this.onEvent.bind(this)); | this.socket.on('event', this.onEvent.bind(this)); | ||||
this.socket.on('events', this.onEvents.bind(this)); | this.socket.on('events', this.onEvents.bind(this)); | ||||
this.socket.on('dc', this.onDisconnect.bind(this)); | this.socket.on('dc', this.onDisconnect.bind(this)); | ||||
}, | }, | ||||
onConnected: function() { | |||||
onConnected: function(onReady) { | |||||
if (this.doneConnect) | if (this.doneConnect) | ||||
this.onDisconnect(); | this.onDisconnect(); | ||||
else | else | ||||
this.doneConnect = true; | this.doneConnect = true; | ||||
if (onReady) | |||||
onReady(); | |||||
}, | }, | ||||
onDisconnect: function() { | onDisconnect: function() { | ||||
window.location = window.location; | window.location = window.location; | ||||
@@ -135,8 +135,10 @@ define([ | |||||
spirteX = -(spirteX * 32); | spirteX = -(spirteX * 32); | ||||
spriteY = -(spriteY * 32); | spriteY = -(spriteY * 32); | ||||
var spritesheet = result.previewSpritesheet || '../../../images/charas.png'; | |||||
this.find('.sprite') | this.find('.sprite') | ||||
.css('background', 'url("../../../images/charas.png") ' + spirteX + 'px ' + spriteY + 'px') | |||||
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px') | |||||
.show(); | .show(); | ||||
this.find('.name').html(name); | this.find('.name').html(name); | ||||
@@ -15,12 +15,7 @@ define([ | |||||
tpl: template, | tpl: template, | ||||
centered: true, | centered: true, | ||||
classSprites: { | |||||
warrior: [1, 1], | |||||
wizard: [2, 0], | |||||
thief: [6, 0], | |||||
cleric: [4, 0] | |||||
}, | |||||
classSprites: null, | |||||
class: 'wizard', | class: 'wizard', | ||||
costume: 0, | costume: 0, | ||||
@@ -172,13 +167,15 @@ define([ | |||||
}, | }, | ||||
setSprite: function() { | setSprite: function() { | ||||
var classSprite = this.classSprites[this.class]; | |||||
var costume = classSprite[this.costume].split(','); | |||||
var classSprite = this.classSprites[this.class][this.costume]; | |||||
var costume = classSprite.sprite.split(','); | |||||
var spirteX = -costume[0] * 32; | var spirteX = -costume[0] * 32; | ||||
var spriteY = -costume[1] * 32; | var spriteY = -costume[1] * 32; | ||||
var spritesheet = classSprite.spritesheet || '../../../images/charas.png'; | |||||
this.find('.sprite') | this.find('.sprite') | ||||
.css('background', 'url("../../../images/charas.png") ' + spirteX + 'px ' + spriteY + 'px'); | |||||
.css('background', 'url("' + spritesheet + '") ' + spirteX + 'px ' + spriteY + 'px'); | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -113,12 +113,14 @@ define([ | |||||
slot = 'rune-' + spellId; | slot = 'rune-' + spellId; | ||||
} | } | ||||
var spritesheet = item.spritesheet || '../../../images/items.png'; | |||||
var elSlot = this.find('[slot="' + slot + '"]'); | var elSlot = this.find('[slot="' + slot + '"]'); | ||||
elSlot | elSlot | ||||
.data('item', item) | .data('item', item) | ||||
.removeClass('empty') | .removeClass('empty') | ||||
.find('.icon') | .find('.icon') | ||||
.css('background', 'url(../../../images/items.png) ' + imgX + 'px ' + imgY + 'px') | |||||
.css('background', 'url("' + spritesheet + '") ' + imgX + 'px ' + imgY + 'px') | |||||
.off() | .off() | ||||
.on('mousemove', this.onHoverItem.bind(this, elSlot, item, null)) | .on('mousemove', this.onHoverItem.bind(this, elSlot, item, null)) | ||||
.on('mouseleave', this.onHoverItem.bind(this, null, null)) | .on('mouseleave', this.onHoverItem.bind(this, null, null)) | ||||
@@ -159,7 +161,7 @@ define([ | |||||
.forEach(function(item) { | .forEach(function(item) { | ||||
var sprite = item.sprite || [7, 0]; | var sprite = item.sprite || [7, 0]; | ||||
var spriteSheet = item.empty ? 'uiIcons' : 'items'; | |||||
var spriteSheet = item.empty ? '../../../images/uiIcons.png' : item.spritesheet || '../../../images/items.png'; | |||||
var imgX = -sprite[0] * 64; | var imgX = -sprite[0] * 64; | ||||
var imgY = -sprite[1] * 64; | var imgY = -sprite[1] * 64; | ||||
@@ -168,7 +170,7 @@ define([ | |||||
el | el | ||||
.find('.icon') | .find('.icon') | ||||
.css('background', 'url(../../../images/' + spriteSheet + '.png) ' + imgX + 'px ' + imgY + 'px') | |||||
.css('background', 'url("' + spriteSheet + '") ' + imgX + 'px ' + imgY + 'px') | |||||
.on('mousemove', this.onHoverItem.bind(this, el, item, null)) | .on('mousemove', this.onHoverItem.bind(this, el, item, null)) | ||||
.on('mouseleave', this.onHoverItem.bind(this, null, null)) | .on('mouseleave', this.onHoverItem.bind(this, null, null)) | ||||
.on('click', this.equipItem.bind(this, item)); | .on('click', this.equipItem.bind(this, item)); | ||||
@@ -119,7 +119,7 @@ define([ | |||||
var itemEl = $(tplItem) | var itemEl = $(tplItem) | ||||
.appendTo(container); | .appendTo(container); | ||||
var spritesheet = 'items'; | |||||
var spritesheet = item.spritesheet || 'items'; | |||||
if (item.material) | if (item.material) | ||||
spritesheet = 'materials'; | spritesheet = 'materials'; | ||||
else if (item.quest) | else if (item.quest) | ||||
@@ -220,7 +220,7 @@ define([ | |||||
var imgX = -item.sprite[0] * 64; | var imgX = -item.sprite[0] * 64; | ||||
var imgY = -item.sprite[1] * 64; | var imgY = -item.sprite[1] * 64; | ||||
var spritesheet = 'items'; | |||||
var spritesheet = item.spritesheet || 'items'; | |||||
if (item.material) | if (item.material) | ||||
spritesheet = 'materials'; | spritesheet = 'materials'; | ||||
else if (item.quest) | else if (item.quest) | ||||
@@ -43,9 +43,10 @@ define([ | |||||
.on('mouseover', this.onShowTooltip.bind(this, el, spells[i])) | .on('mouseover', this.onShowTooltip.bind(this, el, spells[i])) | ||||
.on('mouseleave', this.onHideTooltip.bind(this, el)); | .on('mouseleave', this.onHideTooltip.bind(this, el)); | ||||
var spritesheet = spells[i].spritesheet || '../../../images/abilityIcons.png'; | |||||
el | el | ||||
.find('.icon').css({ | .find('.icon').css({ | ||||
'background': 'url("../../../images/abilityIcons.png") ' + x + 'px ' + y + 'px' | |||||
'background': 'url("' + spritesheet + '") ' + x + 'px ' + y + 'px' | |||||
}) | }) | ||||
.next().html(i + 1); | .next().html(i + 1); | ||||
@@ -62,7 +62,7 @@ define([ | |||||
var size = 64; | var size = 64; | ||||
var offset = 0; | var offset = 0; | ||||
var spritesheet = 'items'; | |||||
var spritesheet = item.spritesheet || 'items'; | |||||
if (item.material) | if (item.material) | ||||
spritesheet = 'materials'; | spritesheet = 'materials'; | ||||
else if (item.quest) | else if (item.quest) | ||||
@@ -115,8 +115,8 @@ define([ | |||||
var result = characters | var result = characters | ||||
.map(c => ({ | .map(c => ({ | ||||
name: c, | |||||
level: leaderboard.getLevel(c) | |||||
name: c.name ? c.name : c, | |||||
level: leaderboard.getLevel(c.name ? c.name : c) | |||||
})); | })); | ||||
data.callback(result); | data.callback(result); | ||||
@@ -300,14 +300,8 @@ define([ | |||||
this.obj.class = data.class; | this.obj.class = data.class; | ||||
this.obj.costume = data.costume; | this.obj.costume = data.costume; | ||||
var tiles = { | |||||
wizard: [2, 3], | |||||
cleric: [4, 5], | |||||
thief: [6, 7], | |||||
warrior: [9, 10] | |||||
}; | |||||
this.obj.cell = tiles[data.class][data.costume]; | |||||
this.obj.cell = skins.getCell(this.obj.class, this.obj.costume); | |||||
this.obj.previewSpritesheet = skins.getSpritesheet(this.obj.class); | |||||
var simple = this.obj.getSimple(true); | var simple = this.obj.getSimple(true); | ||||
simple.components.push({ | simple.components.push({ | ||||
@@ -360,10 +354,16 @@ define([ | |||||
}, | }, | ||||
onDeleteCharacter: function(msg, result) { | onDeleteCharacter: function(msg, result) { | ||||
this.characterList.spliceWhere(c => c == msg.data.name); | this.characterList.spliceWhere(c => c == msg.data.name); | ||||
var characterList = this.characterList | |||||
.map(c => ({ | |||||
name: c.name ? c.name : c, | |||||
level: leaderboard.getLevel(c.name ? c.name : c) | |||||
})); | |||||
io.set({ | io.set({ | ||||
ent: this.username, | ent: this.username, | ||||
field: 'characterList', | field: 'characterList', | ||||
value: JSON.stringify(this.characterList), | |||||
value: JSON.stringify(characterList), | |||||
callback: this.onRemoveFromList.bind(this, msg) | callback: this.onRemoveFromList.bind(this, msg) | ||||
}); | }); | ||||
@@ -11,7 +11,6 @@ define([ | |||||
objects, | objects, | ||||
classes | classes | ||||
) { | ) { | ||||
return { | return { | ||||
type: 'inventory', | type: 'inventory', | ||||
@@ -26,9 +26,10 @@ define([ | |||||
spawn: function(character) { | spawn: function(character) { | ||||
var obj = this.obj; | var obj = this.obj; | ||||
extend(true, obj, { | extend(true, obj, { | ||||
sheetName: 'characters', | |||||
sheetName: classes.getSpritesheet(character.class), | |||||
layerName: 'mobs', | layerName: 'mobs', | ||||
cell: character.cell, | cell: character.cell, | ||||
previewSpritesheet: character.previewSpritesheet, | |||||
name: character.name, | name: character.name, | ||||
class: character.class, | class: character.class, | ||||
zoneName: character.zoneName || 'tutorial-cove', | zoneName: character.zoneName || 'tutorial-cove', | ||||
@@ -2,12 +2,14 @@ define([ | |||||
'./../config/spells/spellTemplate', | './../config/spells/spellTemplate', | ||||
'./../config/animations', | './../config/animations', | ||||
'./../config/spells', | './../config/spells', | ||||
'./../config/spellsConfig' | |||||
'./../config/spellsConfig', | |||||
'misc/events' | |||||
], function( | ], function( | ||||
spellTemplate, | spellTemplate, | ||||
animations, | animations, | ||||
playerSpells, | playerSpells, | ||||
playerSpellsConfig | |||||
playerSpellsConfig, | |||||
events | |||||
) { | ) { | ||||
return { | return { | ||||
type: 'spellbook', | type: 'spellbook', | ||||
@@ -82,9 +84,15 @@ define([ | |||||
var type = options.type[0].toUpperCase() + options.type.substr(1); | var type = options.type[0].toUpperCase() + options.type.substr(1); | ||||
var typeTemplate = require('./config/spells/spell' + type); | |||||
var typeTemplate = { | |||||
type: type, | |||||
template: null | |||||
}; | |||||
events.emit('onBeforeGetSpellTemplate', typeTemplate); | |||||
if (!typeTemplate.template) | |||||
typeTemplate.template = require('./config/spells/spell' + type); | |||||
var builtSpell = extend(true, {}, spellTemplate, typeTemplate, options); | |||||
var builtSpell = extend(true, {}, spellTemplate, typeTemplate.template, options); | |||||
builtSpell.obj = this.obj; | builtSpell.obj = this.obj; | ||||
builtSpell.baseDamage = builtSpell.damage; | builtSpell.baseDamage = builtSpell.damage; | ||||
builtSpell.damage += (options.damageAdd || 0); | builtSpell.damage += (options.damageAdd || 0); | ||||
@@ -1,9 +1,9 @@ | |||||
define([ | define([ | ||||
'misc/events' | |||||
], function( | ], function( | ||||
events | |||||
) { | ) { | ||||
return { | |||||
var classes = { | |||||
spells: { | spells: { | ||||
wizard: ['ice spear'], | wizard: ['ice spear'], | ||||
cleric: ['healing circle'], | cleric: ['healing circle'], | ||||
@@ -41,6 +41,13 @@ define([ | |||||
cleric: 'Mace', | cleric: 'Mace', | ||||
thief: 'Dagger', | thief: 'Dagger', | ||||
warrior: 'Axe' | warrior: 'Axe' | ||||
}, | |||||
getSpritesheet: function(className) { | |||||
return this.stats[className].spritesheet || 'characters'; | |||||
} | } | ||||
}; | }; | ||||
events.emit('onBeforeGetClasses', classes); | |||||
return classes; | |||||
}); | }); |
@@ -0,0 +1,17 @@ | |||||
define([ | |||||
'misc/events' | |||||
], function( | |||||
events | |||||
) { | |||||
return { | |||||
resourceList: [], | |||||
init: function() { | |||||
events.emit('onBeforeGetResourceList', this.resourceList); | |||||
}, | |||||
getResourcesList: function(msg) { | |||||
msg.callback(this.resourceList); | |||||
} | |||||
}; | |||||
}); |
@@ -1,7 +1,7 @@ | |||||
define([ | define([ | ||||
'misc/events' | |||||
], function( | ], function( | ||||
events | |||||
) { | ) { | ||||
var config = { | var config = { | ||||
'wizard 1': { | 'wizard 1': { | ||||
@@ -60,6 +60,8 @@ define([ | |||||
} | } | ||||
}; | }; | ||||
events.emit('onBeforeGetSkins', config); | |||||
return { | return { | ||||
getBlueprint: function(skinId) { | getBlueprint: function(skinId) { | ||||
return config[skinId]; | return config[skinId]; | ||||
@@ -79,10 +81,35 @@ define([ | |||||
if (!result[l.class]) | if (!result[l.class]) | ||||
result[l.class] = []; | result[l.class] = []; | ||||
result[l.class].push(l.sprite[0] + ',' + l.sprite[1]); | |||||
result[l.class].push({ | |||||
sprite: l.sprite[0] + ',' + l.sprite[1], | |||||
spritesheet: l.spritesheet | |||||
}); | |||||
}); | }); | ||||
return result; | return result; | ||||
}, | |||||
getCell: function(className, costume) { | |||||
var res = Object.keys(config) | |||||
.filter(function(s) { | |||||
return (config[s].class == className); | |||||
}) | |||||
.map(function(s) { | |||||
return config[s]; | |||||
})[costume]; | |||||
return (res.sprite[1] * 8) + res.sprite[0]; | |||||
}, | |||||
getSpritesheet: function(className) { | |||||
return Object.keys(config) | |||||
.filter(function(s) { | |||||
return (config[s].class == className); | |||||
}) | |||||
.map(function(s) { | |||||
return config[s]; | |||||
})[0].spritesheet; | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -1,9 +1,9 @@ | |||||
define([ | define([ | ||||
'misc/events' | |||||
], function( | ], function( | ||||
events | |||||
) { | ) { | ||||
return [{ | |||||
var spells = [{ | |||||
name: 'Magic Missile', | name: 'Magic Missile', | ||||
description: 'Launches an orb of unfocussed energy at your target.', | description: 'Launches an orb of unfocussed energy at your target.', | ||||
type: 'projectile', | type: 'projectile', | ||||
@@ -382,4 +382,7 @@ define([ | |||||
chance: 0.02 | chance: 0.02 | ||||
} | } | ||||
}]; | }]; | ||||
events.emit('onBeforeGetSpellsInfo', spells); | |||||
return spells; | |||||
}); | }); |
@@ -1,9 +1,9 @@ | |||||
define([ | define([ | ||||
'misc/events' | |||||
], function( | ], function( | ||||
events | |||||
) { | ) { | ||||
return { | |||||
var spells = { | |||||
'magic missile': { | 'magic missile': { | ||||
statType: 'int', | statType: 'int', | ||||
statMult: 0.216, | statMult: 0.216, | ||||
@@ -172,4 +172,7 @@ define([ | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
events.emit('onBeforeGetSpellsConfig', spells); | |||||
return spells; | |||||
}); | }); |
@@ -4,14 +4,16 @@ define([ | |||||
'misc/helpers', | 'misc/helpers', | ||||
'items/lootRoller', | 'items/lootRoller', | ||||
'world/atlas', | 'world/atlas', | ||||
'leaderboard/leaderboard' | |||||
'leaderboard/leaderboard', | |||||
'config/clientConfig' | |||||
], function( | ], function( | ||||
extend, | extend, | ||||
cons, | cons, | ||||
helpers, | helpers, | ||||
lootRoller, | lootRoller, | ||||
atlas, | atlas, | ||||
leaderboard | |||||
leaderboard, | |||||
clientConfig | |||||
) { | ) { | ||||
return { | return { | ||||
init: function() { | init: function() { | ||||
@@ -21,6 +23,9 @@ define([ | |||||
global.lootRoller = lootRoller; | global.lootRoller = lootRoller; | ||||
global.atlas = atlas; | global.atlas = atlas; | ||||
global.leaderboard = leaderboard; | global.leaderboard = leaderboard; | ||||
global.clientConfig = clientConfig; | |||||
clientConfig.init(); | |||||
} | } | ||||
}; | }; | ||||
}); | }); |
@@ -1,9 +1,9 @@ | |||||
define([ | define([ | ||||
'misc/events' | |||||
], function( | ], function( | ||||
events | |||||
) { | ) { | ||||
return { | |||||
var types = { | |||||
head: { | head: { | ||||
'Helmet': { | 'Helmet': { | ||||
sprite: [0, 0], | sprite: [0, 0], | ||||
@@ -191,4 +191,7 @@ define([ | |||||
} | } | ||||
} | } | ||||
} | } | ||||
events.emit('onBeforeGetItemTypes', types); | |||||
return types; | |||||
}); | }); |
@@ -15,6 +15,8 @@ define([ | |||||
item.type = type; | item.type = type; | ||||
item.sprite = typeBlueprint.sprite; | item.sprite = typeBlueprint.sprite; | ||||
if (typeBlueprint.spritesheet) | |||||
item.spritesheet = typeBlueprint.spritesheet; | |||||
if (typeBlueprint.spellName) | if (typeBlueprint.spellName) | ||||
blueprint.spellName = typeBlueprint.spellName; | blueprint.spellName = typeBlueprint.spellName; | ||||
@@ -0,0 +1,62 @@ | |||||
define([ | |||||
], function( | |||||
) { | |||||
return { | |||||
events: {}, | |||||
queue: [], | |||||
on: function(event, callback) { | |||||
var list = this.events[event] || (this.events[event] = []); | |||||
list.push(callback); | |||||
for (var i = 0; i < this.queue.length; i++) { | |||||
var q = this.queue[i]; | |||||
if (q.event != event) | |||||
continue; | |||||
this.queue.splice(i, 1); | |||||
i--; | |||||
q.args.splice(0, 0, event); | |||||
this.emit.apply(this, q.args); | |||||
} | |||||
return callback; | |||||
}, | |||||
off: function(event, callback) { | |||||
var list = this.events[event] || []; | |||||
var lLen = list.length; | |||||
for (var i = 0; i < lLen; i++) { | |||||
if (list[i] == callback) { | |||||
list.splice(i, 1); | |||||
i--; | |||||
lLen--; | |||||
} | |||||
} | |||||
if (lLen == 0) | |||||
delete this.events[event]; | |||||
}, | |||||
emit: function(event) { | |||||
var args = [].slice.call(arguments, 1); | |||||
var list = this.events[event]; | |||||
if (!list) { | |||||
this.queue.push({ | |||||
event: event, | |||||
args: args | |||||
}); | |||||
return; | |||||
} | |||||
var len = list.length | |||||
for (var i = 0; i < len; i++) { | |||||
var l = list[i]; | |||||
l.apply(null, args); | |||||
} | |||||
} | |||||
}; | |||||
}); |
@@ -0,0 +1,14 @@ | |||||
define([ | |||||
'mods/modList' | |||||
], function( | |||||
modList | |||||
) { | |||||
return { | |||||
init: function() { | |||||
modList.forEach(function(m) { | |||||
var mod = require('mods/' + m + '/index'); | |||||
mod.init(); | |||||
}, this); | |||||
} | |||||
}; | |||||
}); |
@@ -0,0 +1,9 @@ | |||||
define([ | |||||
], function( | |||||
) { | |||||
return [ | |||||
]; | |||||
}); |
@@ -10,7 +10,10 @@ define([ | |||||
global.io = require('socket.io')(server); | global.io = require('socket.io')(server); | ||||
app.use(function(req, res, next) { | app.use(function(req, res, next) { | ||||
req.url = '/client/' + req.url; | |||||
if (req.url.indexOf('/server') != 0) | |||||
req.url = '/client/' + req.url; | |||||
else | |||||
req.url.substr(7); | |||||
next(); | next(); | ||||
}); | }); | ||||
@@ -4,14 +4,16 @@ define([ | |||||
'world/atlas', | 'world/atlas', | ||||
'components/components', | 'components/components', | ||||
'leaderboard/leaderboard', | 'leaderboard/leaderboard', | ||||
'security/io' | |||||
'security/io', | |||||
'misc/mods' | |||||
], function( | ], function( | ||||
globals, | globals, | ||||
server, | server, | ||||
atlas, | atlas, | ||||
components, | components, | ||||
leaderboard, | leaderboard, | ||||
io | |||||
io, | |||||
mods | |||||
) { | ) { | ||||
return { | return { | ||||
init: function() { | init: function() { | ||||
@@ -30,6 +32,7 @@ define([ | |||||
server.init(this.onServerReady.bind(this)); | server.init(this.onServerReady.bind(this)); | ||||
}, | }, | ||||
onServerReady: function() { | onServerReady: function() { | ||||
mods.init(); | |||||
atlas.init(); | atlas.init(); | ||||
leaderboard.init(); | leaderboard.init(); | ||||
} | } | ||||
@@ -9,9 +9,9 @@ global.io = true; | |||||
var instancer = null; | var instancer = null; | ||||
requirejs([ | requirejs([ | ||||
'extend', 'misc/helpers', 'components/components', 'world/instancer', 'security/io' | |||||
'extend', 'misc/helpers', 'components/components', 'world/instancer', 'security/io', 'misc/mods' | |||||
], function( | ], function( | ||||
extend, helpers, components, _instancer, io | |||||
extend, helpers, components, _instancer, io, mods | |||||
) { | ) { | ||||
var onDbReady = function() { | var onDbReady = function() { | ||||
global.extend = extend; | global.extend = extend; | ||||
@@ -26,6 +26,8 @@ requirejs([ | |||||
}); | }); | ||||
}); | }); | ||||
mods.init(); | |||||
setInterval(function() { | setInterval(function() { | ||||
global.gc(); | global.gc(); | ||||
}, 60000); | }, 60000); | ||||