Skip to content

Commit

Permalink
Merge pull request #1060 from y-lohse/jz/reverse-dynamic-tags
Browse files Browse the repository at this point in the history
Put dynamic tags in choice in correct order
  • Loading branch information
smwhr authored May 14, 2024
2 parents b35555e + 97254b0 commit ed6f19a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inkjs",
"version": "2.2.2",
"version": "2.2.3",
"description": "A javascript port of inkle's ink scripting language (http://www.inklestudios.com/ink/)",
"main": "dist/ink-full.js",
"types": "ink.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ export class Story extends InkObject {
this.state.PopFromOutputStream(outputCountConsumed);
// Build string out of the content we collected
let sb = new StringBuilder();
for (let strVal of contentStackForTag) {
for (let strVal of contentStackForTag.reverse()) {
sb.Append(strVal.toString());
}
let choiceTag = new Tag(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VAR var1 = "aaa"
VAR var2 = "bbb"

+[choice #tag {var1}{var2}]
11 changes: 11 additions & 0 deletions src/tests/specs/ink/Choices.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,15 @@ describe("Choices", () => {
expect(context.story.Continue()).toBe("one three");
expect(context.story.currentTags).toEqual(["one", "three"]);
});

//TestDynanicTagsInChoice
it("tests tags in choice", () => {
compileStory("dynamic_tags_in_choice", true);
context.story.Continue();

expect(context.story.currentTags.length).toBe(0);
expect(context.story.currentChoices.length).toBe(1);
expect(context.story.currentChoices[0].text).toEqual("choice");
expect(context.story.currentChoices[0].tags).toEqual(["tag aaabbb"]);
});
});

0 comments on commit ed6f19a

Please sign in to comment.