123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- module.exports = class PlayerMobile {
- constructor() {
- this.id = 0;
- this.login = null;
- this.name = "";
- this.description = "A player.";
- this.type = "mobile";
- this.roomId = "ZebedeeTemple";
- this.filename = "playermobile.js";
- this.keywords = [];
- this.items = [];
- this.health = 100;
- this.maxHealth = 100;
- this.roles = [];
- this.memory = {};
- this.title = "the player";
- this.account = 0;
- this.itemSlots = {};
- this.aliases = {};
- }
- mud_sendMessage(source, message) {
- this.login.sendMessage(message);
- }
- mud_addMemory(section, newMemory) {
- if(!this.memory.hasOwnProperty(section)) {
- this.memory[section] = [];
- }
- this.memory[section].push(memory);
- }
- mud_checkMemory(section, memoryToCheck) {
- if(this.memory.hasOwnProperty(section)) {
- if(this.memory[section].hasOwnProperty(memory)) {
- return true;
- }
- }
- return false;
- }
- mud_addCurrency(amount) {
- this.account += amount;
- }
- mud_removeCurrency(amount) {
- this.account -= amount;
- this.account = Math.max(0, this.account);
- }
- mud_tick(time) {
- if(this.health != this.maxHealth) {
- this.health++;
- this.hp();
- }
- }
- mud_getName() {
- return "{mobile}" + this.name + "{/mobile}";
- }
- mud_getDescription() {
- return this.description;
- }
- mud_wearInSlot(itemId, slot) {
- if(this.itemSlots.hasOwnProperty(slot) && this.itemSlots[slot] != null) {
- return this.itemSlots[slot];
- }
- this.itemSlots[slot] = itemId;
- }
- mud_removeSlot(slot) {
- if(!this.itemSlots.hasOwnProperty(slot) || this.itemSlots[slot] == null) {
- return false;
- }
- this.itemSlots[slot] = null;
- }
- mud_hasEquipped(itemName) {
- for(var index in this.itemSlots) {
- var slot = this.itemSlots[index];
- if(slot != null) {
- if(world.mud_getItem(slot).constructor.name == itemName) {
- return true;
- }
-
- }
- }
- if(Object.keys(this.itemSlots).length > 0) {
- var inventoryItem = libs.Utilities.getSpecific(itemName, Object.values(this.itemSlots), session.items);
- if(inventoryItem != null) {
- return true;
- }
- }
- return false;
- }
- mud_setAlias(aliasKey, instructions) {
- this.aliases[aliasKey] = instructions;
- var commands = instructions.split(";");
- this[aliasKey] = function() {
- for(var index in commands) {
- var command = commands[index];
- world.mud_handleInput(this.roomId, this.id, command.split(" "));
- }
- };
- }
- hp(room, mobile, input) {
- libs.Output.toMobile(mobile.id, "[HP: "+mobile.health+"/" +mobile.maxHealth+"]");
- return true;
- }
- quit(room, mobile, input) {
- this.login.logout();
- return true;
- }
- save(room, mobile, input) {
- libs.Output.toMobile(mobile.id, "Saving player information.");
- world.mud_playerSave(this);
- libs.Output.toMobile(mobile.id, "Saved successfully.");
- return true;
- }
- hint(room, mobile, input) {
- if(["on", "please"].indexOf(input[0]) != -1) {
- mobile.hintColor = "FgMagenta";
- libs.Output.toMobile(mobile.id, "Enabling hints.");
- return true;
- }
- if (["off"].indexOf(input[0]) != -1) {
- mobile.hintColor = "Reset";
- libs.Output.toMobile(mobile.id, "Disabling hints.");
- return true;
- }
- libs.Output.toMobile(mobile.id, "hint [on|off] - controls highlighting in description text.");
- return true;
- }
- setting(room, mobile, input) {
-
- }
- chpass(room, mobile, input) {
- var username = mobile.name.toLowerCase();
- mobile.password = world.mud_generateHash(username + input.join(" "));
- world.mud_playerSave(mobile);
- libs.Output.toMobile(mobile.id, "Password has been updated!");
- return true;
- }
- };
|