Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RanvierMUD/core
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean O'Donohue committed Oct 3, 2019
2 parents d28f876 + 46715b7 commit fe6c2ab
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/AreaManager.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/Metadatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Npc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/PlayerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -183,7 +179,7 @@ class PlayerManager extends EventEmitter {
* @return {Array<Character>}
*/
getBroadcastTargets() {
return this.players;
return this.getPlayersAsArray();
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/QuestFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/QuestTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class QuestTracker {
}

/**
* @param {Quest} queset
* @param {Quest} quest
*/
start(quest) {
const qid = quest.entityReference;
Expand Down

0 comments on commit fe6c2ab

Please sign in to comment.