communication.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module.exports = class Communication {
  2. help(room, mobile, input) {
  3. var topic = input.join(" ").trim();
  4. switch(topic) {
  5. case "say":
  6. libs.Output.toMobile(mobile.id, "Since MUDs are multiplayer, being able to communicate with other players is pretty important. You can use this command to talk with players and NPCs.");
  7. libs.Output.toMobile(mobile.id, "* say [message] - will cause your character to say the message to the room you are currently in.");
  8. return true;
  9. case "shout":
  10. libs.Output.toMobile(mobile.id, "You can communicate to everyone across the server using this command");
  11. libs.Output.toMobile(mobile.id, "* shout [message] - will cause your character to shout the message to the entire server.");
  12. return true;
  13. }
  14. }
  15. say(room, mobile, input) {
  16. var message = input.join(" ");
  17. libs.Output.toMobile(mobile.id, "You say '" + message + "'", mobile);
  18. libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " says '" + message + "'", mobile);
  19. return true;
  20. }
  21. shout(room, mobile, input) {
  22. var message = input.join(" ");
  23. libs.Output.toMobile(mobile.id, "{global}You shout '" + message + "'{/global}", mobile);
  24. libs.Output.worldToMobiles("{global}" + mobile.mud_getName() + " shouts '" + message + "'{/global}", mobile);
  25. libs.Output.toServer(mobile.mud_getName() + " shouts '" + message + "'");
  26. return true;
  27. }
  28. emote(room, mobile, input) {
  29. var message = input.join(" ");
  30. libs.Output.toMobile(mobile.id, "You emote: '" + message + "'", mobile);
  31. libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " " + message, mobile);
  32. return true;
  33. }
  34. announce(room, mobile, input) {
  35. libs.Output.toMobile(mobile.id, "You announce your stats:", mobile);
  36. var hpPercent = parseInt(100*(mobile.health / mobile.maxHealth));
  37. libs.Output.toMobile(mobile.id, "HP: "+ hpPercent + "%");
  38. libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + ": HP is " + hpPercent + "%");
  39. return true;
  40. }
  41. mud_getErrorMessage() {
  42. return "A {error}glitch{/error} appears in your mouth and prevents you from speaking.";
  43. }
  44. };