diff options
author | Pacien TRAN-GIRARD | 2014-02-23 18:46:48 +0000 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-02-23 18:46:48 +0000 |
commit | 48a842e6d4fada66c6cbfdbc5cb411163b6a5987 (patch) | |
tree | d2fb33a402f70d2fb11dea52f12d24173b247505 | |
parent | a09f50675a10f1c06eaf47772594cd932d4e4920 (diff) | |
parent | 1b4b8c7e5bbe05f05f6cfc7aa16ad0570af4f2ca (diff) | |
download | esieequest-48a842e6d4fada66c6cbfdbc5cb411163b6a5987.tar.gz |
Merge branch 'zuul-better-v1' into 'master'
Zuul Better V1
-rw-r--r-- | report/progression.tex | 31 | ||||
-rw-r--r-- | src/esieequest/Command.java | 37 | ||||
-rw-r--r-- | src/esieequest/Game.java | 201 | ||||
-rwxr-xr-x | src/esieequest/Main.java | 5 | ||||
-rw-r--r-- | src/esieequest/Room.java | 78 | ||||
-rw-r--r-- | src/esieequest/package-info.java | 5 |
6 files changed, 263 insertions, 94 deletions
diff --git a/report/progression.tex b/report/progression.tex index cef3a50..15709c5 100644 --- a/report/progression.tex +++ b/report/progression.tex | |||
@@ -10,20 +10,49 @@ | |||
10 | 10 | ||
11 | \subsection{printLocationInfo} | 11 | \subsection{printLocationInfo} |
12 | 12 | ||
13 | This code duplication has been previously avoided with the printRoomInfo() | ||
14 | method. | ||
15 | It has been renamed to printLocationInfo(), as part of the commit e52a34789, to | ||
16 | match the exercise. | ||
17 | |||
13 | \subsection{getExit} | 18 | \subsection{getExit} |
14 | 19 | ||
20 | The exit attributes have been made private and a getter was added in commit | ||
21 | 53c427ff3. A switch statement has been used instead of multiple if statements. | ||
22 | |||
15 | \subsection{getExitString} | 23 | \subsection{getExitString} |
16 | 24 | ||
25 | This method has been added as part of commit ca65af2e2. | ||
26 | |||
17 | \subsection{HashMap, setExit} | 27 | \subsection{HashMap, setExit} |
18 | 28 | ||
29 | Room exits are now stored in an HashMap since commit c9d890b9b. The setExits() | ||
30 | method has been replaced by setExit() which takes advantages of the HashMap. | ||
31 | |||
19 | \subsection{Vertical direction} | 32 | \subsection{Vertical direction} |
20 | 33 | ||
21 | \subsection{keySet} | 34 | In commit 4145a5e8c, the getExitString() method has been modified to be able to |
35 | print the availability of the new exits, used in the stairwell at wing 3. Due | ||
36 | to the architecture of these rooms, the side exits that were previously settled | ||
37 | to link them have been kept. | ||
38 | |||
39 | \subsection{keySet ?} | ||
40 | |||
41 | The keySet() method of the class HashMap returns a Set of the keys contained in | ||
42 | the map. | ||
22 | 43 | ||
23 | \subsection{getExitString ?} | 44 | \subsection{getExitString ?} |
24 | 45 | ||
46 | The getExitString() method returns a String listing the room's exits. | ||
47 | To achieve that, it iterates through the exits Map's keys, that is a Set of | ||
48 | Strings, appending each one to the String that it returns. | ||
49 | |||
25 | \subsection{getLongDescription} | 50 | \subsection{getLongDescription} |
26 | 51 | ||
52 | The Room class now uses the previously explained getExitString() method and | ||
53 | includes the getLongDescription() method that returns the full description of | ||
54 | the room since commit e510b08d0. | ||
55 | |||
27 | \subsection{Object diagram} | 56 | \subsection{Object diagram} |
28 | 57 | ||
29 | \subsubsection{Changes on execution} | 58 | \subsubsection{Changes on execution} |
diff --git a/src/esieequest/Command.java b/src/esieequest/Command.java index de6b853..fd05930 100644 --- a/src/esieequest/Command.java +++ b/src/esieequest/Command.java | |||
@@ -3,6 +3,17 @@ package esieequest; | |||
3 | /** | 3 | /** |
4 | * A text command that triggers an action in the game. | 4 | * A text command that triggers an action in the game. |
5 | * | 5 | * |
6 | * This class holds information about a command that was issued by the user. A | ||
7 | * command currently consists of two strings: a command word and a second word | ||
8 | * (for example, if the command was "take map", then the two strings obviously | ||
9 | * are "take" and "map"). | ||
10 | * | ||
11 | * The way this is used is: Commands are already checked for being valid command | ||
12 | * words. If the user entered an invalid command (a word that is not known) then | ||
13 | * the command word is <null>. | ||
14 | * | ||
15 | * If the command had only one word, then the second word is <null>. | ||
16 | * | ||
6 | * @author Pacien TRAN-GIRARD | 17 | * @author Pacien TRAN-GIRARD |
7 | * @author Benoit LUBRANO DI SBARAGLIONE | 18 | * @author Benoit LUBRANO DI SBARAGLIONE |
8 | * | 19 | * |
@@ -12,23 +23,49 @@ public class Command { | |||
12 | private String aCommandWord; | 23 | private String aCommandWord; |
13 | private String aSecondWord; | 24 | private String aSecondWord; |
14 | 25 | ||
26 | /** | ||
27 | * Create a command object. First and second word must be supplied, but | ||
28 | * either one (or both) can be null. | ||
29 | * | ||
30 | * @param firstWord | ||
31 | * The first word of the command. Null if the command was not | ||
32 | * recognised. | ||
33 | * @param secondWord | ||
34 | * The second word of the command. | ||
35 | */ | ||
15 | public Command(final String pCommandWord, final String pSecondWord) { | 36 | public Command(final String pCommandWord, final String pSecondWord) { |
16 | this.aCommandWord = pCommandWord; | 37 | this.aCommandWord = pCommandWord; |
17 | this.aSecondWord = pSecondWord; | 38 | this.aSecondWord = pSecondWord; |
18 | } | 39 | } |
19 | 40 | ||
41 | /** | ||
42 | * Return the command word (the first word) of this command. If the command | ||
43 | * was not understood, the result is null. | ||
44 | * | ||
45 | * @return The command word. | ||
46 | */ | ||
20 | public String getCommandWord() { | 47 | public String getCommandWord() { |
21 | return this.aCommandWord; | 48 | return this.aCommandWord; |
22 | } | 49 | } |
23 | 50 | ||
51 | /** | ||
52 | * @return The second word of this command. Returns null if there was no | ||
53 | * second word. | ||
54 | */ | ||
24 | public String getSecondWord() { | 55 | public String getSecondWord() { |
25 | return this.aSecondWord; | 56 | return this.aSecondWord; |
26 | } | 57 | } |
27 | 58 | ||
59 | /** | ||
60 | * @return true if this command was not understood. | ||
61 | */ | ||
28 | public boolean isUnknown() { | 62 | public boolean isUnknown() { |
29 | return this.aCommandWord == null; | 63 | return this.aCommandWord == null; |
30 | } | 64 | } |
31 | 65 | ||
66 | /** | ||
67 | * @return true if the command has a second word. | ||
68 | */ | ||
32 | public boolean hasSecondWord() { | 69 | public boolean hasSecondWord() { |
33 | return this.aSecondWord != null; | 70 | return this.aSecondWord != null; |
34 | } | 71 | } |
diff --git a/src/esieequest/Game.java b/src/esieequest/Game.java index 89b7318..638c9b8 100644 --- a/src/esieequest/Game.java +++ b/src/esieequest/Game.java | |||
@@ -3,6 +3,10 @@ package esieequest; | |||
3 | /** | 3 | /** |
4 | * The game engine. | 4 | * The game engine. |
5 | * | 5 | * |
6 | * This class creates and initializes all the others: it creates all rooms, | ||
7 | * creates the parser and starts the game. It also evaluates and executes the | ||
8 | * commands that the parser returns. | ||
9 | * | ||
6 | * @author Pacien TRAN-GIRARD | 10 | * @author Pacien TRAN-GIRARD |
7 | * @author Benoit LUBRANO DI SBARAGLIONE | 11 | * @author Benoit LUBRANO DI SBARAGLIONE |
8 | * | 12 | * |
@@ -12,13 +16,19 @@ public class Game { | |||
12 | private Room aCurrentRoom; | 16 | private Room aCurrentRoom; |
13 | private Parser aParser; | 17 | private Parser aParser; |
14 | 18 | ||
19 | /** | ||
20 | * Create the game and initialize its internal map. | ||
21 | */ | ||
15 | public Game() { | 22 | public Game() { |
16 | this.createRooms(); | 23 | this.createRooms(); |
17 | this.printWelcome(); | 24 | this.printWelcome(); |
18 | this.printRoomInfo(); | 25 | this.printLocationInfo(); |
19 | this.play(); | 26 | this.play(); |
20 | } | 27 | } |
21 | 28 | ||
29 | /** | ||
30 | * Main play routine. Loops until end of play. | ||
31 | */ | ||
22 | private void play() { | 32 | private void play() { |
23 | aParser = new Parser(); | 33 | aParser = new Parser(); |
24 | boolean vFinished = false; | 34 | boolean vFinished = false; |
@@ -30,6 +40,9 @@ public class Game { | |||
30 | System.out.println("Thank you for playing. Good bye."); | 40 | System.out.println("Thank you for playing. Good bye."); |
31 | } | 41 | } |
32 | 42 | ||
43 | /** | ||
44 | * Create all the rooms and link their exits together. | ||
45 | */ | ||
33 | private void createRooms() { | 46 | private void createRooms() { |
34 | // create rooms | 47 | // create rooms |
35 | Room vAmphitheaterSeat = new Room("in the amphitheater"); | 48 | Room vAmphitheaterSeat = new Room("in the amphitheater"); |
@@ -78,78 +91,101 @@ public class Game { | |||
78 | Room vOffscriptMovingcharacterMo = new Room("in M-O's room"); | 91 | Room vOffscriptMovingcharacterMo = new Room("in M-O's room"); |
79 | 92 | ||
80 | // connect rooms (N, W, S, E) | 93 | // connect rooms (N, W, S, E) |
81 | vAmphitheaterSeat.setExits(vAmphitheaterStage, null, null, null); | 94 | vAmphitheaterSeat.setExit("north", vAmphitheaterStage); |
82 | vAmphitheaterStage.setExits(null, vCafeteria, null, null); | 95 | vAmphitheaterStage.setExit("west", vCafeteria); |
83 | 96 | ||
84 | vCafeteriaStreet.setExits(null, null, vCafeteria, vEsieespaceStreet); | 97 | vCafeteriaStreet.setExit("south", vCafeteria); |
85 | vCafeteria.setExits(vCafeteriaStreet, null, null, vAmphitheaterStage); | 98 | vCafeteriaStreet.setExit("east", vEsieespaceStreet); |
86 | 99 | vCafeteria.setExit("north", vCafeteriaStreet); | |
87 | vEsieespaceStreet.setExits(null, vCafeteria, vEsieespaceFront, vEntranceStreet); | 100 | vCafeteria.setExit("east", vAmphitheaterStage); |
88 | vEsieespaceFront.setExits(vEsieespaceStreet, null, null, vEsieespaceEntrance); | 101 | |
89 | vEsieespaceEntrance.setExits(vEsieespace, vEsieespaceFront, null, null); | 102 | vEsieespaceStreet.setExit("west", vCafeteria); |
90 | vEsieespace.setExits(null, null, vEsieespaceEntrance, null); | 103 | vEsieespaceStreet.setExit("south", vEsieespaceFront); |
91 | 104 | vEsieespaceStreet.setExit("east", vEntranceStreet); | |
92 | vClubnixStreet.setExits(null, vWingStreet, vClubnixFront, null); | 105 | vEsieespaceFront.setExit("north", vEsieespaceStreet); |
93 | vClubnixFront.setExits(vClubnixStreet, null, null, vClubnixEntrance); | 106 | vEsieespaceFront.setExit("east", vEsieespaceEntrance); |
94 | vClubnixEntrance.setExits(vClubnix, vClubnixFront, null, null); | 107 | vEsieespaceEntrance.setExit("north", vEsieespace); |
95 | vClubnix.setExits(null, null, vClubnixEntrance, null); | 108 | vEsieespaceEntrance.setExit("west", vEsieespaceFront); |
96 | 109 | vEsieespace.setExit("south", vEsieespaceEntrance); | |
97 | vEntranceStreet.setExits(null, vEsieespaceStreet, vEntranceStairs, vWingStreet); | 110 |