Skip to content

Commit

Permalink
Change add choice node to be similar to dialog
Browse files Browse the repository at this point in the history
Changes the add choice node to have similar syntax to the set and append
dialog nodes.
  • Loading branch information
exodrifter committed Mar 1, 2021
1 parent 7f05bd2 commit 7c6f77f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
behaviour that it had in Rumor 3.X.
* `choose` and `pause` now require the `{}` block syntax when specifying an
amount of time.
* `choice` no longer uses `>` to prefix every line; instead, it works similar
to `:` and `+` commands.

### Fixed
* Injecting nodes clears the current yield and continues execution instead of
Expand Down
10 changes: 6 additions & 4 deletions Compiler/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,19 @@ public static partial class Compiler
// Parse the choice text
Parse.Whitespaces(state);
Parse.Indented(state);
var text = PrefixText(
Parse.Char('>').Then(Parse.Spaces)
)(state);
state.IndentIndex = state.Index;
Parse.Char('>')(state);
Parse.Whitespaces(state);
var text = Text(state);
// Consume the rest of the whitespace on this line
Parse.Spaces.Until(Parse.EOL)(state);
// Parse an optional indented block on the next line
var result = Parse.EOL
.Then(Parse.Whitespaces)
.Then(Parse.Indented)
.Then(Parse.Same)
.Then(Script)
.Maybe()(state)
.GetValueOrDefault(
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Tests/AddChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void AddChoiceUnlabeledMultilineSuccess()
var state = new ParserState(
"choice\n" +
" > Hello?\n" +
" > Anyone there?\n" +
" Anyone there?\n" +
" : Hello!",
4
);
Expand Down Expand Up @@ -102,7 +102,7 @@ public static void AddChoiceLabeledMultilineSuccess()
var state = new ParserState(
"choice [choice1]\n" +
" > Hello?\n" +
" > Anyone there?\n" +
" Anyone there?\n" +
" : Hello!",
4, new RumorParserState()
);
Expand Down

0 comments on commit 7c6f77f

Please sign in to comment.