Skip to content

Commit

Permalink
Fixing a bug causing dialogue to crash and fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Katilith committed Jun 29, 2023
1 parent 39978a0 commit 0cff06b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 0 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions src/engine/world/actor/dialogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,17 @@ function parseDialogueTree(player: Player, npcParticipants: NpcParticipant[], di
}
}

console.log('npc:', npc);

dialogueDetails = dialogueAction(npc);

if (npc === -1) {
throw new Error('No npc found for dialogue action.');
}
} else {
dialogueDetails = dialogueAction(player);
}

// TODO (Jameskmonger) not sure if this check is needed, added it when getting TypeScript types into strict mode
if (npc === -1) {
throw new Error('No npc found for dialogue action.');
}

const emote = dialogueDetails[0] as Emote;
const text = carryoverDialogue.join(' ') + dialogueDetails[1] as string;
carryoverDialogue = [];
Expand Down Expand Up @@ -582,10 +583,10 @@ async function runDialogueAction(player: Player, dialogueAction: string | Dialog

if (dialogueAction.type === 'NPC') {
npcId = (dialogueAction as NpcDialogueAction).npcId;
}
// TODO (Jameskmonger) not sure if this check is needed, added it when getting TypeScript types into strict mode
if (npcId === -1) {
throw new Error('No npc found for dialogue action.');

if (npcId === -1) {
throw new Error('No npc found for dialogue action.');
}
}

const actorDialogueAction = dialogueAction as ActorDialogueAction;
Expand Down

0 comments on commit 0cff06b

Please sign in to comment.