From 993635fe780d3eaa262e7fa8602761c775efd816 Mon Sep 17 00:00:00 2001 From: Aaron Vienneau Date: Sun, 2 Jun 2019 20:35:28 -0400 Subject: [PATCH 01/10] Loading A Player From an Invalid Room (#72) --- src/AreaManager.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AreaManager.js b/src/AreaManager.js index 1b35a103..6f741fc4 100644 --- a/src/AreaManager.js +++ b/src/AreaManager.js @@ -1,6 +1,8 @@ 'use strict'; const BehaviorManager = require('./BehaviorManager'); +const Area = require('./Area'); +const Room = require('./Room'); /** * Stores references to, and handles distribution of, active areas From e6d50d231a179a0d4b1c300005b4100b94613f96 Mon Sep 17 00:00:00 2001 From: Alexander Morse Date: Sun, 2 Jun 2019 20:37:08 -0400 Subject: [PATCH 02/10] fix result of PlayerManager's getBroadcastTargets (#78) --- src/PlayerManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PlayerManager.js b/src/PlayerManager.js index 32b5f481..ec92a7eb 100644 --- a/src/PlayerManager.js +++ b/src/PlayerManager.js @@ -183,7 +183,7 @@ class PlayerManager extends EventEmitter { * @return {Array} */ getBroadcastTargets() { - return this.players; + return this.getPlayersAsArray(); } } From c9106af1fa520b5464276b1073f3416a6f75bb57 Mon Sep 17 00:00:00 2001 From: Tony McNulty Date: Mon, 3 Jun 2019 01:37:57 +0100 Subject: [PATCH 03/10] Remove old code (#82) --- src/PlayerManager.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/PlayerManager.js b/src/PlayerManager.js index ec92a7eb..21a99cdb 100644 --- a/src/PlayerManager.js +++ b/src/PlayerManager.js @@ -159,10 +159,6 @@ class PlayerManager extends EventEmitter { async saveAll() { for (const [ name, player ] of this.players.entries()) { await this.save(player); - /** - * @event Player#save - */ - player.emit('saved', playerCallback); } } From 4ce0ac1b79f0c07b4b435267b7b86d0db6435c7e Mon Sep 17 00:00:00 2001 From: Tony McNulty Date: Mon, 3 Jun 2019 01:39:44 +0100 Subject: [PATCH 04/10] Handle quests without rewards (#81) --- src/QuestFactory.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/QuestFactory.js b/src/QuestFactory.js index c714307f..f65422c4 100644 --- a/src/QuestFactory.js +++ b/src/QuestFactory.js @@ -97,6 +97,11 @@ class QuestFactory { player.emit('questComplete', instance); player.questTracker.complete(instance.entityReference); + if (!quest.config.rewards) { + player.save(); + return; + } + for (const reward of quest.config.rewards) { try { const rewardClass = GameState.QuestRewardManager.get(reward.type); From 4c2138193c15169e97ade001985814c4b4707b11 Mon Sep 17 00:00:00 2001 From: Daniel <2941686+thedandroid@users.noreply.github.com> Date: Sun, 2 Jun 2019 20:40:20 -0400 Subject: [PATCH 05/10] Fix logging to file (#77) --- src/Logger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logger.js b/src/Logger.js index 1a169b6b..4f07c8c9 100644 --- a/src/Logger.js +++ b/src/Logger.js @@ -59,7 +59,7 @@ class Logger { path += logExt; } console.log("Adding file logging at " + path); - winston.add(winston.transports.File, { path, timestamp: true }); + winston.add(winston.transports.File, { filename: path, timestamp: true }); } static deactivateFileLogging() { From e0b333a36cd52bcf6686bf52d772a135e2158fb1 Mon Sep 17 00:00:00 2001 From: Brian Nelson <41605807+nelsonsbrian@users.noreply.github.com> Date: Sun, 2 Jun 2019 17:41:05 -0700 Subject: [PATCH 06/10] Fix docblock typo (#75) --- src/QuestTracker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuestTracker.js b/src/QuestTracker.js index 93c68f29..7ccbb6f3 100644 --- a/src/QuestTracker.js +++ b/src/QuestTracker.js @@ -68,7 +68,7 @@ class QuestTracker { } /** - * @param {Quest} queset + * @param {Quest} quest */ start(quest) { const qid = quest.entityReference; From b9e51001c642850eecc0982accd31cda3b04faf7 Mon Sep 17 00:00:00 2001 From: Brian Nelson <41605807+nelsonsbrian@users.noreply.github.com> Date: Sun, 2 Jun 2019 17:45:28 -0700 Subject: [PATCH 07/10] Actually use the account.serialize() when saving. (#84) --- src/Account.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Account.js b/src/Account.js index aee2cf27..c144a5d1 100644 --- a/src/Account.js +++ b/src/Account.js @@ -86,7 +86,7 @@ class Account { * @param {function} callback after-save callback */ save(callback) { - Data.save('account', this.username, this, callback); + Data.save('account', this.username, this.serialize(), callback); } /** From 2b1f779ea9a3a7e154f490f4f015d37ee8433676 Mon Sep 17 00:00:00 2001 From: Jared Date: Sun, 2 Jun 2019 18:47:42 -0600 Subject: [PATCH 08/10] Give NPCs a commandQueue to allow for more dynamic combat. (#85) --- src/Npc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Npc.js b/src/Npc.js index d0637041..2d12b436 100644 --- a/src/Npc.js +++ b/src/Npc.js @@ -6,6 +6,7 @@ const Character = require('./Character'); const Config = require('./Config'); const Logger = require('./Logger'); const Scriptable = require('./Scriptable'); +const CommandQueue = require('./CommandQueue'); /** * @property {number} id Area-relative id (vnum) @@ -37,6 +38,7 @@ class Npc extends Scriptable(Character) { this.keywords = data.keywords; this.quests = data.quests || []; this.uuid = data.uuid || uuid(); + this.commandQueue = new CommandQueue(); } /** From db575bc6d6439663b75bb9db5ba35009ded733ca Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 9 Aug 2019 19:54:16 -0600 Subject: [PATCH 09/10] allow for N levels of metadata through setMeta (#89) Pretty sure this was supposed to be a shift(). --- src/Metadatable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Metadatable.js b/src/Metadatable.js index a4878b99..d07ee9b6 100644 --- a/src/Metadatable.js +++ b/src/Metadatable.js @@ -33,7 +33,7 @@ class extends parentClass { let base = this.metadata; while (parts.length) { - let part = parts.pop(); + let part = parts.shift(); if (!(part in base)) { throw new RangeError(`Metadata path invalid: ${key}`); } From 46715b7ecc305b59b061067e83fe38cd7d91ddab Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 9 Aug 2019 19:55:04 -0600 Subject: [PATCH 10/10] Make sure metadata objects are unique (#90) --- src/Character.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Character.js b/src/Character.js index 8b63883c..493401ce 100644 --- a/src/Character.js +++ b/src/Character.js @@ -45,7 +45,11 @@ class Character extends Metadatable(EventEmitter) { // Arbitrary data bundles are free to shove whatever they want in // WARNING: values must be JSON.stringify-able - this.metadata = data.metadata || {}; + if (data.metadata) { + this.metadata = JSON.parse(JSON.stringify(data.metadata)); + } else { + this.metadata = {}; + } } /**