Skip to content
Permalink
Browse files

Item - remove MessageBus arg from Take()

  • Loading branch information...
bobbymcr committed Dec 15, 2018
1 parent da2ce6c commit efb7da3fe72ee622f54f7fd5e11ab55390ddcc9c
Showing with 19 additions and 19 deletions.
  1. +5 −5 core/src/Item.cs
  2. +1 −1 core/src/Room.cs
  3. +3 −3 core/test/RoomTest.cs
  4. +6 −6 sample/src/Coin.cs
  5. +4 −4 sample/src/Table.cs
@@ -24,9 +24,9 @@ public bool Do(MessageBus bus, Word verb, Word noun)
return this.DoCore(bus, verb, noun);
}

public bool Take(MessageBus bus)
public bool Take()
{
return this.TakeCore(bus);
return this.TakeCore();
}

public bool Drop(MessageBus bus)
@@ -39,7 +39,7 @@ protected virtual bool DoCore(MessageBus bus, Word verb, Word noun)
return false;
}

protected virtual bool TakeCore(MessageBus bus)
protected virtual bool TakeCore()
{
return true;
}
@@ -49,9 +49,9 @@ protected virtual bool DropCore(MessageBus bus)
return true;
}

protected void Output(MessageBus bus, string text)
protected void Output(string text)
{
bus.Send(new OutputMessage(text));
this.bus.Send(new OutputMessage(text));
}
}
}
@@ -138,7 +138,7 @@ private void TakeItem(Word verb, Word noun)
return;
}

if (!taken.Take(this.bus))
if (!taken.Take())
{
this.Add(noun.Primary, taken);
return;
@@ -463,14 +463,14 @@ public TestKey(MessageBus bus, bool canTake = true)

public override string LongDescription => "It is solid gold.";

protected override bool TakeCore(MessageBus bus)
protected override bool TakeCore()
{
if (this.canTake)
{
return base.TakeCore(bus);
return base.TakeCore();
}

bus.Send(new OutputMessage("I won't let you take this!"));
this.Output("I won't let you take this!");
return false;
}
}
@@ -17,10 +17,10 @@ public Coin(MessageBus bus)

public override string LongDescription => "It is a small gold coin with an inscription on the edge.";

protected override bool TakeCore(MessageBus bus)
protected override bool TakeCore()
{
this.taken = true;
return base.TakeCore(bus);
return base.TakeCore();
}

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

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

private void Read(MessageBus bus)
private void Read()
{
if (this.taken)
{
this.Output(bus, "The inscription reads: \"MCMXCIX\"");
this.Output("The inscription reads: \"MCMXCIX\"");
}
else
{
this.Output(bus, "The writing is too small. You'd have to pick it up to see it better.");
this.Output("The writing is too small. You'd have to pick it up to see it better.");
}
}
}
@@ -20,9 +20,9 @@ public Table(MessageBus bus, Room parent)

public override string LongDescription => "It is an ordinary wooden table.";

protected override bool TakeCore(MessageBus bus)
protected override bool TakeCore()
{
this.Output(bus, "It is too heavy.");
this.Output("It is too heavy.");
return false;
}

@@ -42,12 +42,12 @@ private void Move(MessageBus bus)
if (!this.tableMoved)
{
this.tableMoved = true;
this.Output(bus, "You move the table slightly. Underneath you see a coin.");
this.Output("You move the table slightly. Underneath you see a coin.");
this.parent.Add(Noun.Coin, new Coin(bus));
}
else
{
this.Output(bus, "Someone has already moved it.");
this.Output("Someone has already moved it.");
}
}
}

0 comments on commit efb7da3

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