diff options
Diffstat (limited to 'src/esieequest/model/Game.java')
-rw-r--r-- | src/esieequest/model/Game.java | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index 668a7f9..eb74f85 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java | |||
@@ -11,27 +11,27 @@ import java.util.HashMap; | |||
11 | */ | 11 | */ |
12 | public class Game { | 12 | public class Game { |
13 | 13 | ||
14 | private boolean aRunning; | 14 | private boolean running; |
15 | private HashMap<String, Room> aRooms; | 15 | private HashMap<String, Room> rooms; |
16 | private Room aCurrentRoom; | 16 | private Room currentRoom; |
17 | 17 | ||
18 | public Game() { | 18 | public Game() { |
19 | this.aRunning = false; | 19 | this.running = false; |
20 | this.aRooms = new HashMap<String, Room>(); | 20 | this.rooms = new HashMap<String, Room>(); |
21 | this.aCurrentRoom = null; | 21 | this.currentRoom = null; |
22 | 22 | ||
23 | this.createRooms(); | 23 | this.createRooms(); |
24 | this.linkRooms(); | 24 | this.linkRooms(); |
25 | this.createItems(); | ||
25 | this.goToRoom("AmphitheaterSeat"); | 26 | this.goToRoom("AmphitheaterSeat"); |
26 | } | 27 | } |
27 | 28 | ||
28 | private void createRoom(final String pName, final String pDescription) { | 29 | private void createRoom(String name, String description) { |
29 | this.aRooms.put(pName, new Room(pDescription)); | 30 | this.rooms.put(name, new Room(description)); |
30 | } | 31 | } |
31 | 32 | ||
32 | private void setRoomExit(final String pRoomName, final String pDirection, | 33 | private void setRoomExit(String roomName, String direction, String exitRoomName) { |
33 | final String pExitRoomName) { | 34 | this.rooms.get(roomName).setExit(direction, this.rooms.get(exitRoomName)); |
34 | this.aRooms.get(pRoomName).setExit(pDirection, this.aRooms.get(pExitRoomName)); | ||
35 | } | 35 | } |
36 | 36 | ||
37 | private void createRooms() { | 37 | private void createRooms() { |
@@ -165,32 +165,36 @@ public class Game { | |||
165 | this.setRoomExit("OffscriptMovingcharacter", "west", "OffscriptAlea"); | 165 | this.setRoomExit("OffscriptMovingcharacter", "west", "OffscriptAlea"); |
166 | } | 166 | } |
167 | 167 | ||
168 | public void setRunning(final boolean pState) { | 168 | private void createItems() { |
169 | this.aRunning = pState; | 169 | this.rooms.get("Cafeteria").setItem(new Item("Banana", 12)); |
170 | } | ||
171 | |||
172 | public void setRunning(boolean state) { | ||
173 | this.running = state; | ||
170 | } | 174 | } |
171 | 175 | ||
172 | public boolean isRunning() { | 176 | public boolean isRunning() { |
173 | return this.aRunning; | 177 | return this.running; |
174 | } | 178 | } |
175 | 179 | ||
176 | public void goToRoom(final Room pRoom) { | 180 | public void goToRoom(Room room) { |
177 | this.aCurrentRoom = pRoom; | 181 | this.currentRoom = room; |
178 | } | 182 | } |
179 | 183 | ||
180 | public void goToRoom(final String pRoomName) { | 184 | public void goToRoom(String roomName) { |
181 | this.aCurrentRoom = this.aRooms.get(pRoomName); | 185 | this.currentRoom = this.rooms.get(roomName); |
182 | } | 186 | } |
183 | 187 | ||
184 | public Room getRoomExit(final String pDirection) { | 188 | public Room getRoomExit(String direction) { |
185 | return this.aCurrentRoom.getExit(pDirection); | 189 | return this.currentRoom.getExit(direction); |
186 | } | 190 | } |
187 | 191 | ||
188 | public String getLocationInfo() { | 192 | public String getLocationInfo() { |
189 | return this.aCurrentRoom.getLongDescription(); | 193 | return this.currentRoom.getLongDescription(); |
190 | } | 194 | } |
191 | 195 | ||
192 | public String getLocationImageName() { | 196 | public String getLocationImageName() { |
193 | return this.aCurrentRoom.getImageName(); | 197 | return this.currentRoom.getImageName(); |
194 | } | 198 | } |
195 | 199 | ||
196 | public String getEatMessage() { | 200 | public String getEatMessage() { |
@@ -213,4 +217,12 @@ public class Game { | |||
213 | return "There is no exit."; | 217 | return "There is no exit."; |
214 | } | 218 | } |
215 | 219 | ||
220 | public String getItemDescription() { | ||
221 | if (this.currentRoom != null) { | ||
222 | return "This room contain : " + this.currentRoom.getItem().getDescription(); | ||
223 | } else { | ||
224 | return ""; | ||
225 | } | ||
226 | } | ||
227 | |||
216 | } | 228 | } |