-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathRoomDark.java
More file actions
80 lines (71 loc) · 2.07 KB
/
RoomDark.java
File metadata and controls
80 lines (71 loc) · 2.07 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
import java.util.HashMap;
import java.util.LinkedList;
// represents a dark room
public class RoomDark extends Room {
public RoomDark(String description, String shortDescription, String darkDescription, String darkShortDescription) {
this(description, shortDescription, darkDescription, darkShortDescription, true);
}
public RoomDark(String description, String shortDescription, String darkDescription, String darkShortDescription, boolean isDark){
super(description, shortDescription);
this.isDark = isDark;
this.darkDescription = darkDescription;
this.darkShortDescription = darkShortDescription;
this.safeDirections = new LinkedList<Action>();
this.deathMessage = null;
}
public boolean isDark() {
return this.isDark;
}
public void setDark(boolean isDark) {
this.isDark = isDark;
}
public void setSafeDirection(Action direction) {
this.safeDirections.add(direction);
}
public boolean willDieInDirection(Action dir) {
return !this.safeDirections.contains(dir);
}
public String deathMessage() {
return this.deathMessage;
}
public void setDeathMessage(String s) {
this.deathMessage = s;
}
public String toString() {
if(this.isDark) {
if(this.player.hasItemOfType("Luminous")) {
return super.toString();
}
else {
return this.darkDescription;
}
}
else {
return super.toString();
}
}
public String description() {
if(this.isDark) {
if(this.player.hasItemOfType("Luminous")) {
String s = this.roomWasVisited ? this.shortDescription : this.description + "\n" + visibleItems();
this.roomWasVisited = true;
return s;
}
else {
String s = this.roomWasVisited ? this.darkShortDescription : this.darkDescription;
this.roomWasVisited = true;
return s;
}
}
else {
String s = this.roomWasVisited ? this.shortDescription : this.description + "\n" + visibleItems();
this.roomWasVisited = true;
return s;
}
}
protected LinkedList<Action> safeDirections;
protected String darkDescription;
protected String darkShortDescription;
protected boolean isDark;
protected String deathMessage;
}