Skip to content

Commit 02a74bd

Browse files
Merge pull request #14 from roman-yagodin/master
"Follow link" action
2 parents 2b6b3d1 + 74ff891 commit 02a74bd

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

Diff for: js/app.js

+40-4
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ async function puzzle1() {
345345
choice: "anything"
346346
};
347347

348-
const somethingOrAnything = randomInt(0,2);
348+
const somethingOrAnything = randomYes(0.5);
349349

350350
let choice = await menu([
351351
{ text: "", choice: "nothing" },
352-
somethingOrAnything === 0 ? optionSomething : optionAnything,
352+
!somethingOrAnything ? optionSomething : optionAnything,
353353
{ text: "I don't feel anything...", choice: "nothing" },
354-
somethingOrAnything === 1 ? optionSomething : optionAnything,
354+
!!somethingOrAnything ? optionSomething : optionAnything,
355355
{ text: `I feel ${randomMsg(["everything", "EVERYTHING"])}!..`, choice: "everything" }
356356
]);
357357

@@ -599,12 +599,21 @@ async function scene4_world(note) {
599599
];
600600

601601
if (note.id.includes("-")) {
602-
choices = choices.toSpliced(4, 0, {
602+
const insertIdx = choices.findIndex(c => c.choice === "hint");
603+
choices = choices.toSpliced(insertIdx, 0, {
603604
text: "In English, please!",
604605
choice: "inEnglish"
605606
});
606607
}
607608

609+
if (note.meta.link) {
610+
const insertIdx = choices.findIndex(c => c.choice === "followLanguage");
611+
choices = choices.toSpliced(insertIdx, 0, {
612+
text: "Follow link.",
613+
choice: "followLink"
614+
});
615+
}
616+
608617
const choice = await menu(choices, showMenu);
609618
showMenu = false;
610619

@@ -713,6 +722,33 @@ async function scene4_world(note) {
713722
showNote = true;
714723
showMenu = true;
715724
}
725+
726+
if (choice === "followLink") {
727+
if (note.meta.link.startsWith("http")) {
728+
window.open(note.meta.link, "_blank");
729+
}
730+
else {
731+
const nextNote = game.notes.find(n => {
732+
// count breadcrumbs or not?
733+
if (n.id === note.meta.link) {
734+
return true;
735+
}
736+
return false;
737+
});
738+
739+
if (nextNote) {
740+
note = nextNote;
741+
game.state.breadCrumbs.push(note.id);
742+
game.saveState();
743+
}
744+
else {
745+
await reachedEOW();
746+
noteColor = randomNoteColor(note);
747+
}
748+
showNote = true;
749+
showMenu = true;
750+
}
751+
}
716752

717753
if (choice === "copy") {
718754
const wasCopied = await copyToClipboard(note.original);

0 commit comments

Comments
 (0)