This commit is contained in:
11
examples/gather-at-choice/main.hank
Normal file
11
examples/gather-at-choice/main.hank
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
What a beautiful morning!
|
||||||
|
|
||||||
|
* Drink water
|
||||||
|
|
||||||
|
- * Brush teeth
|
||||||
|
|
||||||
|
- * Egg breakfast
|
||||||
|
* Toast breakfast
|
||||||
|
* Easy breakfast
|
||||||
|
|
||||||
|
- Done
|
||||||
10
examples/gather-at-choice/test1.hlog
Normal file
10
examples/gather-at-choice/test1.hlog
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
What a beautiful morning!
|
||||||
|
* Drink water
|
||||||
|
> 1: Drink water
|
||||||
|
* Brush teeth
|
||||||
|
> 1: Brush teeth
|
||||||
|
* Egg breakfast
|
||||||
|
* Toast breakfast
|
||||||
|
* Easy breakfast
|
||||||
|
> 2: Toast breakfast
|
||||||
|
Done
|
||||||
@@ -80,7 +80,12 @@ class ASTExtension {
|
|||||||
case EChoice(choice):
|
case EChoice(choice):
|
||||||
if (tryAdd(choice, [])) lastChoiceIndex = i;
|
if (tryAdd(choice, [])) lastChoiceIndex = i;
|
||||||
case ETagged(EChoice(choice), tags):
|
case ETagged(EChoice(choice), tags):
|
||||||
if (tryAdd(choice, tags)) lastChoiceIndex = 1;
|
if (tryAdd(choice, tags)) lastChoiceIndex = i;
|
||||||
|
// Choice immediatly after gather at current depth:
|
||||||
|
case EGather(_, d, EChoice(choice)) if(i == startingIndex && d == depth):
|
||||||
|
if (tryAdd(choice, [])) lastChoiceIndex = i;
|
||||||
|
case EGather(_, d, ETagged(EChoice(choice), tags)) if(i == startingIndex && d == depth):
|
||||||
|
if (tryAdd(choice, tags)) lastChoiceIndex = i;
|
||||||
// Stop at the next gather of this depth
|
// Stop at the next gather of this depth
|
||||||
case EGather(_, d, _) if (d == depth):
|
case EGather(_, d, _) if (d == depth):
|
||||||
break;
|
break;
|
||||||
@@ -111,7 +116,7 @@ class ASTExtension {
|
|||||||
for (i in 0...ast.length) {
|
for (i in 0...ast.length) {
|
||||||
var expr = ast[i].expr;
|
var expr = ast[i].expr;
|
||||||
switch (expr) {
|
switch (expr) {
|
||||||
case EChoice(c) | ETagged(EChoice(c), _):
|
case EChoice(c) | ETagged(EChoice(c), _) | EGather(_, _, EChoice(c)):
|
||||||
if (c.id == id)
|
if (c.id == id)
|
||||||
return i;
|
return i;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -383,7 +383,9 @@ class Story {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exprIndex < ast.length && ast[exprIndex].expr.match(EChoice(_))) {
|
if (exprIndex < ast.length &&
|
||||||
|
(ast[exprIndex].expr.match(EChoice(_))
|
||||||
|
|| ast[exprIndex].expr.match(EGather(_, _, EChoice(_))))) {
|
||||||
var allChoiceInfo = ast.collectChoices(exprIndex, weaveDepth).choices;
|
var allChoiceInfo = ast.collectChoices(exprIndex, weaveDepth).choices;
|
||||||
for (choiceInfo in allChoiceInfo) {
|
for (choiceInfo in allChoiceInfo) {
|
||||||
if (choicesTaken.indexOf(choiceInfo.choice.id) == -1 || !choiceInfo.choice.onceOnly) {
|
if (choicesTaken.indexOf(choiceInfo.choice.id) == -1 || !choiceInfo.choice.onceOnly) {
|
||||||
@@ -404,7 +406,6 @@ class Story {
|
|||||||
// trace('final:');
|
// trace('final:');
|
||||||
// traceChoiceArray(choices);
|
// traceChoiceArray(choices);
|
||||||
|
|
||||||
// traceChoiceArray(choices);
|
|
||||||
return choices;
|
return choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user