1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- module.exports = class Pickaxe {
- constructor() {
- this.id = 0;
- this.name = "a pickaxe";
- this.description = "An iron pickaxe with a rough wooden handle. The head has spots of rust and the point is a little worn, but it would still work fine for {hint}mining{/hint}.";
- this.type = "item";
- this.keywords = ["pick", "pickaxe", "tool"];
- this.resetDelay = 12000000;
- this.mud_reset(0);
- this.filename = "pickaxe.js";
- this.heldBy = -1;
- this.isWorn = -1;
- this.inRoom = -1;
- this.value = 25;
- this.itemSlot = libs.ItemSlot.MainHand;
- }
- mud_reset(time) {
- this.itemExpires = time + this.resetDelay;
- }
- mud_tick(time) {
- if(time >= this.itemExpires) {
- this.mud_reset(time);
- }
- }
- mud_getName() {
- var dispName = "{item}"+this.name+"{/item}";
- if(this.isWorn != -1) {
- dispName += " (wielded)";
- }
- return dispName;
- }
- mud_getDescription() {
- return this.description;
- }
- mine(room, mobile, input) {
- if(this.isWorn == mobile.id) {
- if(room.isMiningPoint) {
- var itemName = room.mineItems.shift();
- if(itemName == null) {
- libs.Output.toMobile(mobile.id, "You swing your pickaxe a few times but don't find anything.");
- libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " mines some ore.", mobile);
- return true;
- }
- libs.Output.toMobile(mobile.id, "You swing your pickaxe a few times and break off some ore.");
- libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " mines some ore.", mobile);
-
- var minedItem = builder.mud_spawnItem(itemName);
- if(typeof minedItem.mud_getName == "function") {
- libs.Output.toMobile(mobile.id, "You receive " + minedItem.mud_getName() + "!");
- } else {
- libs.Output.toMobile(mobile.id, "You receive {item}" + minedItem.mud_getName() + "{/item}!");
- }
-
- world.mud_addItemToMobile(mobile.id, minedItem.id);
- return true;
- }
- libs.Output.toMobile(mobile.id, "You swing your pickaxe and smash a small stone to bits.");
- libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " swings " + this.mud_getName() + " haphazardly.", mobile);
- return true;
- } else if(this.isWorn != mobile.id) {
- libs.Output.toMobile(mobile.id, "You would have to {hint}hold{/hint} a pickaxe first.");
- return true;
- }
- }
- }
|