Skip to content

Instantly share code, notes, and snippets.

@cefn
Created November 18, 2022 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cefn/1d35942b17658d8e696cd34a9e5a7aac to your computer and use it in GitHub Desktop.
Save cefn/1d35942b17658d8e696cd34a9e5a7aac to your computer and use it in GitHub Desktop.
Hello World IF
import type { Story } from "../lib/engine/types";
import { prompt, tell } from "../lib/engine/actions";
import { unhandled } from "../lib/util";
export const story: Story = function* () {
yield* tell(
<>
You wake bruised in a darkened, musty room with the freshness of the sound
of running water
</>
);
const choice = yield* prompt(
<>
You've no idea how you arrived here, but you are so groggy and exhausted
you're not sure if you can even stand up.
</>,
{
run: <>Run Away</>,
sleep: <>Go back to sleep</>,
}
);
if (choice === "sleep") {
yield* tell(
<>
You go back to sleep and die peacefully from Carbon Monoxide poisoning,
thanks to a poorly maintained gas fire.
</>
);
return;
}
else if (choice === "run") {
yield* tell(
<>
You run away and die horribly when you are involved in an accident with
agricultural machinery
</>
);
return;
}
unhandled(choice);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment