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

Jz/Fix list_range #1025

Merged
merged 3 commits into from
Aug 17, 2023
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 src/engine/InkList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export class InkList extends Map<SerializedInkListItem, number> {
if (Number.isInteger(maxBound)) {
maxValue = maxBound;
} else {
if (minBound instanceof InkList && minBound.Count > 0)
if (maxBound instanceof InkList && maxBound.Count > 0)
maxValue = maxBound.maxItem.Value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/inkfiles/compiled/lists/list_range.ink.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"inkVersion":20,"root":[["ev",{"VAR?":"Food"},"LIST_ALL",{"VAR?":"Currency"},"LIST_ALL","+","/ev",{"VAR=":"all","re":true},"\n","ev",{"VAR?":"all"},"out","/ev","\n","ev",{"VAR?":"all"},2,3,"range","out","/ev","\n","ev",{"VAR?":"Numbers"},"LIST_ALL",{"VAR?":"Two"},{"VAR?":"Six"},"range","out","/ev","\n","ev",{"list":{"Food.Pizza":1,"Food.Pasta":2}},-1,100,"range","out","/ev","\n",["done",{"#n":"g-0"}],null],"done",{"global decl":["ev",{"list":{},"origins":["Food"]},{"VAR=":"Food"},{"list":{},"origins":["Currency"]},{"VAR=":"Currency"},{"list":{},"origins":["Numbers"]},{"VAR=":"Numbers"},{"list":{}},{"VAR=":"all"},"/ev","end",null]}],"listDefs":{"Food":{"Pizza":1,"Pasta":2,"Curry":3,"Paella":4},"Currency":{"Pound":1,"Euro":2,"Dollar":3},"Numbers":{"One":1,"Two":2,"Three":3,"Four":4,"Five":5,"Six":6,"Seven":7}}}
{"inkVersion":21,"root":[["ev",{"VAR?":"Food"},"LIST_ALL",{"VAR?":"Currency"},"LIST_ALL","+","/ev",{"VAR=":"all","re":true},"\n","ev",{"VAR?":"all"},"out","/ev","\n","ev",{"VAR?":"all"},2,3,"range","out","/ev","\n","ev",{"VAR?":"Numbers"},"LIST_ALL",{"VAR?":"Two"},{"VAR?":"Six"},"range","out","/ev","\n","ev",{"VAR?":"Numbers"},"LIST_ALL",2,{"VAR?":"Four"},"range","out","/ev","\n","ev",{"VAR?":"Numbers"},"LIST_ALL",{"VAR?":"Two"},5,"range","out","/ev","\n","ev",{"list":{"Food.Pizza":1,"Food.Pasta":2}},-1,100,"range","out","/ev","\n",["done",{"#n":"g-0"}],null],"done",{"global decl":["ev",{"list":{},"origins":["Food"]},{"VAR=":"Food"},{"list":{},"origins":["Currency"]},{"VAR=":"Currency"},{"list":{},"origins":["Numbers"]},{"VAR=":"Numbers"},{"list":{}},{"VAR=":"all"},"/ev","end",null]}],"listDefs":{"Food":{"Pizza":1,"Pasta":2,"Curry":3,"Paella":4},"Currency":{"Pound":1,"Euro":2,"Dollar":3},"Numbers":{"One":1,"Two":2,"Three":3,"Four":4,"Five":5,"Six":6,"Seven":7}}}
2 changes: 2 additions & 0 deletions src/tests/inkfiles/original/lists/list_range.ink
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ VAR all = ()
{all}
{LIST_RANGE(all, 2, 3)}
{LIST_RANGE(LIST_ALL(Numbers), Two, Six)}
{LIST_RANGE(LIST_ALL(Numbers), 2, Four)} // mix int and list
{LIST_RANGE(LIST_ALL(Numbers), Two, 5)} // mix list and int
{LIST_RANGE((Pizza, Pasta), -1, 100)} // allow out of range
8 changes: 7 additions & 1 deletion src/tests/specs/ink/Lists.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ describe("Lists", () => {
compileStory("list_range");

expect(context.story.ContinueMaximally()).toBe(
"Pound, Pizza, Euro, Pasta, Dollar, Curry, Paella\nEuro, Pasta, Dollar, Curry\nTwo, Three, Four, Five, Six\nPizza, Pasta\n"
`Pound, Pizza, Euro, Pasta, Dollar, Curry, Paella
Euro, Pasta, Dollar, Curry
Two, Three, Four, Five, Six
Two, Three, Four
Two, Three, Four, Five
Pizza, Pasta
`
);
});

Expand Down
1 change: 0 additions & 1 deletion src/tests/specs/inkjs/engine/Integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ describe("Integration", () => {
expect(context.story.currentChoices.length).toEqual(2);
expect(context.story.currentChoices[0].tags.length).toEqual(1);
expect(context.story.currentChoices[0].tags[0]).toEqual("a tag");
console.log(context.story.currentChoices[0].tags);

const save = context.story.state.ToJson();
context.story.state.LoadJson(save);
Expand Down
Loading