Skip to content

Commit

Permalink
clean up login, can now pass a room to look command to avoid the lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
MoreOutput committed Jul 20, 2016
1 parent f4c3633 commit 9b1e025
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/character.js
Expand Up @@ -218,8 +218,15 @@ Character.prototype.create = function(r, s, fn) {
if (!Cmds) {
Cmds = require('./commands').cmd;
}

roomObj = World.getRoomObject(s.player.area, s.player.roomid);

roomObj.playersInRoom.push(s.player);

Cmds.look(s.player);
Cmds.look(s.player, {
roomObj: roomObj,
msg: ''
});

fn(s);
} else {
Expand Down Expand Up @@ -313,8 +320,8 @@ Character.prototype.newCharacter = function(r, s, fn) {

if (classes.length - 1 === i) {
s.emit('msg', {
msg: 'Great, <strong>two more steps to go!</strong> Now time to select a class for ' + s.player.name +
'. Pick one of the following: <ul>' +
msg: 'Great, <strong>two more steps to go!</strong> Now time to select a class for '
+ s.player.name + '. Pick one of the following: <ul>' +
str + '</ul>',
res: 'selectClass',
styleClass: 'race-selection'
Expand All @@ -328,8 +335,9 @@ Character.prototype.newCharacter = function(r, s, fn) {
s.player.charClass = r.msg;

s.emit('msg', {
msg: s.player.name + ' is a ' + s.player.charClass + '! <strong>One more step before ' + s.player.name +
' is saved</strong>. Please define a password (8 or more characters):',
msg: s.player.name + ' is a ' + s.player.charClass
+ '! <strong>One more step before ' + s.player.name
+ ' is saved</strong>. Please define a password (8 or more characters):',
res: 'createPassword',
styleClass: 'race-selection'
});
Expand All @@ -343,7 +351,10 @@ Character.prototype.newCharacter = function(r, s, fn) {
}
});
} else {
s.emit('msg', {msg: 'That class is not on the list, please try again', styleClass: 'error' });
s.emit('msg', {
msg: 'That class is not on the list, please try again',
styleClass: 'error'
});
}
});
});
Expand Down
8 changes: 7 additions & 1 deletion src/commands.js
Expand Up @@ -1180,7 +1180,7 @@ Cmd.prototype.kill = function(player, command, roomObj, fn) {
};

Cmd.prototype.look = function(target, command) {
var roomObj = World.getRoomObject(target.area, target.roomid),
var roomObj,
displayHTML,
monster,
// boolean. when it is false it indicates we need a light source to see.
Expand All @@ -1190,6 +1190,12 @@ Cmd.prototype.look = function(target, command) {
itemDescription,
item, // looking at an item
i = 0;

if (!command || !command.roomObj) {
roomObj = World.getRoomObject(target.area, target.roomid);
} else {
roomObj = command.roomObj;
}

if (canSee) {
canSee = Character.canSee(target, roomObj);
Expand Down

0 comments on commit 9b1e025

Please sign in to comment.