Skip to content

Commit

Permalink
Oops, don’t kill flow when there’s a warning. Also, print out warning…
Browse files Browse the repository at this point in the history
… messages in command line player, and in test bed
  • Loading branch information
joethephish committed Apr 17, 2018
1 parent cc4db05 commit 864e4fc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions InkTestBed/InkTestBed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ void Play ()
if (story.canContinue)
ContinueMaximally ();

PrintAllMessages ();

if (story.currentChoices.Count > 0)
PlayerChoice ();
}
Expand Down
3 changes: 2 additions & 1 deletion ink-engine-runtime/Story.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,8 @@ void AddError (string message, bool isWarning = false, bool useEndLineNumber = f
state.AddError (message, isWarning);

// In a broken state don't need to know about any other errors.
state.ForceEnd ();
if( !isWarning )
state.ForceEnd ();
}

void Assert(bool condition, string message = null, params object[] formatParams)
Expand Down
10 changes: 8 additions & 2 deletions inklecate/CommandLinePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,19 @@ void EvaluateStory ()
Console.WriteLine (errorMsg, ConsoleColor.Red);
}
}

if (story.hasWarning) {
foreach (var warningMsg in story.currentWarnings) {
Console.WriteLine (warningMsg, ConsoleColor.Blue);
}
}

story.ResetErrors ();
}

if (story.currentChoices.Count == 0 && keepOpenAfterStoryFinish) {
Console.WriteLine ("--- End of story ---");
}

story.ResetErrors ();
}

Compiler _compiler;
Expand Down
17 changes: 17 additions & 0 deletions tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,23 @@ Hello world!
}


[Test ()]
public void TestTempNotFound ()
{
var storyStr =
@"
{x}
~temp x = 5
hello
";
var story = CompileString (storyStr);

Assert.AreEqual ("0\nhello\n", story.ContinueMaximally ());

Assert.IsTrue (story.hasWarning);
}


// Helper compile function
protected Story CompileString(string str, bool countAllVisits = false, bool testingErrors = false)
{
Expand Down

0 comments on commit 864e4fc

Please sign in to comment.