Skip to content
Permalink
Browse files

Room - ProcessGoDirection

  • Loading branch information...
bobbymcr committed Dec 16, 2018
1 parent cf03509 commit df2ecb1e5ab202bcf42ab1d2c414efdf316b53e8
Showing with 25 additions and 8 deletions.
  1. +4 −3 core/src/Room.cs
  2. +17 −0 core/test/RoomTest.cs
  3. +4 −5 core/test/TestRoom.cs
@@ -118,9 +118,9 @@ protected void Go(Word verb, Word noun)
{
this.Output($"Where do you want to {verb}?");
}
else
else if (!this.GoCore(noun))
{
this.GoCore(noun);
this.bus.Send(new GoMessage(noun.Primary));
}
}

@@ -141,8 +141,9 @@ protected virtual bool TakeCore(Word noun)
return false;
}

protected virtual void GoCore(Word noun)
protected virtual bool GoCore(Word noun)
{
return false;
}

private void TakeItem(Word verb, Word noun)
@@ -223,6 +223,23 @@ public void ProcessGoCustom()
"This is no time to play cards.");
}

[Fact]
public void ProcessGoDirection()
{
MessageBus bus = new MessageBus();
List<string> messages = new List<string>();
bus.Subscribe<OutputMessage>(m => messages.Add(m.Text));
bus.Subscribe<GoMessage>(m => messages.Add($"You go {m.Direction}!"));
TestRoom room = new TestRoom(bus);

room.Enter();
bus.Send(new SentenceMessage(new Word("go", "GO"), new Word("north", "NORTH")));

messages.Should().Equal(
"You are in a test room.",
"You go north!");
}

[Fact]
public void ProcessTake()
{
@@ -70,16 +70,15 @@ protected override bool TakeCore(Word noun)
return base.TakeCore(noun);
}

protected override void GoCore(Word noun)
protected override bool GoCore(Word noun)
{
if (noun.Primary == "fish")
{
this.Output("This is no time to play cards.");
return true;
}
else
{
base.GoCore(noun);
}

return base.GoCore(noun);
}

private void Hello(Word verb, Word noun)

0 comments on commit df2ecb1

Please sign in to comment.
You can’t perform that action at this time.