/
Item.cs
57 lines (45 loc) · 1.12 KB
/
Item.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// <copyright file="Item.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace Adventure
{
using Adventure.Messages;
public abstract class Item
{
protected Item(MessageBus bus)
{
this.Bus = bus;
}
public abstract string ShortDescription { get; }
public abstract string LongDescription { get; }
protected MessageBus Bus { get; }
public bool Do(Word verb, Word noun)
{
return this.DoCore(verb, noun);
}
public bool Take()
{
return this.TakeCore();
}
public bool Drop()
{
return this.DropCore();
}
protected virtual bool DoCore(Word verb, Word noun)
{
return false;
}
protected virtual bool TakeCore()
{
return true;
}
protected virtual bool DropCore()
{
return true;
}
protected void Output(string text)
{
this.Bus.Send(new OutputMessage(text));
}
}
}