-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExit.java
More file actions
231 lines (206 loc) · 4.77 KB
/
Exit.java
File metadata and controls
231 lines (206 loc) · 4.77 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
public class Exit {
public static final int UNDEFINED = 0;
public static final int NORTH = 1;
public static final int SOUTH = 2;
public static final int EAST = 3;
public static final int WEST = 4;
public static final int UP = 5;
public static final int DOWN = 6;
public static final int NORTHEAST = 7;
public static final int NORTHWEST = 8;
public static final int SOUTHEAST = 9;
public static final int SOUTHWEST = 10;
public static final int IN = 11;
public static final int OUT = 12;
public static final String[] dirName =
{
"UNDEFINED",
"NORTH",
"SOUTH",
"EAST",
"WEST",
"UP",
"DOWN",
"NORTHEAST",
"NORTHWEST",
"SOUTHEAST",
"SOUTHWEST",
"IN",
"OUT"
};
public static final String[] shortDirName =
{
"NULL",
"N",
"S",
"E",
"W",
"U",
"D",
"NE",
"NW",
"SE",
"SW",
"I",
"O"
};
private Location to = null;
private Location curr = new Location();
private String Direction;
private int dirCode;
private String shortDirection;
private Boolean isLocked = false;
private Item key = null;
public Exit() {
this.to = new Location();
this.Direction = new String();
this.shortDirection = new String();
}
public Exit(Location to, int Direction) {
this.to = to;
dirCode = Direction;
if(Direction <= dirName.length)
this.Direction = dirName[Direction];
if(Direction <= shortDirName.length)
this.shortDirection = shortDirName[Direction];
}
public Exit(Location to, int Direction, Boolean isLocked){
this.isLocked = isLocked;
this.to = to;
dirCode = Direction;
if(Direction <= dirName.length)
this.Direction = dirName[Direction];
if(Direction <= shortDirName.length)
this.shortDirection = shortDirName[Direction];
}
public Exit(Location to, int Direction, Boolean isLocked, Item Key){
this.key = Key;
this.isLocked = isLocked;
this.to = to;
dirCode = Direction;
if(Direction <= dirName.length)
this.Direction = dirName[Direction];
if(Direction <= shortDirName.length)
this.shortDirection = shortDirName[Direction];
}
public String toString() {
return Direction;
}
public void setLeadsTo(Location to) {
this.to = to;
}
public Location getLeadsTo() {
return this.to;
}
public void setCurrentLocation(Location at) {
this.curr = at;
}
public Location getCurrentLocation() {
return this.curr;
}
public void setDirection(String Direction) {
this.Direction = Direction;
}
public void setDirection(int Direction) {
dirCode = Direction;
if(Direction <= dirName.length)
this.Direction = dirName[Direction];
if(Direction <= shortDirName.length)
this.shortDirection = shortDirName[Direction];
}
public String getDirection() {
return this.Direction;
}
public void setShortDirection(String ShortDirection) {
this.shortDirection = ShortDirection;
}
public String getShortDirection() {
return this.shortDirection;
}
public Boolean getIsItLocked(){
return this.isLocked;
}
public void setIsLocked(Boolean isLocked) {
this.isLocked = isLocked;
}
public String getKeyDescription() {
return this.key.getDescription();
}
public void setKey(Item isKey) {
this.key = isKey;
}
public Item getKey() {
return this.key;
}
public void ExitTaken() {
Location temp = new Location();
temp = this.curr;
this.curr = this.to;
this.to = temp;
if(!(this.curr.getExits().contains(this)))
this.curr.addExit(this);
switch(dirCode) {
case 0: break;
case 1:
this.Direction = dirName[2];
this.shortDirection = shortDirName[2];
dirCode = 2;
break;
case 2:
this.Direction = dirName[1];
this.shortDirection = shortDirName[1];
dirCode = 1;
break;
case 3:
this.Direction = dirName[4];
this.shortDirection = shortDirName[4];
dirCode = 4;
break;
case 4:
this.Direction = dirName[3];
this.shortDirection = shortDirName[3];
dirCode = 3;
break;
case 5:
this.Direction = dirName[6];
this.shortDirection = shortDirName[6];
dirCode = 6;
break;
case 6:
this.Direction = dirName[5];
this.shortDirection = shortDirName[5];
dirCode = 5;
break;
case 7:
this.Direction = dirName[10];
this.shortDirection = shortDirName[10];
dirCode = 10;
break;
case 8:
this.Direction = dirName[9];
this.shortDirection = shortDirName[9];
dirCode = 9;
break;
case 9:
this.Direction = dirName[8];
this.shortDirection = shortDirName[8];
dirCode = 8;
break;
case 10:
this.Direction = dirName[7];
this.shortDirection = shortDirName[7];
dirCode = 7;
break;
case 11:
this.Direction = dirName[12];
this.shortDirection = shortDirName[12];
dirCode = 12;
break;
case 12:
this.Direction = dirName[11];
this.shortDirection = shortDirName[11];
dirCode = 11;
break;
}
}
}