1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- module.exports = class WoodenSword {
- constructor() {
- this.id = 0;
- this.name = "a wooden sword";
- this.description = "This training sword has seen a lot of action and is a little splintered on the edges. It would serve pretty well as a weapon if you were to {hint}hold{/hint} it.";
- this.type = "item";
- this.keywords = ["sword"];
- this.resetDelay = 12000000;
- this.itemExpires = 0;
- this.filename = "woodensword.js";
- this.heldBy = -1;
- this.isWorn = -1;
- this.inRoom = -1;
- this.value = 75;
- 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;
- }
- attack(room, mobile, input) {
- if(this.isWorn == mobile.id) {
- if(!room.isCombatZone) {
- libs.Output.toMobile(mobile.id, "You lose your grip on " + this.mud_getName() + ".");
-
- var slotKey = Object.keys(mobile.itemSlots).find(key => mobile.itemSlots[key] === this.id);
- mobile.itemSlots[slotKey] = null;
- this.isWorn = -1;
- return true;
- }
- libs.Output.toMobile(mobile.id, "You swing your sword gracefully with large swooping motions.");
- libs.Output.toRoom(mobile.roomId, mobile.mud_getName() + " swings " + this.mud_getName() + " wildly, almost losing balance.", mobile);
- return true;
- } else if(this.isWorn != mobile.id) {
- libs.Output.toMobile(mobile.id, "You would have to {hint}wield{/hint} a weapon first.");
- return true;
- }
- }
- }
|