Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Game - create MainRoom to hold verb logic
- Loading branch information
Showing
2 changed files
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
// <copyright file="MainRoom.cs" company="Brian Rogers"> | |||
// Copyright (c) Brian Rogers. All rights reserved. | |||
// </copyright> | |||
|
|||
namespace Adventure.Sample | |||
{ | |||
using System.Threading; | |||
|
|||
internal sealed class MainRoom : Room | |||
{ | |||
private readonly CancellationTokenSource cts; | |||
|
|||
public MainRoom(MessageBus bus, CancellationTokenSource cts) | |||
: base(bus) | |||
{ | |||
this.cts = cts; | |||
} | |||
|
|||
protected override void EnterCore() | |||
{ | |||
this.Register(Verb.Greet, (_, __) => this.Output("You say, \"Hello,\" to no one in particular. No one answers.")); | |||
this.Register(Verb.Quit, (_, n) => this.cts.Cancel()); | |||
this.Register(Verb.Take, (_, n) => this.Output("There is no " + n.Actual.ToLowerInvariant() + " here.")); | |||
} | |||
} | |||
} |