diff options
author | Pacien TRAN-GIRARD | 2016-04-08 19:28:25 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-04-08 19:28:25 +0200 |
commit | 46752822c0904b0cc1ff787f47787dd4bd6f9b6f (patch) | |
tree | f703d547aff25151e9807ed04c48ff0570cc57f0 /src | |
parent | e3f8e4276d87f2dba10395a882dc4673b65b4e89 (diff) | |
download | xblast-46752822c0904b0cc1ff787f47787dd4bd6f9b6f.tar.gz |
Elaborate documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/ch/epfl/xblast/server/Bomb.java | 12 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 49 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Player.java | 62 |
3 files changed, 93 insertions, 30 deletions
diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index f32960f..2eacf6c 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java | |||
@@ -69,6 +69,8 @@ public final class Bomb { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Returns the Bomb's owner ID. | ||
73 | * | ||
72 | * @return the ID of the owner of the bomb | 74 | * @return the ID of the owner of the bomb |
73 | */ | 75 | */ |
74 | public PlayerID ownerId() { | 76 | public PlayerID ownerId() { |
@@ -76,6 +78,8 @@ public final class Bomb { | |||
76 | } | 78 | } |
77 | 79 | ||
78 | /** | 80 | /** |
81 | * Returns the Bomb's position Cell. | ||
82 | * | ||
79 | * @return the position of the bomb | 83 | * @return the position of the bomb |
80 | */ | 84 | */ |
81 | public Cell position() { | 85 | public Cell position() { |
@@ -83,6 +87,8 @@ public final class Bomb { | |||
83 | } | 87 | } |
84 | 88 | ||
85 | /** | 89 | /** |
90 | * Returns the Bomb's fuse length sequence. | ||
91 | * | ||
86 | * @return the length of the fuse | 92 | * @return the length of the fuse |
87 | */ | 93 | */ |
88 | public Sq<Integer> fuseLengths() { | 94 | public Sq<Integer> fuseLengths() { |
@@ -90,6 +96,8 @@ public final class Bomb { | |||
90 | } | 96 | } |
91 | 97 | ||
92 | /** | 98 | /** |
99 | * Returns the Bomb's fuse length. | ||
100 | * | ||
93 | * @return the remaining time before the explosion | 101 | * @return the remaining time before the explosion |
94 | */ | 102 | */ |
95 | public int fuseLength() { | 103 | public int fuseLength() { |
@@ -97,6 +105,8 @@ public final class Bomb { | |||
97 | } | 105 | } |
98 | 106 | ||
99 | /** | 107 | /** |
108 | * Returns the Bomb's range. | ||
109 | * | ||
100 | * @return the range of the Bomb | 110 | * @return the range of the Bomb |
101 | */ | 111 | */ |
102 | public int range() { | 112 | public int range() { |
@@ -104,6 +114,8 @@ public final class Bomb { | |||
104 | } | 114 | } |
105 | 115 | ||
106 | /** | 116 | /** |
117 | * Builds and returns a new explosion sequence. | ||
118 | * | ||
107 | * @return the explosion | 119 | * @return the explosion |
108 | */ | 120 | */ |
109 | public List<Sq<Sq<Cell>>> explosion() { | 121 | public List<Sq<Sq<Cell>>> explosion() { |
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index fefaf02..2797e41 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java | |||
@@ -206,9 +206,9 @@ public final class GameState { | |||
206 | /** | 206 | /** |
207 | * Generate the new Sequence of Directed Positions. | 207 | * Generate the new Sequence of Directed Positions. |
208 | * | 208 | * |
209 | * @param player0 | 209 | * @param player0 the Player |
210 | * @param requestedDirection | 210 | * @param requestedDirection the requested Direction |
211 | * @return | 211 | * @return the path |
212 | */ | 212 | */ |
213 | private static Sq<Player.DirectedPosition> nextPath(Player player0, Direction requestedDirection) { | 213 | private static Sq<Player.DirectedPosition> nextPath(Player player0, Direction requestedDirection) { |
214 | if (!player0.lifeState().canMove()) | 214 | if (!player0.lifeState().canMove()) |
@@ -232,13 +232,13 @@ public final class GameState { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | /** | 234 | /** |
235 | * Check possible collisions and update the Sequence if necessary (kinda ugly right now) | 235 | * Checks for possible collisions and update the path if necessary. |
236 | * | 236 | * |
237 | * @param player0 | 237 | * @param player0 the Player |
238 | * @param projectedPath | 238 | * @param projectedPath the current path projection |
239 | * @param board1 | 239 | * @param board1 the updated Board |
240 | * @param bombedCells1 | 240 | * @param bombedCells1 the Set of bombed Cell-s |
241 | * @return | 241 | * @return the corrected path |
242 | */ | 242 | */ |
243 | private static Sq<Player.DirectedPosition> handleCollisions(Player player0, | 243 | private static Sq<Player.DirectedPosition> handleCollisions(Player player0, |
244 | Sq<Player.DirectedPosition> projectedPath, | 244 | Sq<Player.DirectedPosition> projectedPath, |
@@ -253,11 +253,12 @@ public final class GameState { | |||
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * @param player0 | 256 | * Computes a projection of the next DirectedPosition. |
257 | * @param projectedPath | 257 | * |
258 | * @return | 258 | * @param player0 the Player |
259 | * @param projectedPath the projected path | ||
260 | * @return the projected next DirectedPosition | ||
259 | */ | 261 | */ |
260 | |||
261 | private static Player.DirectedPosition projectedDirectedPosition(Player player0, Sq<Player.DirectedPosition> projectedPath) { | 262 | private static Player.DirectedPosition projectedDirectedPosition(Player player0, Sq<Player.DirectedPosition> projectedPath) { |
262 | if (!player0.lifeState().canMove()) | 263 | if (!player0.lifeState().canMove()) |
263 | return new Player.DirectedPosition(player0.position(), player0.direction()); | 264 | return new Player.DirectedPosition(player0.position(), player0.direction()); |
@@ -267,11 +268,13 @@ public final class GameState { | |||
267 | } | 268 | } |
268 | 269 | ||
269 | /** | 270 | /** |
270 | * @param player0 | 271 | * Returns T(the player is colliding with an object). |
271 | * @param projectedCell | 272 | * |
272 | * @param board1 | 273 | * @param player0 the Player |
273 | * @param bombedCells1 | 274 | * @param projectedCell the projected next Cell |
274 | * @return | 275 | * @param board1 the updated Board |
276 | * @param bombedCells1 the Set of bombed Cell-s | ||
277 | * @return T(the player is colliding with an object) | ||
275 | */ | 278 | */ |
276 | private static boolean isColliding(Player player0, Cell projectedCell, Board board1, Set<Cell> bombedCells1) { | 279 | private static boolean isColliding(Player player0, Cell projectedCell, Board board1, Set<Cell> bombedCells1) { |
277 | if (!board1.blockAt(projectedCell).canHostPlayer()) | 280 | if (!board1.blockAt(projectedCell).canHostPlayer()) |
@@ -285,12 +288,12 @@ public final class GameState { | |||
285 | } | 288 | } |
286 | 289 | ||
287 | /** | 290 | /** |
288 | * Apply damages and generate a new LifeState Sequence | 291 | * Applies damages and generate a new LifeState sequence. |
289 | * | 292 | * |
290 | * @param player0 | 293 | * @param player0 the Player |
291 | * @param directedPositions1 | 294 | * @param directedPositions1 the DirectedPosition sequence |
292 | * @param blastedCells1 | 295 | * @param blastedCells1 the Set of blasted Cell-s |
293 | * @return | 296 | * @return the next LifeState sequence |
294 | */ | 297 | */ |
295 | private static Sq<Player.LifeState> nextLifeState(Player player0, Sq<Player.DirectedPosition> directedPositions1, | 298 | private static Sq<Player.LifeState> nextLifeState(Player player0, Sq<Player.DirectedPosition> directedPositions1, |
296 | Set<Cell> blastedCells1) { | 299 | Set<Cell> blastedCells1) { |
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index fdc4715..f6f6c99 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java | |||
@@ -44,6 +44,8 @@ public final class Player { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Returns the number of lives. | ||
48 | * | ||
47 | * @return the number of lives | 49 | * @return the number of lives |
48 | */ | 50 | */ |
49 | public int lives() { | 51 | public int lives() { |
@@ -51,6 +53,8 @@ public final class Player { | |||
51 | } | 53 | } |
52 | 54 | ||
53 | /** | 55 | /** |
56 | * Returns the State. | ||
57 | * | ||
54 | * @return the state | 58 | * @return the state |
55 | */ | 59 | */ |
56 | public State state() { | 60 | public State state() { |
@@ -58,7 +62,9 @@ public final class Player { | |||
58 | } | 62 | } |
59 | 63 | ||
60 | /** | 64 | /** |
61 | * @return true if the actual state allow to move | 65 | * Returns T(this State allows the player to move). |
66 | * | ||
67 | * @return T(this State allows the player to move) | ||
62 | */ | 68 | */ |
63 | public boolean canMove() { | 69 | public boolean canMove() { |
64 | return this.state() == State.INVULNERABLE || this.state() == State.VULNERABLE; | 70 | return this.state() == State.INVULNERABLE || this.state() == State.VULNERABLE; |
@@ -75,21 +81,25 @@ public final class Player { | |||
75 | private final Direction direction; | 81 | private final Direction direction; |
76 | 82 | ||
77 | /** | 83 | /** |
78 | * @return an infinite sequence of directed positions corresponding to a stopped player. | 84 | * Builds and returns an infinite sequence of directed positions corresponding to a stopped player. |
85 | * | ||
86 | * @return the sequence | ||
79 | */ | 87 | */ |
80 | public static Sq<DirectedPosition> stopped(DirectedPosition p) { | 88 | public static Sq<DirectedPosition> stopped(DirectedPosition p) { |
81 | return Sq.constant(p); | 89 | return Sq.constant(p); |
82 | } | 90 | } |
83 | 91 | ||
84 | /** | 92 | /** |
85 | * @return an infinite sequence of directed position corresponding to a moving player. | 93 | * Builds and returns an infinite sequence of directed position corresponding to a moving player. |
94 | * | ||
95 | * @return the sequence | ||
86 | */ | 96 | */ |
87 | public static Sq<DirectedPosition> moving(DirectedPosition p) { | 97 | public static Sq<DirectedPosition> moving(DirectedPosition p) { |
88 |