Comparing version 0.8.0 to 0.8.2
@@ -23,3 +23,3 @@ String.implement({ | ||
str = this.charAt(0).toUpperCase() + this.slice(1); | ||
if (!str.match(/[?!.]$/)) str = str+'.'; | ||
if (!str.match(/[?!\.]$/)) str = str+'.'; | ||
return str; | ||
@@ -26,0 +26,0 @@ }, |
@@ -58,3 +58,2 @@ Living = new Class({ | ||
if (name) this.set('name', name); | ||
this.startHeart(); | ||
this.create(); | ||
@@ -189,2 +188,3 @@ this.guid = String.uniqueID(); | ||
startHeart: function() { | ||
if (this.heartTimer) return; | ||
this.heartTimer = this.beatHeart.periodical(1000, this); | ||
@@ -219,3 +219,3 @@ }, | ||
*/ | ||
send: function(message, style) { | ||
send: function(message, style, raw) { | ||
if (!message) return; | ||
@@ -225,3 +225,3 @@ if (!message.each) message = [message]; | ||
if (!line || !line.charAt) return; | ||
line = line.charAt(0).toUpperCase() + line.substr(1); | ||
if (!raw) line = line.makeSentence(); | ||
this.logOutput(line); | ||
@@ -231,2 +231,6 @@ this.fireEvent('output', [line,style]); | ||
}, | ||
send_raw: function(message, style) { | ||
this.send(message, style, true); | ||
}, | ||
@@ -324,2 +328,6 @@ guiSend: function(message, handler) { | ||
if (!string) return; | ||
if (!this.room) { | ||
this.stopHeart(); | ||
delete(this); | ||
} | ||
@@ -326,0 +334,0 @@ string = string.trim(); |
@@ -40,3 +40,3 @@ Prompts = { | ||
command: function(data) { | ||
this.send("> "+data, 'prompt'); | ||
this.send_raw("> "+data, 'prompt'); | ||
this.queueCommand(data); | ||
@@ -43,0 +43,0 @@ } |
@@ -41,2 +41,3 @@ Room = new Class({ | ||
removeLiving: function(living) { | ||
living.stopHeart(); | ||
living.room = false; | ||
@@ -51,5 +52,7 @@ if (living.player) { | ||
addLiving: function(living) { | ||
living.startHeart(); | ||
if (living.player){ | ||
this.addPlayer(living); | ||
} else { | ||
living.startHeart(); | ||
this.addNPC(living); | ||
@@ -56,0 +59,0 @@ } |
@@ -172,2 +172,3 @@ var fs = require('fs'), | ||
var com = this.loadModule([world,engine], {rootPath:true}); | ||
var file_path = com.file_path; | ||
if (!com) { | ||
@@ -178,2 +179,3 @@ that.commands[command] = false; | ||
} | ||
that.commands[command].file_path = file_path; | ||
} return this.commands[command]; | ||
@@ -238,3 +240,3 @@ }, | ||
mob.game_path = path; | ||
mob.file_path = file; | ||
mob.file_path = this.npcs[path].file_path; | ||
return mob; | ||
@@ -322,2 +324,26 @@ | ||
reloadEngineModule: function(file_path) { | ||
var path = this.enginePath+file_path,bkup; | ||
console.log(path.color('green')); | ||
if (require.cache[path+'.js']) { | ||
bkup = require.cache[path+'.js']; | ||
delete(require.cache[path+'.js']); | ||
try { | ||
require(path); | ||
} catch (e) { | ||
require.cache[path+'.js'] = bkup; | ||
return false; | ||
} | ||
return true; | ||
} | ||
}, | ||
reloadCommand: function(command) { | ||
com = this.getCommand(command); | ||
if (!com) return; | ||
delete(this.commands[command]); | ||
delete(require.cache[com.file_path+'.js']); | ||
return true; | ||
}, | ||
reloadItem: function(object) { | ||
@@ -347,5 +373,14 @@ delete(this.items[object.game_path]); | ||
reloadNPC: function(object) { | ||
var success = this.reloadModule(object.file_path); | ||
if (!success) return false; | ||
delete(this.npcs[object.game_path]); | ||
this.reloadModule(object.file_path); | ||
return this.loadNPC(object.game_path); | ||
var room = object.get('room'), | ||
replacement = this.loadNPC(object.game_path); | ||
if (replacement) { | ||
room.removeLiving(object); | ||
room.addLiving(replacement); | ||
return replacement; | ||
} else { | ||
return false; | ||
} | ||
}, | ||
@@ -352,0 +387,0 @@ |
@@ -9,2 +9,3 @@ module.exports = new Class({ | ||
this.add_syntax('<living>', 'reload_living'); | ||
this.add_syntax('<string>', 'reload_something'); | ||
this.add_syntax('', 'reload_room'); | ||
@@ -36,2 +37,4 @@ }, | ||
this.emit("%You wave%s %your hands about in an arcane manner."); | ||
if (holder instanceof Living) { | ||
@@ -64,5 +67,55 @@ holder.emit("%Your "+ object.get('definite') +" disappears in a "+ | ||
reload_living: function(l) { | ||
this.send("ZOMG"); | ||
this.emit( | ||
"%You chant%s something under %your breath while peering at "+ | ||
l.get('definite') | ||
); | ||
if (l.player && l.name == this.name) { | ||
this.send("You reload yourself."); | ||
} | ||
if (l.player) { | ||
this.send( | ||
l.get('definite')+" is a human, what would you reload?" | ||
); | ||
return false; | ||
} | ||
var replacement = this.world.reloadNPC(l); | ||
if (replacement) { | ||
replacement.emit( | ||
"%You look%s startled as %you disappears into thin air for "+ | ||
"a moment." | ||
); | ||
} else { | ||
l.emit("%You cock%s %his at %them, confused.", this); | ||
this.send( | ||
"Failed to reload "+l.get('definite')+". Check for bugs!" | ||
); | ||
} | ||
}, | ||
reload_something: function(words) { | ||
var andThen = "Nothing happens.", success = false; | ||
if (this.world.reloadEngineModule(words)) { | ||
andThen = "The core mechanics of the universe seem to be "+ | ||
"different somehow."; | ||
success = true; | ||
} else if (this.world.reloadCommand(words)) { | ||
andThen = "The rules of '"+words+"' seem to have changed."; | ||
this.send(andThen); | ||
success = true; | ||
} | ||
this.emit("%You hop%s about mysteriously. "+andThen); | ||
if (!success) { | ||
this.send( | ||
"Sorry, the "+words+" command either can't be found or "+ | ||
"isn't working. Try checking for bugs." | ||
); | ||
} | ||
} | ||
}); |
@@ -11,3 +11,3 @@ module.exports = new Class({ | ||
this.emit( | ||
"%You huggle%s "+target.get('definite')+".", | ||
"%You huggle%s "+target.get('definite')+" the rat.", | ||
target | ||
@@ -14,0 +14,0 @@ ); |
{ | ||
"name":"discord", | ||
"description":"A LP/Discworld inspired MUD server running on Node.JS and MooTools.", | ||
"version":"0.8.0", | ||
"version":"0.8.2", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -22,3 +22,4 @@ /** | ||
log_error = function (e) { | ||
console.log("ERROR:".color('red'), e.stack); | ||
console.log("ERROR:".color('red'), e ); | ||
console.log(e.stack || console.trace()); | ||
} | ||
@@ -25,0 +26,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133689
3396
7