aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/model/Game.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/esieequest/model/Game.java')
-rw-r--r--src/esieequest/model/Game.java332
1 files changed, 111 insertions, 221 deletions
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java
index 87d3d51..830b48c 100644
--- a/src/esieequest/model/Game.java
+++ b/src/esieequest/model/Game.java
@@ -1,284 +1,174 @@
1package esieequest.model; 1package esieequest.model;
2 2
3import java.util.HashMap; 3import esieequest.model.characters.Character;
4import java.util.HashSet; 4import esieequest.model.characters.Sumobot;
5 5import esieequest.model.doors.Door;
6import esieequest.model.entities.Player; 6import esieequest.model.doors.HiddenDoor;
7import esieequest.model.entities.Sumobot; 7import esieequest.model.doors.LockedDoor;
8import esieequest.model.doors.TransporterDoor;
9import esieequest.model.doors.TrapDoor;
8import esieequest.model.items.Beamer; 10import esieequest.model.items.Beamer;
9import esieequest.model.items.Item; 11import esieequest.model.items.Item;
10import esieequest.model.items.KeyCard; 12import esieequest.model.items.KeyCard;
11import esieequest.model.map.Door; 13import esieequest.model.map.Direction;
12import esieequest.model.map.HiddenDoor;
13import esieequest.model.map.LockedDoor;
14import esieequest.model.map.Room; 14import esieequest.model.map.Room;
15import esieequest.model.map.TransporterDoor;
16import esieequest.model.map.TrapDoor;
17 15
18/** 16/**
19 * Represents the game. 17 * The Game model.
20 * 18 *
21 * @author Pacien TRAN-GIRARD 19 * @author Pacien TRAN-GIRARD
22 * @author BenoƮt LUBRANO DI SBARAGLIONE
23 */ 20 */
24public class Game { 21public class Game {
25 22
26 private final HashMap<String, Room> rooms;
27
28 private final Player player; 23 private final Player player;
29 24
30 /** 25 /**
31 * The default constructor. 26 * Creates a Game with a step limit for the Player.
27 *
28 * @param maxNbSteps
29 * the step limit for the Player
32 */ 30 */
33 public Game() { 31 public Game(final int maxNbSteps) {
34 this.rooms = new HashMap<String, Room>(); 32 this.player = new Player(10, maxNbSteps);
35 33 this.connectRooms();
36 this.player = new Player(10); 34 this.addItems();
37 35 this.addCharacters();
38 this.createRooms();
39 this.linkRooms();
40 this.createItems();
41 this.createCharacters();
42 this.goToRoom("AmphitheaterSeat");
43 } 36 }
44 37
45 /** 38 /**
46 * Returns the player 39 * Creates a Game.
47 *
48 * @return the player
49 */ 40 */
50 public Player getPlayer() { 41 public Game() {
51 return this.player; 42 this(0);
52 } 43 }
53 44
54 /** 45 /**
55 * Creates a new room. 46 * @return the player
56 *
57 * @param name
58 * the name of the room
59 * @param description
60 * the description of the room
61 */ 47 */
62 private void createRoom(final String name, final String description) { 48 public Player getPlayer() {
63 this.rooms.put(name, new Room(description)); 49 return this.player;
64 } 50 }
65 51
66 /** 52 /**
67 * Creates all the rooms. 53 * Connects Room-s together using Door-s.
68 */ 54 */
69 private void createRooms() { 55 private void connectRooms() {
70 this.createRoom("AmphitheaterSeat", "in the amphitheater"); 56 this.d(Room.AMPHITHEATER_SEAT, Direction.NORTH, Room.AMPHITHEATER_STAGE);
71 this.createRoom("AmphitheaterStage", "on the amphitheater stage"); 57 this.d(Room.AMPHITHEATER_STAGE, Direction.WEST, Room.CAFETERIA);
72 58 this.d(Room.CAFETERIA, Direction.NORTH, Room.CAFETERIA_STREET);
73 this.createRoom("CafeteriaStreet", "in the main corridor, in front of the cafeteria"); 59 this.d(Room.CAFETERIA_STREET, Direction.EAST, Room.ESIEESPACE_STREET);
74 this.createRoom("Cafeteria", "at the cafeteria"); 60
75 61 this.d(Room.ESIEESPACE_STREET, Direction.SOUTH, Room.ESIEESPACE_FRONT);
76 this.createRoom("EsieespaceStreet", "in the main corridor, in front of the ESIEEspace HQ"); 62 this.d(Room.ESIEESPACE_FRONT, Direction.EAST, Room.ESIEESPACE_ENTRANCE);
77 this.createRoom("EsieespaceFront", "in front of the ESIEEspace HQ"); 63 this.d(Room.ESIEESPACE_ENTRANCE, Direction.NORTH, Room.ESIEESPACE);
78 this.createRoom("EsieespaceEntrance", "at the ESIEEspace HQ entrance"); 64
79 this.createRoom("Esieespace", "in the ESIEEspace HQ"); 65 this.d(Room.ESIEESPACE_STREET, Direction.EAST, Room.ENTRANCE_STREET);
80 66 this.d(Room.ENTRANCE_STREET, Direction.SOUTH, Room.ENTRANCE_STAIRS);
81 this.createRoom("ClubnixStreet", "in the main corridor, in front of the Club*Nix"); 67 this.d(Room.ENTRANCE_STAIRS, Direction.SOUTH, Room.ENTRANCE_ROUNDABOUT);
82 this.createRoom("ClubnixFront", "in front of the Club*Nix"); 68
83 this.createRoom("ClubnixEntrance", "at the Club*Nix entrance"); 69 this.d(Room.ENTRANCE_STREET, Direction.EAST, Room.WING_STREET);
84 this.createRoom("Clubnix", "in the Club*Nix"); 70 this.d(Room.WING_STREET, Direction.NORTH, Room.WING_FLOOR_ONE);
85 71 this.d(Room.WING_FLOOR_ONE, Direction.WEST, Room.WING_STAIRS_ONE);
86 this.createRoom("EntranceStreet", "in the main corridor, at the reception"); 72 this.d(Room.WING_STAIRS_ONE, Direction.SOUTH, Room.WING_STAIRS_TWO);
87 this.createRoom("EntranceStairs", "on the main entrance stairs"); 73 this.d(Room.WING_STAIRS_ONE, Direction.UP, Room.WING_STAIRS_TWO);
88 this.createRoom("EntranceRoundabout", "on the roundabout"); 74 this.d(Room.WING_STAIRS_TWO, Direction.EAST, Room.WING_FLOOR_TWO);
89 75 this.d(Room.WING_FLOOR_TWO, Direction.NORTH, Room.WING_OFFICE_CORRIDOR);
90 this.createRoom("WingStreet", "in font of wing #3"); 76 this.d(Room.WING_OFFICE_CORRIDOR, Direction.EAST, Room.WING_OFFICE);
91 this.createRoom("WingCorridorOne", "in the corridor in wing #3, on the ground floor"); 77
92 this.createRoom("WingStairsOne", "in the stairwell on the ground floor"); 78 this.d(Room.WING_STREET, Direction.EAST, Room.CLUBNIX_STREET);
93 this.createRoom("WingStairsTwo", "in the stairwell on the first floor"); 79 this.d(Room.CLUBNIX_STREET, Direction.SOUTH, Room.CLUBNIX_FRONT);
94 this.createRoom("WingCorridorTwo", "in the corridor in wing #3, on the first floor"); 80 this.d(Room.CLUBNIX_FRONT, Direction.EAST, Room.CLUBNIX_ENTRANCE);
95 this.createRoom("WingCorridorTwoOffice", "in front of the office #3254"); 81 this.d(Room.CLUBNIX_ENTRANCE, Direction.NORTH, Room.CLUBNIX);
96 this.createRoom("WingOffice", "in the office #3254"); 82
97 83 this.d(Room.WING_FLOOR_ONE, Direction.EAST, new HiddenDoor(Room.SECRET_CORRIDOR_ENTRANCE));
98 // off-script rooms 84 this.d(Room.SECRET_CORRIDOR_ENTRANCE, Direction.WEST, new Door(Room.WING_FLOOR_ONE));
99 this.createRoom("Secret corridor 1", "in a secret corridor"); 85 this.d(Room.SECRET_CORRIDOR_ENTRANCE, Direction.NORTH, Room.STORAGE_ROOM);
100 this.createRoom("Secret corridor 2", "at the end of a secret corridor"); 86 this.d(Room.SECRET_CORRIDOR_ENTRANCE, Direction.SOUTH, Room.SECRET_LAB);
101 this.createRoom("Storage room", "in a storage room"); 87 this.d(Room.SECRET_CORRIDOR_ENTRANCE, Direction.EAST, Room.SECRET_CORRIDOR_END);
102 this.createRoom("Secret lab", "in a secret lab"); 88 this.d(Room.SECRET_CORRIDOR_END, Direction.NORTH, new TrapDoor(Room.DEAD_END));
103 this.createRoom("Dead-end", "in a dead end"); 89 this.d(Room.SECRET_CORRIDOR_END, Direction.SOUTH, new LockedDoor(Room.LOCKED_ROOM));
104 this.createRoom("Locked room", "in a locked room"); 90 this.d(Room.LOCKED_ROOM, Direction.NORTH, new LockedDoor(Room.SECRET_CORRIDOR_END));
105 91 this.d(Room.SECRET_CORRIDOR_END, Direction.EAST, new TransporterDoor(Room.values()));
106 } 92 }
107 93
108 /** 94 /**
109 * Sets the exit room of a given room designated by its name. 95 * Adds two Door that connect two Room-s in both ways.
110 * 96 *
111 * @param roomName 97 * @param source
112 * the name of the room 98 * the source Room
113 * @param direction 99 * @param direction
114 * the direction of the exit 100 * the direction of the Door, seen from the source Room
115 * @param exitRoomName 101 * @param destination
116 * the nam