/
InfoDumpRoom.cs
151 lines (135 loc) · 4.48 KB
/
InfoDumpRoom.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using System.Collections.Generic;
namespace CandideTextAdventure
{
internal class InfoDumpRoom : Room
{
private readonly string desc;
private readonly string ending;
private readonly Room next;
private readonly Dictionary<InfoDumpPainting, bool> paintings = new Dictionary<InfoDumpPainting, bool>();
public InfoDumpRoom(IEnumerable<InfoDumpPainting> list, Room nextroom,
string endingmessage = "You feel yourself being sucked through a magical portal...",
string OpeningDescription = "Blah.")
{
foreach (InfoDumpPainting p in list)
paintings.Add(p, false);
Items.AddRange(list);
next = nextroom;
ending = endingmessage;
desc = OpeningDescription;
//Items.Add(new TestPickup());
//Items.Add(new TestUsable());
}
public override bool OnInteract(string command, Item target, string attemptedname)
{
if (command == "iddqd")
{
ChangeRoom(next);
return false;
}
if (command == "examine" && target.GetType() == typeof (InfoDumpPainting) &&
paintings.ContainsKey((InfoDumpPainting) target))
{
paintings[(InfoDumpPainting) target] = true;
if (!paintings.ContainsValue(false))
{
target.OnInteract("examine", attemptedname);
Terminal.WriteLine(ending);
Terminal.WriteLine("Press any key to continue...");
Terminal.ReadKey();
Terminal.Clear();
ChangeRoom(next);
return false;
}
}
return true;
}
public override void OnEnter()
{
Terminal.WriteLine("Examine all paintings to continue");
}
public override bool OnExamine()
{
Terminal.WriteLine("You are in a room with paintings.");
return true;
}
public override void Describe(bool isFirstEntry = false)
{
Terminal.WriteLine(desc);
base.Describe(isFirstEntry);
}
}
internal class InfoDumpPainting : Item
{
private readonly string description;
private readonly string name;
public InfoDumpPainting(string name, string description, params string[] usernames)
{
this.description = description;
this.name = name;
ValidNames.Add(name.ToLower());
foreach (string username in usernames)
{
ValidNames.Add("painting of " + username.ToLower());
ValidNames.Add("a painting of " + username.ToLower());
ValidNames.Add("portrait of " + username.ToLower());
ValidNames.Add(username);
}
}
public override bool OnInteract(string command, string attemptedname)
{
switch (command)
{
case "examine":
Terminal.WriteLine(description);
return true;
default:
return false;
}
}
public override string GetName()
{
return "a painting of " + name;
}
}
internal class TestPickup : Item
{
public TestPickup(string name = "item")
{
ValidNames.Add(name);
}
public override bool AttemptedGrab()
{
Terminal.WriteLine("You pick it up.");
Room.Inventory.Add(this);
Room.CurrentRoom.Items.Remove(this);
return true;
}
public override bool AttemptedSingleUse()
{
Terminal.WriteLine("You use it on itself");
return true;
}
public override bool OnInteract(string command, string attemptedname)
{
if (command == "examine")
{
Terminal.WriteLine("It is an item.");
return true;
}
return false;
}
public override bool AttemptedDoubleItemUse(Item target)
{
Terminal.WriteLine("You use it.");
return true;
}
}
internal class TestUsable : Item
{
public TestUsable(string name = "usable")
{
ValidNames.Add(name);
}
}
}