Skip to content

Commit

Permalink
Merge pull request #239 from markbmullins/quest-journal-fix
Browse files Browse the repository at this point in the history
Fixed error when opening quest journal
  • Loading branch information
Tynarus authored Dec 6, 2020
2 parents 448cc3c + 179570b commit 362b522
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/plugins/quests/quest-journal-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ import { pluginActions } from '@server/game-server';

export const action: buttonAction = (details) => {
const { player, buttonId } = details;
const [questData] = pluginActions.quest.filter((quest) => quest.quest.questTabId === buttonId);
if(!questData) {
return;
}
const quest = questData.quest;

const quests = pluginActions.quest;
const questData = quests[Object.keys(quests).filter(questKey => quests[questKey].questTabId === buttonId)[0]];
const playerQuest = player.quests.find(quest => quest.questId === questData.id);
let playerStage = 'NOT_STARTED';
const [playerQuest] = player.quests.filter(
(playerQuest) => playerQuest.questId === quest.questTabId
);

if(playerQuest && playerQuest.stage) {
let playerStage = "NOT_STARTED";
if (playerQuest && playerQuest.stage) {
playerStage = playerQuest.stage;
}

let stageText = questData.stages[playerStage];
let stageText = quest.stages[playerStage];
let color = 128;

if(typeof stageText === 'function') {
Expand All @@ -32,7 +37,7 @@ export const action: buttonAction = (details) => {
lines = [ 'Invalid Quest Stage' ];
}

player.modifyWidget(widgets.questJournal, { childId: 2, text: '@dre@' + questData.name });
player.modifyWidget(widgets.questJournal, { childId: 2, text: '@dre@' + quest.name });

for(let i = 0; i <= 100; i++) {
if(i === 0) {
Expand Down

0 comments on commit 362b522

Please sign in to comment.