aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-04-08 23:48:50 +0200
committerPacien TRAN-GIRARD2016-04-08 23:48:50 +0200
commit0a9b70b88aa3164303de4ca7c0f5b73b4e703674 (patch)
treef2e014ca83feea47e47093b6dc73018df8adc544
parent46752822c0904b0cc1ff787f47787dd4bd6f9b6f (diff)
downloadxblast-0a9b70b88aa3164303de4ca7c0f5b73b4e703674.tar.gz
Code clean up
-rw-r--r--src/ch/epfl/xblast/Cell.java2
-rw-r--r--src/ch/epfl/xblast/Lists.java2
-rw-r--r--src/ch/epfl/xblast/SubCell.java8
-rw-r--r--src/ch/epfl/xblast/server/Board.java2
-rw-r--r--src/ch/epfl/xblast/server/Bomb.java5
-rw-r--r--src/ch/epfl/xblast/server/Player.java2
6 files changed, 12 insertions, 9 deletions
diff --git a/src/ch/epfl/xblast/Cell.java b/src/ch/epfl/xblast/Cell.java
index 06dfdbb..ecad75b 100644
--- a/src/ch/epfl/xblast/Cell.java
+++ b/src/ch/epfl/xblast/Cell.java
@@ -103,7 +103,7 @@ public final class Cell {
103 * @param n the number to normalize (the dividend) 103 * @param n the number to normalize (the dividend)
104 * @return the normalized value 104 * @return the normalized value
105 */ 105 */
106 protected static int normalize(int max, int n) { 106 static int normalize(int max, int n) {
107 return Math.floorMod(n, max); 107 return Math.floorMod(n, max);
108 } 108 }
109 109
diff --git a/src/ch/epfl/xblast/Lists.java b/src/ch/epfl/xblast/Lists.java
index 4ea45c2..bdcfb6a 100644
--- a/src/ch/epfl/xblast/Lists.java
+++ b/src/ch/epfl/xblast/Lists.java
@@ -19,7 +19,7 @@ public final class Lists {
19 * @param <T> the type of the list's elements 19 * @param <T> the type of the list's elements
20 * @return a reversed copy of the list. 20 * @return a reversed copy of the list.
21 */ 21 */
22 public static <T> List<T> reversed(List<T> l) { 22 private static <T> List<T> reversed(List<T> l) {
23 List<T> r = new ArrayList<>(l); 23 List<T> r = new ArrayList<>(l);
24 Collections.reverse(r); 24 Collections.reverse(r);
25 return r; 25 return r;
diff --git a/src/ch/epfl/xblast/SubCell.java b/src/ch/epfl/xblast/SubCell.java
index 27d5bcc..531de01 100644
--- a/src/ch/epfl/xblast/SubCell.java
+++ b/src/ch/epfl/xblast/SubCell.java
@@ -11,22 +11,22 @@ public final class SubCell {
11 /** 11 /**
12 * The number of x-subdivisions of each Cell. 12 * The number of x-subdivisions of each Cell.
13 */ 13 */
14 public static final int SUB_COL_DIVISIONS = 16; 14 private static final int SUB_COL_DIVISIONS = 16;
15 15
16 /** 16 /**
17 * The number of y-subdivisions of each Cell. 17 * The number of y-subdivisions of each Cell.
18 */ 18 */
19 public static final int SUB_ROW_DIVISIONS = 16; 19 private static final int SUB_ROW_DIVISIONS = 16;
20 20
21 /** 21 /**
22 * The width of the board (total of sub-columns). 22 * The width of the board (total of sub-columns).
23 */ 23 */
24 public static final int SUB_COLUMNS = SUB_COL_DIVISIONS * Cell.COLUMNS; 24 private static final int SUB_COLUMNS = SUB_COL_DIVISIONS * Cell.COLUMNS;
25 25
26 /** 26 /**
27 * The height of the board (total of sub-rows). 27 * The height of the board (total of sub-rows).
28 */ 28 */
29 public static final int SUB_ROWS = SUB_ROW_DIVISIONS * Cell.ROWS; 29 private static final int SUB_ROWS = SUB_ROW_DIVISIONS * Cell.ROWS;
30 30
31 /** 31 /**
32 * Returns the central SubCell of the given Cell. 32 * Returns the central SubCell of the given Cell.
diff --git a/src/ch/epfl/xblast/server/Board.java b/src/ch/epfl/xblast/server/Board.java
index 661a7a8..e449a00 100644
--- a/src/ch/epfl/xblast/server/Board.java
+++ b/src/ch/epfl/xblast/server/Board.java
@@ -18,7 +18,7 @@ public final class Board {
18 /** 18 /**
19 * Distance (in SubCells) from a bomb to block a player. 19 * Distance (in SubCells) from a bomb to block a player.
20 */ 20 */
21 public static final int BOMB_BLOCKING_DISTANCE = 6; 21 static final int BOMB_BLOCKING_DISTANCE = 6;
22 22
23 private static final int BLOCKS_LIST_SIZE = 195; 23 private static final int BLOCKS_LIST_SIZE = 195;
24 private static final int BOARD_ROWS = 13; 24 private static final int BOARD_ROWS = 13;
diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java
index 2eacf6c..c1a6b12 100644
--- a/src/ch/epfl/xblast/server/Bomb.java
+++ b/src/ch/epfl/xblast/server/Bomb.java
@@ -8,6 +8,7 @@ import ch.epfl.xblast.PlayerID;
8 8
9import java.util.List; 9import java.util.List;
10import java.util.Objects; 10import java.util.Objects;
11import java.util.function.UnaryOperator;
11import java.util.stream.Collectors; 12import java.util.stream.Collectors;
12import java.util.stream.Stream; 13import java.util.stream.Stream;
13 14
@@ -19,6 +20,8 @@ import java.util.stream.Stream;
19 */ 20 */
20public final class Bomb { 21public final class Bomb {
21 22
23 private static final UnaryOperator<Integer> FUSE_STEP_FUNCTION = fl -> fl - 1;
24
22 private PlayerID ownerId; 25 private PlayerID ownerId;
23 private Cell position; 26 private Cell position;
24 private Sq<Integer> fuseLengths; 27 private Sq<Integer> fuseLengths;
@@ -65,7 +68,7 @@ public final class Bomb {
65 * @throws NullPointerException if ownerId, position or fuseLengths is null 68 * @throws NullPointerException if ownerId, position or fuseLengths is null
66 */ 69 */
67 public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { 70 public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) {
68 this(ownerId, position, Sq.iterate(fuseLength, fl -> fl - 1), range); 71 this(ownerId, position, Sq.iterate(fuseLength, Bomb.FUSE_STEP_FUNCTION), range);
69 } 72 }
70 73
71 /** 74 /**
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java
index f6f6c99..afff209 100644
--- a/src/ch/epfl/xblast/server/Player.java
+++ b/src/ch/epfl/xblast/server/Player.java
@@ -290,7 +290,7 @@ public final class Player {
290 * 290 *
291 * @return the vulnerability state of the player 291 * @return the vulnerability state of the player
292 */ 292 */
293 public boolean isVulnerable() { 293 boolean isVulnerable() {
294 return this.lifeState().state() == LifeState.State.VULNERABLE; 294 return this.lifeState().state() == LifeState.State.VULNERABLE;
295 } 295 }
296 296