Explorar el Código

fixes #321

tags/v0.1.8^2
big bad waffle hace 6 años
padre
commit
3452f7f46b
Se han modificado 9 ficheros con 172 adiciones y 39 borrados
  1. BIN
     
  2. BIN
     
  3. +16
    -15
      src/client/ui/factory.js
  4. +11
    -13
      src/server/components/door.js
  5. +9
    -9
      src/server/components/syncer.js
  6. +112
    -0
      src/server/components/wardrobe.js
  7. +21
    -1
      src/server/config/maps/tutorial/map.json
  8. +1
    -0
      src/server/config/skins.js
  9. +2
    -1
      src/server/security/router.js


+ 16
- 15
src/client/ui/factory.js Ver fichero

@@ -1,21 +1,21 @@
define([
'ui/uiBase',
'js/system/events'
], function(
], function (
uiBase,
events
) {
return {
uis: [],
root: '',
init: function(root) {
init: function (root) {
if (root)
this.root = root + '/';

events.on('onEnterGame', this.onEnterGame.bind(this));
events.on('onKeyDown', this.onKeyDown.bind(this));
},
onEnterGame: function() {
onEnterGame: function () {
events.clearQueue();

[
@@ -27,7 +27,7 @@ define([
'spells',
'messages',
'online',
'options',
'options',
'context',
'party',
'help',
@@ -48,13 +48,14 @@ define([
'death',
'leaderboard',
'reputation',
'mail'
].forEach(function(u) {
'mail',
'wardrobe'
].forEach(function (u) {
this.build(u);
}, this);
},

build: function(type, options) {
build: function (type, options) {
//Don't make doubles?
var className = 'ui' + type[0].toUpperCase() + type.substr(1);
var el = $('.' + className);
@@ -64,10 +65,10 @@ define([
this.getTemplate(type, options);
$(window).on('resize', this.onResize.bind(this));
},
getTemplate: function(type, options) {
getTemplate: function (type, options) {
require([this.root + 'ui/templates/' + type + '/' + type], this.onGetTemplate.bind(this, options));
},
onGetTemplate: function(options, template) {
onGetTemplate: function (options, template) {
var ui = _.create(uiBase, template);
ui.setOptions(options);
ui.render();
@@ -75,8 +76,8 @@ define([

this.uis.push(ui);
},
onResize: function() {
this.uis.forEach(function(ui) {
onResize: function () {
this.uis.forEach(function (ui) {
if (ui.centered)
ui.center();
else if ((ui.centeredX) || (ui.centeredY))
@@ -84,9 +85,9 @@ define([
}, this);
},

onKeyDown: function(key) {
onKeyDown: function (key) {
if (key == 'esc') {
this.uis.forEach(function(u) {
this.uis.forEach(function (u) {
if (!u.modal)
return;

@@ -97,7 +98,7 @@ define([
}
},

update: function() {
update: function () {
var uis = this.uis;
var uLen = uis.length;
for (var i = 0; i < uLen; i++) {
@@ -107,4 +108,4 @@ define([
}
}
};
});
});

+ 11
- 13
src/server/components/door.js Ver fichero

@@ -1,7 +1,7 @@
define([
], function(
], function (
) {
return {
type: 'door',
@@ -13,7 +13,7 @@ define([
openSprite: 157,
closedSprite: 156,

init: function(blueprint) {
init: function (blueprint) {
this.locked = blueprint.locked;
this.key = blueprint.key;

@@ -46,7 +46,7 @@ define([
}]);
},

exitArea: function(obj) {
exitArea: function (obj) {
if (!obj.player)
return;

@@ -60,7 +60,7 @@ define([
});
},

enterArea: function(obj) {
enterArea: function (obj) {
if (!obj.player)
return;

@@ -75,8 +75,7 @@ define([
msg = `You don't have the key to unlock this door`;
}
}
}
else
} else
msg = 'Press U to close this door';

if (canAction) {
@@ -96,8 +95,8 @@ define([
}, [obj.serverId]);
},

unlock: function(msg) {
if (!msg.sourceId)
unlock: function (msg) {
if (msg.sourceId == null)
return;

var obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
@@ -123,8 +122,7 @@ define([

this.closed = false;
this.enterArea(obj);
}
else {
} else {
thisObj.cell = this.closedSprite;
syncO.cell = this.closedSprite;
this.obj.instance.physics.setCollision(thisObj.x, thisObj.y, true);
@@ -134,4 +132,4 @@ define([
}
}
};
});
});

+ 9
- 9
src/server/components/syncer.js Ver fichero

@@ -1,6 +1,6 @@
define([

], function(
], function (

) {
return {
@@ -11,7 +11,7 @@ define([
oSelf: {
components: []
},
reset: function() {
reset: function () {
this.o = {
components: []
};
@@ -20,7 +20,7 @@ define([
components: []
};
},
get: function(self) {
get: function (self) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -37,7 +37,7 @@ define([

return o;
},
set: function(self, cpnType, property, value) {
set: function (self, cpnType, property, value) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -57,7 +57,7 @@ define([
o[property] = value;
}
},
setObject: function(self, cpnType, object, property, value) {
setObject: function (self, cpnType, object, property, value) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -78,7 +78,7 @@ define([

obj[property] = value;
},
setArray: function(self, cpnType, property, value) {
setArray: function (self, cpnType, property, value) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -97,7 +97,7 @@ define([
cpn[property].push(value);
},

setSelfArray: function(self, property, value) {
setSelfArray: function (self, property, value) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -108,7 +108,7 @@ define([
o[property].push(value);
},

delete: function(self, cpnType, property) {
delete: function (self, cpnType, property) {
var o = this.o;
if (self)
o = this.oSelf;
@@ -125,4 +125,4 @@ define([
}
}
};
});
});

+ 112
- 0
src/server/components/wardrobe.js Ver fichero

@@ -0,0 +1,112 @@
define([
'config/skins'
], function (
skins
) {
return {
type: 'wardrobe',

init: function (blueprint) {
var o = this.obj.instance.objects.buildObjects([{
properties: {
x: this.obj.x - 1,
y: this.obj.y - 1,
width: 3,
height: 3,
cpnNotice: {
actions: {
enter: {
cpn: 'wardrobe',
method: 'enterArea',
targetId: this.obj.id,
args: []
},
exit: {
cpn: 'wardrobe',
method: 'exitArea',
targetId: this.obj.id,
args: []
}
}
}
}
}]);
},

exitArea: function (obj) {
if (!obj.player)
return;

obj.syncer.setArray(true, 'serverActions', 'removeActions', {
key: 'u',
action: {
targetId: this.obj.id,
cpn: 'wardrobe',
method: 'access'
}
});

this.obj.instance.syncer.queue('onCloseWardrobe', null, [obj.serverId]);
},

enterArea: function (obj) {
if (!obj.player)
return;

var msg = `Press U to access the wardrobe`;

obj.syncer.setArray(true, 'serverActions', 'addActions', {
key: 'u',
action: {
targetId: this.obj.id,
cpn: 'wardrobe',
method: 'open'
}
});

this.obj.instance.syncer.queue('onGetAnnouncement', {
src: this.obj.id,
msg: msg
}, [obj.serverId]);
},

open: function (msg) {
if (msg.sourceId == null)
return;

var obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
if ((!obj) || (!obj.player))
return;

var thisObj = this.obj;
if ((Math.abs(thisObj.x - obj.x) > 1) || (Math.abs(thisObj.y - obj.y) > 1))
return;

obj.auth.getSkins({
callback: this.onGetSkins.bind(this, obj)
});
},

apply: function (msg) {
var obj = this.obj.instance.objects.objects.find(o => o.serverId == msg.sourceId);
if (!obj)
return;

obj.skinId = msg.skinId;

obj.cell = skins.getCell(obj.skinId);
obj.sheetName = skins.getSpritesheet(obj.skinId);

var syncer = obj.syncer;
syncer.set(false, null, 'cell', obj.cell);
syncer.set(false, null, 'sheetName', obj.sheetName);
},

onGetSkins: function (obj, skins) {
this.obj.instance.syncer.queue('onGetWardrobeSkins', {
id: this.obj.id,
skins: skins[obj.class]
}, [obj.serverId]);
}
};
});

+ 21
- 1
src/server/config/maps/tutorial/map.json Ver fichero

@@ -877,6 +877,26 @@
"width":8,
"x":912,
"y":456
},
{
"gid":690,
"height":8,
"id":709,
"name":"wardrobe",
"properties":
{
"cpnWardrobe":"{}"
},
"propertytypes":
{
"cpnWardrobe":"string"
},
"rotation":0,
"type":"",
"visible":true,
"width":8,
"x":920,
"y":376
}],
"opacity":1,
"properties":
@@ -2064,7 +2084,7 @@
"x":0,
"y":0
}],
"nextobjectid":709,
"nextobjectid":710,
"orientation":"orthogonal",
"properties":
{


+ 1
- 0
src/server/config/skins.js Ver fichero

@@ -86,6 +86,7 @@ define([
result[l.class] = [];

result[l.class].push({
name: l.name,
id: l.id,
sprite: l.sprite[0] + ',' + l.sprite[1],
spritesheet: l.spritesheet


+ 2
- 1
src/server/security/router.js Ver fichero

@@ -26,7 +26,8 @@ define([
equipment: ['equip', 'unequip'],
stash: ['withdraw'],
trade: ['buySell'],
door: ['lock', 'unlock']
door: ['lock', 'unlock'],
wardrobe: ['open', 'apply']
};

return ((secondaryAllowed[msg.data.cpn]) && (secondaryAllowed[msg.data.cpn].indexOf(msg.data.method) > -1));


Cargando…
Cancelar
Guardar