Skip to content
Permalink
Browse files

Item - make 'bus' protected property, remove arg from Do()

  • Loading branch information...
bobbymcr committed Dec 15, 2018
1 parent a5d7fce commit b4f3611dc4dd33d77f61a1416bdeb90277123318
Showing with 21 additions and 21 deletions.
  1. +7 −7 core/src/Item.cs
  2. +1 −1 core/src/Items.cs
  3. +2 −2 core/test/InventoryTest.cs
  4. +2 −2 core/test/ItemsTest.cs
  5. +2 −2 core/test/RoomTest.cs
  6. +2 −2 sample/src/Coin.cs
  7. +5 −5 sample/src/Table.cs
@@ -8,20 +8,20 @@ namespace Adventure

public abstract class Item
{
private readonly MessageBus bus;

protected Item(MessageBus bus)
{
this.bus = bus;
this.Bus = bus;
}

public abstract string ShortDescription { get; }

public abstract string LongDescription { get; }

public bool Do(MessageBus bus, Word verb, Word noun)
protected MessageBus Bus { get; }

public bool Do(Word verb, Word noun)
{
return this.DoCore(bus, verb, noun);
return this.DoCore(verb, noun);
}

public bool Take()
@@ -34,7 +34,7 @@ public bool Drop()
return this.DropCore();
}

protected virtual bool DoCore(MessageBus bus, Word verb, Word noun)
protected virtual bool DoCore(Word verb, Word noun)
{
return false;
}
@@ -51,7 +51,7 @@ protected virtual bool DropCore()

protected void Output(string text)
{
this.bus.Send(new OutputMessage(text));
this.Bus.Send(new OutputMessage(text));
}
}
}
@@ -91,7 +91,7 @@ private bool Do(SentenceMessage sentence)
{
if (this.items.TryGetValue(sentence.Noun.Primary, out Item item))
{
return item.Do(this.bus, sentence.Verb, sentence.Noun);
return item.Do(sentence.Verb, sentence.Noun);
}

return false;
@@ -299,11 +299,11 @@ public TestItem2(MessageBus bus)

public override string LongDescription => throw new System.NotImplementedException();

protected override bool DoCore(MessageBus bus, Word verb, Word noun)
protected override bool DoCore(Word verb, Word noun)
{
if (verb.Primary == "flip")
{
bus.Send(new OutputMessage($"You {verb} the {noun}; it lands on heads."));
this.Output($"You {verb} the {noun}; it lands on heads.");
return true;
}

@@ -270,11 +270,11 @@ public TestItem(MessageBus bus)

public override string LongDescription => "It's a simple test item.";

protected override bool DoCore(MessageBus bus, Word verb, Word noun)
protected override bool DoCore(Word verb, Word noun)
{
if (verb.Primary == "throw")
{
bus.Send(new OutputMessage($"You threw the {noun}!"));
this.Output($"You threw the {noun}!");
return true;
}

@@ -486,11 +486,11 @@ public TestCoin(MessageBus bus)

public override string LongDescription => "It is a shiny new quarter.";

protected override bool DoCore(MessageBus bus, Word verb, Word noun)
protected override bool DoCore(Word verb, Word noun)
{
if (verb.Primary == "flip")
{
bus.Send(new OutputMessage($"You {verb} the {noun}; it lands on heads."));
this.Output($"You {verb} the {noun}; it lands on heads.");
return true;
}

@@ -29,15 +29,15 @@ protected override bool DropCore()
return base.DropCore();
}

protected override bool DoCore(MessageBus bus, Word verb, Word noun)
protected override bool DoCore(Word verb, Word noun)
{
if (verb.Primary == Verb.Read)
{
this.Read();
return true;
}

return base.DoCore(bus, verb, noun);
return base.DoCore(verb, noun);
}

private void Read()
@@ -26,24 +26,24 @@ protected override bool TakeCore()
return false;
}

protected override bool DoCore(MessageBus bus, Word verb, Word noun)
protected override bool DoCore(Word verb, Word noun)
{
if (verb.Primary == Verb.Move)
{
this.Move(bus);
this.Move();
return true;
}

return base.DoCore(bus, verb, noun);
return base.DoCore(verb, noun);
}

private void Move(MessageBus bus)
private void Move()
{
if (!this.tableMoved)
{
this.tableMoved = true;
this.Output("You move the table slightly. Underneath you see a coin.");
this.parent.Add(Noun.Coin, new Coin(bus));
this.parent.Add(Noun.Coin, new Coin(this.Bus));
}
else
{

0 comments on commit b4f3611

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