Skip to content
Permalink
Browse files

Game - add AuxiliaryRoom with movement between MainRoom

  • Loading branch information...
bobbymcr committed Dec 16, 2018
1 parent df2ecb1 commit 2a4f526be26088b1d61509a58833e5534a2ac032
@@ -0,0 +1,26 @@
// <copyright file="AuxiliaryRoom.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>

namespace Adventure.Sample
{
internal sealed class AuxiliaryRoom : Room
{
public AuxiliaryRoom(MessageBus bus)
: base(bus)
{
}

protected override string Description => "You are in the auxiliary room. There is a doorway to the west.";

protected override void EnterCore()
{
this.Register(Verb.Drop, this.Drop);
this.Register(Verb.Go, this.Go);
this.Register(Verb.Greet, (_, __) => this.Output("You say, \"Hello,\" to no one in particular. No one answers."));
this.Register(Verb.Look, (_, n) => this.Look(n));
this.Register(Verb.Inventory, (_, __) => this.Inventory());
this.Register(Verb.Take, this.Take);
}
}
}
@@ -34,6 +34,7 @@ private static Words InitializeWords()
{
Words w = new Words();
w.Add(Verb.Drop, "throw");
w.Add(Verb.Go);
w.Add(Verb.Greet, "hello", "hi");
w.Add(Verb.Look);
w.Add(Verb.Move);
@@ -43,7 +44,9 @@ private static Words InitializeWords()
w.Add(Verb.Inventory, "inv");

w.Add(Noun.Coin);
w.Add(Noun.East);
w.Add(Noun.Table);
w.Add(Noun.West);

return w;
}
@@ -52,9 +55,15 @@ private RoomMap InitializeMap()
{
RoomMap map = new RoomMap(this.bus);

MainRoom mainRoom = new MainRoom(this.bus);
Room mainRoom = new MainRoom(this.bus);
var mainRoomP = map.Add(mainRoom);

Room auxiliaryRoom = new AuxiliaryRoom(this.bus);
var auxiliaryRoomP = map.Add(auxiliaryRoom);

mainRoomP.ConnectTo(auxiliaryRoomP, Noun.East);
auxiliaryRoomP.ConnectTo(mainRoomP, Noun.West);

map.Start(mainRoomP);

return map;
@@ -12,11 +12,12 @@ public MainRoom(MessageBus bus)
this.Add(Noun.Table, new Table(bus, this));
}

protected override string Description => "You are in the main room.";
protected override string Description => "You are in the main room. There is a doorway to the east.";

protected override void EnterCore()
{
this.Register(Verb.Drop, this.Drop);
this.Register(Verb.Go, this.Go);
this.Register(Verb.Greet, (_, __) => this.Output("You say, \"Hello,\" to no one in particular. No one answers."));
this.Register(Verb.Look, (_, n) => this.Look(n));
this.Register(Verb.Inventory, (_, __) => this.Inventory());
@@ -7,6 +7,8 @@ namespace Adventure.Sample
internal static class Noun
{
public const string Coin = "coin";
public const string East = "east";
public const string Table = "table";
public const string West = "west";
}
}
@@ -7,6 +7,7 @@ namespace Adventure.Sample
internal static class Verb
{
public const string Drop = "drop";
public const string Go = "go";
public const string Greet = "greet";
public const string Inventory = "inventory";
public const string Look = "look";
@@ -1,4 +1,7 @@
hello
go east
hello
go west
look

heeyyyyyyyy
@@ -1,7 +1,11 @@
You are in the main room.
You are in the main room. There is a doorway to the east.
There is a table here.
> You say, "Hello," to no one in particular. No one answers.
> You are in the main room.
> You are in the auxiliary room. There is a doorway to the west.
> You say, "Hello," to no one in particular. No one answers.
> You are in the main room. There is a doorway to the east.
There is a table here.
> You are in the main room. There is a doorway to the east.
There is a table here.
> > You can't do that.
> You say, "Hello," to no one in particular. No one answers.
@@ -12,7 +16,7 @@ There is a table here.
> You move the table slightly. Underneath you see a coin.
> You can't do that.
> Someone has already moved it.
> You are in the main room.
> You are in the main room. There is a doorway to the east.
There is a table here.
There is a coin here.
> It is a small gold coin with an inscription on the edge.

0 comments on commit 2a4f526

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