Skip to content
Permalink
Browse files

Items - Take -> Remove

  • Loading branch information...
bobbymcr committed Dec 22, 2018
1 parent 7fc3258 commit 033daa141414354ccfaba0c38b87e5dcfe4965e7
Showing with 14 additions and 14 deletions.
  1. +1 −1 core/src/Inventory.cs
  2. +1 −1 core/src/Items.cs
  3. +1 −1 core/src/Room.cs
  4. +11 −11 core/test/ItemsTest.cs
@@ -59,7 +59,7 @@ private void Take(Word verb, Word noun, Item item)

private void Drop(Word verb, Word noun, Items targetItems)
{
Item item = this.items.Take(noun.Primary);
Item item = this.items.Remove(noun.Primary);
if (item == null)
{
this.Output($"You can't {verb} what you don't have.");
@@ -76,7 +76,7 @@ public void Add(string name, Item item)
this.items.Add(name, item);
}

public Item Take(string name)
public Item Remove(string name)
{
this.items.Remove(name, out Item item);
return item;
@@ -156,7 +156,7 @@ protected virtual bool GoCore(Word noun)

private void TakeItem(Word verb, Word noun)
{
Item taken = this.items.Take(noun.Primary);
Item taken = this.items.Remove(noun.Primary);
if (taken == null)
{
this.Output($"You can't {verb} that.");
@@ -36,21 +36,21 @@ public void AddTwoItems()
}

[Fact]
public void TakeOneOfTwoItems()
public void RemoveOneOfTwoItems()
{
MessageBus bus = new MessageBus();
Items items = new Items(bus);
items.Add("key", new TestItem(bus));
TestItem coin = new TestItem(bus);
items.Add("coin", coin);

Item taken = items.Take("coin");
Item taken = items.Remove("coin");

taken.Should().BeSameAs(coin);
}

[Fact]
public void TakeTwoItems()
public void RemoveTwoItems()
{
MessageBus bus = new MessageBus();
Items items = new Items(bus);
@@ -59,38 +59,38 @@ public void TakeTwoItems()
TestItem coin = new TestItem(bus);
items.Add("coin", coin);

Item takenCoin = items.Take("coin");
Item takenKey = items.Take("key");
Item takenCoin = items.Remove("coin");
Item takenKey = items.Remove("key");

takenCoin.Should().BeSameAs(coin);
takenKey.Should().BeSameAs(key);
}

[Fact]
public void TakeItemAlreadyTaken()
public void RemoveItemAlreadyRemoved()
{
MessageBus bus = new MessageBus();
Items items = new Items(bus);
items.Add("key", new TestItem(bus));

items.Take("key");
Item missing = items.Take("key");
items.Remove("key");
Item missing = items.Remove("key");

missing.Should().BeNull();
}

[Fact]
public void TakeItemNotPresent()
public void RemoveItemNotPresent()
{
Items items = new Items(new MessageBus());

Item missing = items.Take("key");
Item missing = items.Remove("key");

missing.Should().BeNull();
}

[Fact]
public void DropItemAlreadyExists()
public void AddItemAlreadyExists()
{
MessageBus bus = new MessageBus();
Items items = new Items(bus);

0 comments on commit 033daa1

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