Implementing storylet generators as generator functions

This commit is contained in:
David Masad
2021-02-06 07:05:00 -05:00
parent edd66e8da9
commit 82e7c5f403
9 changed files with 90 additions and 103 deletions

View File

@ -15,8 +15,7 @@ State.variables.currentLocation = "Deep space";
StoryManager.storylets["Go somewhere"] = {
name: "Go somewhere",
tags: ["in space"],
generate: function() {
let storylets = [];
generate: function*() {
for (let loc of State.variables.locations) {
if (loc == State.variables.currentLocation) continue;
let storylet = {
@ -24,9 +23,8 @@ StoryManager.storylets["Go somewhere"] = {
description: "Jump to " + loc, // Storylet link text
planet: loc // Data associated with this storylet
};
storylets.push(storylet);
yield storylet;
}
return storylets;
}
}