Permalink
Browse files

Game - add synonyms ('greet' and 'quit')

  • Loading branch information...
bobbymcr committed Dec 1, 2018
1 parent 43fa575 commit 1f6e22bb26165588a943b38feea4fc00cc343765
Showing with 11 additions and 6 deletions.
  1. +7 −4 sample/src/Game.cs
  2. +2 −1 sample/test/walkthrough.in
  3. +2 −1 sample/test/walkthrough.out
@@ -20,8 +20,11 @@ public Game(TextReader reader, TextWriter writer)

public void Run()
{
Words words = new Words();
words.Add("greet", "hello", "hi");
words.Add("quit", "exit");
using (CancellationTokenSource cts = new CancellationTokenSource())
using (new SentenceParser(this.bus, new Words()))
using (new SentenceParser(this.bus, words))
using (this.bus.Subscribe<SentenceMessage>(m => this.ProcessVerb(cts, m.Verb)))
{
this.console.Run(cts.Token);
@@ -31,11 +34,11 @@ public void Run()
private void ProcessVerb(CancellationTokenSource cts, Word verb)
{
string output = null;
if (verb.Actual == "hello")
if (verb.Primary == "greet")
{
output = "world";
output = "You say, \"Hello,\" to no one in particular. No one answers.";
}
else if (verb.Actual == "quit")
else if (verb.Primary == "quit")
{
cts.Cancel();
}
@@ -1,4 +1,5 @@
hello
heeyyyyyyyy
quit
HI
exit
-- END --
@@ -1,2 +1,3 @@
world
You say, "Hello," to no one in particular. No one answers.
I don't know what 'heeyyyyyyyy' means.
You say, "Hello," to no one in particular. No one answers.

0 comments on commit 1f6e22b

Please sign in to comment.