Skip to content

Commit

Permalink
Item - remove MessageBus arg from Take()
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Dec 15, 2018
1 parent da2ce6c commit efb7da3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions core/src/Item.cs
Expand Up @@ -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)
Expand All @@ -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;
}
Expand All @@ -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));
}
}
}
2 changes: 1 addition & 1 deletion core/src/Room.cs
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions core/test/RoomTest.cs
Expand Up @@ -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;
}
}
Expand Down
12 changes: 6 additions & 6 deletions sample/src/Coin.cs
Expand Up @@ -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)
Expand All @@ -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.");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions sample/src/Table.cs
Expand Up @@ -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;
}

Expand All @@ -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.");
}
}
}
Expand Down

0 comments on commit efb7da3

Please sign in to comment.