diff options
author | Pacien TRAN-GIRARD | 2016-03-07 16:56:11 +0100 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-03-07 16:56:11 +0100 |
commit | bccd4e10938c55f9b30283338120689ea2e1738e (patch) | |
tree | e704df77e118b4d9b1b5bbca6eb5444cfa6bf448 /src/ch | |
parent | 9eab4086c339af39c36b58954f4a99f22f29f4de (diff) | |
download | xblast-bccd4e10938c55f9b30283338120689ea2e1738e.tar.gz |
Elaborate documentation (fix missing doc and typos)
Diffstat (limited to 'src/ch')
-rw-r--r-- | src/ch/epfl/xblast/ArgumentChecker.java | 3 | ||||
-rw-r--r-- | src/ch/epfl/xblast/PlayerID.java | 1 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Bomb.java | 14 | ||||
-rw-r--r-- | src/ch/epfl/xblast/server/Player.java | 57 |
4 files changed, 47 insertions, 28 deletions
diff --git a/src/ch/epfl/xblast/ArgumentChecker.java b/src/ch/epfl/xblast/ArgumentChecker.java index 8e7ba76..a567fbb 100644 --- a/src/ch/epfl/xblast/ArgumentChecker.java +++ b/src/ch/epfl/xblast/ArgumentChecker.java | |||
@@ -3,11 +3,12 @@ package ch.epfl.xblast; | |||
3 | /** | 3 | /** |
4 | * ArgumentChecker. | 4 | * ArgumentChecker. |
5 | * | 5 | * |
6 | * @author Pacien TRAN-GIRARD (261948) | ||
6 | * @author Timothée FLOURE (257420) | 7 | * @author Timothée FLOURE (257420) |
7 | */ | 8 | */ |
8 | public final class ArgumentChecker { | 9 | public final class ArgumentChecker { |
9 | /** | 10 | /** |
10 | * Return the given value if it is non-negative | 11 | * Returns the given value if it is non-negative. |
11 | * | 12 | * |
12 | * @param value the tested value | 13 | * @param value the tested value |
13 | * @throws IllegalArgumentException if the value is inferior to 0 | 14 | * @throws IllegalArgumentException if the value is inferior to 0 |
diff --git a/src/ch/epfl/xblast/PlayerID.java b/src/ch/epfl/xblast/PlayerID.java index 05a280b..bb77405 100644 --- a/src/ch/epfl/xblast/PlayerID.java +++ b/src/ch/epfl/xblast/PlayerID.java | |||
@@ -3,6 +3,7 @@ package ch.epfl.xblast; | |||
3 | /** | 3 | /** |
4 | * IDs the 4 different players. | 4 | * IDs the 4 different players. |
5 | * | 5 | * |
6 | * @author Pacien TRAN-GIRARD (261948) | ||
6 | * @author Timothée FLOURE (257420) | 7 | * @author Timothée FLOURE (257420) |
7 | */ | 8 | */ |
8 | public enum PlayerID { | 9 | public enum PlayerID { |
diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 889dde0..659adb6 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java | |||
@@ -11,6 +11,8 @@ import java.util.List; | |||
11 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * A Bomb. | ||
15 | * | ||
14 | * @author Pacien TRAN-GIRARD (261948) | 16 | * @author Pacien TRAN-GIRARD (261948) |
15 | * @author Timothée FLOURE (257420) | 17 | * @author Timothée FLOURE (257420) |
16 | */ | 18 | */ |
@@ -21,20 +23,20 @@ public final class Bomb { | |||
21 | private int range; | 23 | private int range; |
22 | 24 | ||
23 | /** | 25 | /** |
24 | * Generate one arm of explosion | 26 | * Generates one arm of explosion. |
25 | */ | 27 | */ |
26 | private Sq<Sq<Cell>> explosionArmTowards(Direction dir) { | 28 | private Sq<Sq<Cell>> explosionArmTowards(Direction dir) { |
27 | return Sq.constant( Sq.iterate(position, position -> position.neighbor(dir)).limit(range)).limit(Ticks.EXPLOSION_TICKS); | 29 | return Sq.constant( Sq.iterate(position, position -> position.neighbor(dir)).limit(range)).limit(Ticks.EXPLOSION_TICKS); |
28 | } | 30 | } |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Instanciates a new Bomb. | 33 | * Instantiates a new Bomb. |
32 | * | 34 | * |
33 | * @param ownerId id of the owner of the bomb | 35 | * @param ownerId id of the owner of the bomb |
34 | * @param position position of the bomb | 36 | * @param position position of the bomb |
35 | * @param fuseLengths length of the bomb's fuse | 37 | * @param fuseLengths length of the bomb's fuse |
36 | * @param range range of the bomb | 38 | * @param range range of the bomb |
37 | * @throws IllegalArguementException if range is negative or fuseLenghts is empty | 39 | * @throws IllegalArgumentException if range is negative or fuseLenghts is empty |
38 | * @throws NullPointerException if ownerId, position or fuseLengths is null | 40 | * @throws NullPointerException if ownerId, position or fuseLengths is null |
39 | */ | 41 | */ |
40 | public Bomb(PlayerID ownerId, Cell position, Sq<Integer> fuseLengths, int range) { | 42 | public Bomb(PlayerID ownerId, Cell position, Sq<Integer> fuseLengths, int range) { |
@@ -49,13 +51,13 @@ public final class Bomb { | |||
49 | } | 51 | } |
50 | 52 | ||
51 | /** | 53 | /** |
52 | * Instanciates a new Bomb. | 54 | * Instantiates a new Bomb. |
53 | * | 55 | * |
54 | * @param ownerId id of the owner of the bomb | 56 | * @param ownerId id of the owner of the bomb |
55 | * @param position position of the bomb | 57 | * @param position position of the bomb |
56 | * @param fuseLengths length of the bomb's fuse | 58 | * @param fuseLength length of the bomb's fuse |
57 | * @param range range of the bomb | 59 | * @param range range of the bomb |
58 | * @throws IllegalArguementException if range or fuseLengths is negative | 60 | * @throws IllegalArgumentException if range or fuseLengths is negative |
59 | * @throws NullPointerException if ownerId, position or fuseLengths is null | 61 | * @throws NullPointerException if ownerId, position or fuseLengths is null |
60 | */ | 62 | */ |
61 | public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { | 63 | public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { |
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index 59fb962..0548125 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java | |||
@@ -10,7 +10,7 @@ import ch.epfl.cs108.Sq; | |||
10 | import java.util.Objects; | 10 | import java.util.Objects; |
11 | 11 | ||
12 | /** | 12 | /** |
13 | * Player. | 13 | * A Player. |
14 | * | 14 | * |
15 | * @author Pacien TRAN-GIRARD (261948) | 15 | * @author Pacien TRAN-GIRARD (261948) |
16 | * @author Timothée FLOURE (257420) | 16 | * @author Timothée FLOURE (257420) |
@@ -21,7 +21,7 @@ public final class Player { | |||
21 | */ | 21 | */ |
22 | public static final class LifeState { | 22 | public static final class LifeState { |
23 | /** | 23 | /** |
24 | * Enum containing all the possible states. | 24 | * Enum containing all the possible life states. |
25 | */ | 25 | */ |
26 | public enum State { | 26 | public enum State { |
27 | INVULNERABLE, | 27 | INVULNERABLE, |
@@ -34,9 +34,9 @@ public final class Player { | |||
34 | private final State state; | 34 | private final State state; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Instanciates a new LifeSate. | 37 | * Instantiates a new LifeSate. |
38 | * | 38 | * |
39 | * @param lives the number of lifes | 39 | * @param lives the number of lives |
40 | * @param state the state | 40 | * @param state the state |
41 | * @throws IllegalArgumentException if lives is negative | 41 | * @throws IllegalArgumentException if lives is negative |
42 | */ | 42 | */ |
@@ -89,7 +89,7 @@ public final class Player { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Instanciates a new DirectedPos | 92 | * Instantiates a new DirectedPos |
93 | * | 93 | * |
94 | * @param position the position of the player | 94 | * @param position the position of the player |
95 | * @param direction the direction of the player | 95 | * @param direction the direction of the player |
@@ -129,6 +129,9 @@ public final class Player { | |||
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | ||
133 | * The default Direction of a new Player. | ||
134 | */ | ||
132 | private static final Direction DEFAULT_DIRECTION = Direction.S; | 135 | private static final Direction DEFAULT_DIRECTION = Direction.S; |
133 | 136 | ||
134 | private final PlayerID id; | 137 | private final PlayerID id; |
@@ -137,6 +140,12 @@ public final class Player { | |||
137 | private final int maxBombs; | 140 | private final int maxBombs; |
138 | private final int bombRange; | 141 | private final int bombRange; |
139 | 142 | ||
143 | /** | ||
144 | * Builds a default LifeState sequence with the given number of lives. | ||
145 | * | ||
146 | * @param lives number of lives of the desired sequence | ||
147 | * @return the sequence | ||
148 | */ | ||
140 | private static Sq<LifeState> buildDefaultLifeStateSequence(int lives) { | 149 | private static Sq<LifeState> buildDefaultLifeStateSequence(int lives) { |
141 | LifeState invulnerability = new LifeState( | 150 | LifeState invulnerability = new LifeState( |
142 | ArgumentChecker.requireNonNegative(lives), | 151 | ArgumentChecker.requireNonNegative(lives), |
@@ -150,6 +159,12 @@ public final class Player { | |||
150 | return Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); | 159 | return Sq.repeat(Ticks.PLAYER_INVULNERABLE_TICKS,invulnerability).concat(Sq.constant(vulnerability)); |
151 | } | 160 | } |
152 | 161 | ||
162 | /** | ||
163 | * Builds a default DirectedPosition sequence at the given position. | ||
164 | * | ||
165 | * @param pos the position | ||
166 | * @return the sequence | ||
167 | */ | ||
153 | private static Sq<DirectedPosition> buildDefaultDirectedPositionSequence(Cell pos) { | 168 | private static Sq<DirectedPosition> buildDefaultDirectedPositionSequence(Cell pos) { |
154 | DirectedPosition dp = new DirectedPosition( | 169 | DirectedPosition dp = new DirectedPosition( |
155 | SubCell.centralSubCellOf(Objects.requireNonNull(pos)), | 170 | SubCell.centralSubCellOf(Objects.requireNonNull(pos)), |
@@ -160,15 +175,15 @@ public final class Player { | |||
160 | } | 175 | } |
161 | 176 | ||
162 | /** | 177 | /** |
163 | * Instanciates a new Player. | 178 | * Instantiates a new Player. |
164 | * | 179 | * |
165 | * @param id | 180 | * @param id the Player's id |
166 | * @param lifeStates | 181 | * @param lifeStates a sequence of LifeState-s |
167 | * @param directedPos | 182 | * @param directedPos a sequence of DirectedPosition-s |
168 | * @param maxBombs | 183 | * @param maxBombs the maximum number of Bomb-s the Player can carry |
169 | * @param bombRange | 184 | * @param bombRange the range of the Bomb-s |
170 | * @throws IllegalArfuementException | 185 | * @throws IllegalArgumentException |
171 | * @throws NullPointerExeption | 186 | * @throws NullPointerException |
172 | */ | 187 | */ |
173 | public Player(PlayerID id, Sq<LifeState> lifeStates, Sq<DirectedPosition> directedPos, int maxBombs, int bombRange) { | 188 | public Player(PlayerID id, Sq<LifeState> lifeStates, Sq<DirectedPosition> directedPos, int maxBombs, int bombRange) { |
174 | this.id = Objects.requireNonNull(id); | 189 | this.id = Objects.requireNonNull(id); |
@@ -179,15 +194,15 @@ public final class Player { | |||
179 | } | 194 | } |
180 | 195 | ||
181 | /** | 196 | /** |
182 | * Instanciates a new Player. | 197 | * Instantiates a new Player. |
183 | * | 198 | * |
184 | * @param id | 199 | * @param id the Player's id |
185 | * @param lives |