Comparing version 0.0.4 to 0.0.5
@@ -28,6 +28,6 @@ /** | ||
exports = module.exports = advtxt.Server = function() { | ||
var self = this; | ||
var self = this; | ||
self.db = null; | ||
self.initialized = false; | ||
self.initialized = false; | ||
} | ||
@@ -102,6 +102,6 @@ | ||
command.player.items = {}; // clear the player's items array | ||
command.reply(i18n.__("Giving you a blank slate…")); | ||
command.replies.push(i18n.__("Giving you a blank slate…")); | ||
} | ||
else { | ||
command.reply(i18n.__("Moving you to the origin room…")); | ||
command.replies.push(i18n.__("Moving you to the origin room…")); | ||
} | ||
@@ -221,3 +221,3 @@ | ||
else { | ||
command.reply(__.i18n("I don't know what you mean.")); | ||
command.replies.push(__.i18n("I don't know what you mean.")); | ||
} | ||
@@ -250,3 +250,3 @@ | ||
player.items[object] = room.items[object].name; | ||
command.reply(room.items[object].get(player)); | ||
command.replies.push(room.items[object].get(player)); | ||
// update the player | ||
@@ -257,3 +257,4 @@ self.updatePlayerItems(command, self.finalize.bind(self)); | ||
else { | ||
command.reply(available); | ||
command.replies.push(available); | ||
self.finalize(command); | ||
} | ||
@@ -263,3 +264,4 @@ } | ||
else { | ||
command.reply(i18n.__('You can\'t find a "%s" in this room!', object)); | ||
command.replies.push(i18n.__('You can\'t find a "%s" in this room!', object)); | ||
self.finalize(command); | ||
} | ||
@@ -273,3 +275,3 @@ } | ||
// that direction was available, play the "go" message, then move them | ||
command.reply(room.exits[object].go(player)); | ||
command.replies.push(room.exits[object].go(player)); | ||
// move the player | ||
@@ -280,3 +282,4 @@ self.movePlayer(command, object); | ||
else { | ||
command.reply(available); | ||
command.replies.push(available); | ||
self.finalize(command); | ||
} | ||
@@ -287,3 +290,4 @@ } | ||
// TODO give customized replies for actual directions | ||
command.reply(i18n.__('You can\'t go "%s", it just doesn\'t work.', object)); | ||
command.replies.push(i18n.__('You can\'t go "%s", it just doesn\'t work.', object)); | ||
self.finalize(command); | ||
} | ||
@@ -293,3 +297,4 @@ } | ||
else if (typeof room.commands[verb] !== 'undefined') { | ||
command.reply(room.commands[verb](player)); | ||
command.replies.push(room.commands[verb](player)); | ||
self.finalize(command); | ||
} | ||
@@ -308,6 +313,8 @@ // if they asked for the exits, list them | ||
} | ||
command.reply(exitNames); | ||
command.replies.push(exitNames); | ||
self.finalize(command); | ||
} | ||
else { | ||
command.reply(i18n.__('Sorry, I don\'t know how to "%s" in this room.', verb)); | ||
command.replies.push(i18n.__('Sorry, I don\'t know how to "%s" in this room.', verb)); | ||
self.finalize(command); | ||
} | ||
@@ -353,3 +360,3 @@ } | ||
if (enterRoom) { | ||
command.reply(player.room.description); | ||
command.replies.push(player.room.description); | ||
self.finalize(command); | ||
@@ -413,6 +420,6 @@ } | ||
if (command.player.status === 'dead') { | ||
command.reply(i18n.__('You\'ve died! Send the command `reset all` to try again!')); | ||
command.replies.push(i18n.__('You\'ve died! Send the command `reset all` to try again!')); | ||
} | ||
else if (command.player.status === 'win') { | ||
command.reply(i18n.__('You\'ve won the game! How impressive! Send the command `reset all` to play again!')); | ||
command.replies.push(i18n.__('You\'ve won the game! How impressive! Send the command `reset all` to play again!')); | ||
} | ||
@@ -422,8 +429,11 @@ self.updatePlayerStatus(command); | ||
else if (command.player.status === 'dead') { | ||
command.reply(i18n.__('You\'re still dead! Send the command `reset all` to try again!')); | ||
command.replies.push(i18n.__('You\'re still dead! Send the command `reset all` to try again!')); | ||
} | ||
else if (command.player.status === 'win') { | ||
command.reply(i18n.__('Yes, your win was glorious, but send the command `reset all` to play again!')); | ||
command.replies.push(i18n.__('Yes, your win was glorious, but send the command `reset all` to play again!')); | ||
} | ||
// now send the replies out to the reply function | ||
command.done(command); | ||
} | ||
{ | ||
"name": "advtxt", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "index", |
AdvTxt | ||
====== | ||
A text adventure engine. | ||
A Node.js text adventure engine. | ||
@@ -9,3 +9,5 @@ Installation | ||
``` | ||
Currently this project is unstable and shouldn't be relied upon by anyone. | ||
```sh | ||
npm install advtxt | ||
@@ -19,3 +21,3 @@ ``` | ||
``` | ||
```js | ||
var config = { | ||
@@ -42,8 +44,11 @@ adapter: 'mongodb', | ||
``` | ||
```js | ||
var command = { | ||
command: "Your command text", | ||
player: "playerName", | ||
reply: function(message) { | ||
console.log(message); | ||
replies: [], | ||
done: function(command) { | ||
command.replies.forEach (function(reply) { | ||
console.log(reply); | ||
}); | ||
} | ||
@@ -59,2 +64,6 @@ }; | ||
- **v0.0.5** | ||
- Now pushes replies into an array of messages; any reply handling modules will need to be updated. | ||
- **v0.0.4** | ||
- Adds a new command parser with support for aliases. | ||
- **v0.0.3** | ||
@@ -61,0 +70,0 @@ - Moves MongoDB interface to its own [lightweight adapter][advtxtmongo] |
20696
517
95