Permalink
Browse files

AdventureSample - add verbRoutines dictionary (empty right now)

  • Loading branch information...
bobbymcr committed May 12, 2018
1 parent 09f59a8 commit 6c43592ea8a8f7ab33acf6a4c5dd2736b1dcab25
Showing with 11 additions and 3 deletions.
  1. +11 −3 projects/AdventureSample/src/Adventure/adventure.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
internal sealed class adventure
@@ -585,6 +586,8 @@ private int Main()
CLS();
Dictionary<string, Func<int>> verbRoutines = new Dictionary<string, Func<int>>();
while (true)
{
PrintDescription();
@@ -597,7 +600,7 @@ private int Main()
{
Parser();
int ret = HandleVerb();
int ret = HandleVerb(verbRoutines);
if (ret == 0)
{
break;
@@ -610,9 +613,14 @@ private int Main()
}
}
private int HandleVerb()
private int HandleVerb(Dictionary<string, Func<int>> verbRoutines)
{
if (verb == "GO")
Func<int> verbRoutine;
if (verbRoutines.TryGetValue(verb, out verbRoutine))
{
return verbRoutine();
}
else if (verb == "GO")
{
return Go();
}

0 comments on commit 6c43592

Please sign in to comment.