Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put dynamic tags in choice in correct order #1060

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]);
});
});
Loading