From 0a9b70b88aa3164303de4ca7c0f5b73b4e703674 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 8 Apr 2016 23:48:50 +0200 Subject: Code clean up --- src/ch/epfl/xblast/Cell.java | 2 +- src/ch/epfl/xblast/Lists.java | 2 +- src/ch/epfl/xblast/SubCell.java | 8 ++++---- src/ch/epfl/xblast/server/Board.java | 2 +- src/ch/epfl/xblast/server/Bomb.java | 5 ++++- src/ch/epfl/xblast/server/Player.java | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/ch') 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 { * @param n the number to normalize (the dividend) * @return the normalized value */ - protected static int normalize(int max, int n) { + static int normalize(int max, int n) { return Math.floorMod(n, max); } 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 { * @param the type of the list's elements * @return a reversed copy of the list. */ - public static List reversed(List l) { + private static List reversed(List l) { List r = new ArrayList<>(l); Collections.reverse(r); 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 { /** * The number of x-subdivisions of each Cell. */ - public static final int SUB_COL_DIVISIONS = 16; + private static final int SUB_COL_DIVISIONS = 16; /** * The number of y-subdivisions of each Cell. */ - public static final int SUB_ROW_DIVISIONS = 16; + private static final int SUB_ROW_DIVISIONS = 16; /** * The width of the board (total of sub-columns). */ - public static final int SUB_COLUMNS = SUB_COL_DIVISIONS * Cell.COLUMNS; + private static final int SUB_COLUMNS = SUB_COL_DIVISIONS * Cell.COLUMNS; /** * The height of the board (total of sub-rows). */ - public static final int SUB_ROWS = SUB_ROW_DIVISIONS * Cell.ROWS; + private static final int SUB_ROWS = SUB_ROW_DIVISIONS * Cell.ROWS; /** * 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 { /** * Distance (in SubCells) from a bomb to block a player. */ - public static final int BOMB_BLOCKING_DISTANCE = 6; + static final int BOMB_BLOCKING_DISTANCE = 6; private static final int BLOCKS_LIST_SIZE = 195; 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; import java.util.List; import java.util.Objects; +import java.util.function.UnaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -19,6 +20,8 @@ import java.util.stream.Stream; */ public final class Bomb { + private static final UnaryOperator FUSE_STEP_FUNCTION = fl -> fl - 1; + private PlayerID ownerId; private Cell position; private Sq fuseLengths; @@ -65,7 +68,7 @@ public final class Bomb { * @throws NullPointerException if ownerId, position or fuseLengths is null */ public Bomb(PlayerID ownerId, Cell position, int fuseLength, int range) { - this(ownerId, position, Sq.iterate(fuseLength, fl -> fl - 1), range); + this(ownerId, position, Sq.iterate(fuseLength, Bomb.FUSE_STEP_FUNCTION), range); } /** 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 { * * @return the vulnerability state of the player */ - public boolean isVulnerable() { + boolean isVulnerable() { return this.lifeState().state() == LifeState.State.VULNERABLE; } -- cgit v1.2.3