Skip to content
Permalink
Browse files

InventoryDropMessage -> DropItemMessage

  • Loading branch information...
bobbymcr committed Dec 15, 2018
1 parent 280001b commit f8d30478caaa5b3a5e24481886c88e82c840c1a5
@@ -1,12 +1,12 @@
// <copyright file="InventoryDropMessage.cs" company="Brian Rogers">
// <copyright file="DropItemMessage.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>

namespace Adventure
{
public sealed class InventoryDropMessage
public sealed class DropItemMessage
{
public InventoryDropMessage(Items items, Word verb, Word noun)
public DropItemMessage(Items items, Word verb, Word noun)
{
this.Items = items;
this.Verb = verb;
@@ -20,7 +20,7 @@ public Inventory(MessageBus bus)
this.bus = bus;
this.show = bus.Subscribe<InventoryRequestedMessage>(m => this.Show());
this.add = bus.Subscribe<InventoryAddedMessage>(m => this.Add(m.Verb, m.Noun, m.Item));
this.drop = bus.Subscribe<InventoryDropMessage>(m => this.Drop(m.Verb, m.Noun, m.Items));
this.drop = bus.Subscribe<DropItemMessage>(m => this.Drop(m.Verb, m.Noun, m.Items));
this.look = bus.Subscribe<LookItemMessage>(m => this.Look(m.Noun));
this.items = new Items(this.bus);
this.items.Activate();
@@ -107,7 +107,7 @@ protected void Drop(Word verb, Word noun)
}
else
{
this.bus.Send(new InventoryDropMessage(this.items, verb, noun));
this.bus.Send(new DropItemMessage(this.items, verb, noun));
}
}

@@ -173,7 +173,7 @@ public void DropAllowedItem()
using (Inventory inv = new Inventory(bus))
{
inv.Add("key", new TestItem());
bus.Send(new InventoryDropMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new InventoryRequestedMessage());

messages.Should().Equal("You THROW the KEY.", "You are carrying:", "(nothing)");
@@ -191,7 +191,7 @@ public void DropDisallowedItem()
using (Inventory inv = new Inventory(bus))
{
inv.Add("key", new TestItem(false));
bus.Send(new InventoryDropMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new InventoryRequestedMessage());

messages.Should().Equal("I won't let you drop this!", "You are carrying:", "a key");
@@ -208,7 +208,7 @@ public void DropMissingItem()
Items items = new Items(bus);
using (Inventory inv = new Inventory(bus))
{
bus.Send(new InventoryDropMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));

messages.Should().Equal("You can't THROW what you don't have.");
items.Look("{0}").Should().Be(0);
@@ -227,7 +227,7 @@ public void DropItemAfterDispose()
inv.Add("key", new TestItem());
}

bus.Send(new InventoryDropMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));
bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY")));

messages.Should().BeEmpty();
items.Look("{0}").Should().Be(0);
@@ -317,7 +317,7 @@ public void DropOneItem()
MessageBus bus = new MessageBus();
Dictionary<string, Item> items = new Dictionary<string, Item>();
items["DROP/KEY"] = new TestKey();
bus.Subscribe<InventoryDropMessage>(m => m.Items.Add(m.Noun.Primary, items[$"{m.Verb}/{m.Noun}"]));
bus.Subscribe<DropItemMessage>(m => m.Items.Add(m.Noun.Primary, items[$"{m.Verb}/{m.Noun}"]));
List<string> output = new List<string>();
bus.Subscribe<OutputMessage>(m => output.Add(m.Text));
TestRoom room = new TestRoom(bus);

0 comments on commit f8d3047

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