12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- module.exports = class PhandalinLionshieldCoster {
- constructor() {
- this.id = this.constructor.name;
- this.name = "The Lionshield Coster";
- this.description = "A vast warehouse of armor, weapons and adventuring supplies. There are blue banners with white lionheads decorating the walls. A large wooden board above the counter displays a {hint}list{/hint} of the items for sale here.";
- this.filename = "phandalin/lionshieldcoster.js";
- this.type = "room";
- this.items = [];
- this.mobiles = [];
- this.roomExpires = 0;
- this.resetDelay = 12000000;
- this.roomExits = ["leave"];
- this.shopInventory = [];
- }
- mud_reset(time) {
- libs.Output.toRoom(this.id, "Sunlight from the windows glints off a shield on the wall.");
- this.roomExpires = time + this.resetDelay;
- }
- mud_tick(time) {
- if(time >= this.roomExpires) {
- this.mud_reset(time);
- }
- }
- mud_getName() {
- return this.name;
- }
- mud_getDescription() {
- return this.description;
- }
- leave(room, mobile, input) {
- world.mud_moveMobile(mobile.id, this.id, "PhandalinRoad5", "leaves", "leave the Coster");
- return true;
- }
- list(room, mobile, input) {
- for(var itemIndex in this.shopInventory) {
- var shopItem = world.mud_getItem(this.shopInventory[itemIndex]);
- if(typeof shopItem.mud_getName == "function") {
- libs.Output.toMobile(mobile.id, shopItem.mud_getName() + " - $" + shopItem.value);
- } else {
- libs.Output.toMobile(mobile.id, "{"+shopItem.type+"}" + shopItem.name + "{/"+shopItem.type+"} - $" + shopItem.value);
- }
- }
- return true;
- }
- sell(room, mobile, input) {
- if(input.join(" ") == null) {
- return false;
- }
- var inventoryItem = libs.Utilities.getSpecific(input.join(" "), mobile.items, session.items);
- if(inventoryItem == null) {
- libs.Output.toMobile(mobile.id, "You don't seem to have '" + input.join(" ") + "'.");
- return true;
- }
- world.mud_removeItemFromMobile(mobile.id, inventoryItem.id);
- this.shopInventory.push(inventoryItem.id);
- //TODO: give money to mobile
- libs.Output.toMobile(mobile.id, "You sell " + inventoryItem.name + " for " + inventoryItem.value + ".");
- libs.Output.toRoom(room.id, mobile.name + " sells "+inventoryItem.name+" to the shop.", mobile);
- return true;
- }
- value(room, mobile, input) {
- libs.Output.toMobile(mobile.id, "value");
- //libs.Output.toRoom(room.id, mobile.name + " tries to open the door but fails.", mobile);
- return true;
- }
- info(room, mobile, input) {
- libs.Output.toMobile(mobile.id, "info of");
- //libs.Output.toRoom(room.id, mobile.name + " tries to open the door but fails.", mobile);
- return true;
- }
- buy(room, mobile, input) {
- if(input.join(" ") == null) {
- return false;
- }
- var shopItem = libs.Utilities.getSpecific(input.join(" "), this.shopInventory, session.items);
- if(shopItem == null) {
- libs.Output.toMobile(mobile.id, "The shop doesn't seem to have '" + input.join(" ") + "'.");
- return true;
- }
- world.mud_addItemToMobile(mobile.id, shopItem.id);
- this.shopInventory.splice(this.shopInventory.indexOf(shopItem.id), 1);
- //TODO: take money from mobile
- libs.Output.toMobile(mobile.id, "You buy " + shopItem.name + " for " + shopItem.value + ".");
- libs.Output.toRoom(room.id, mobile.name + " buys "+shopItem.name+" from the shop.", mobile);
- return true;
- }
- };
|