aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-03-15 13:57:11 +0100
committerPacien TRAN-GIRARD2016-03-15 13:59:15 +0100
commit3b8c85a5f483c856b34c7026f48abd4f355b67d7 (patch)
tree4c24fd76c0d0644c7d9bedb5fccfacfee78bc1ca
parent59d35ae34c4513f54decf056e944190d7e9926f0 (diff)
downloadxblast-3b8c85a5f483c856b34c7026f48abd4f355b67d7.tar.gz
Code clean up and reformatting
-rw-r--r--src/ch/epfl/xblast/ArgumentChecker.java5
-rw-r--r--src/ch/epfl/xblast/Time.java12
-rw-r--r--src/ch/epfl/xblast/server/Block.java14
-rw-r--r--src/ch/epfl/xblast/server/Bonus.java24
-rw-r--r--src/ch/epfl/xblast/server/GameState.java74
-rw-r--r--src/ch/epfl/xblast/server/Ticks.java3
6 files changed, 78 insertions, 54 deletions
diff --git a/src/ch/epfl/xblast/ArgumentChecker.java b/src/ch/epfl/xblast/ArgumentChecker.java
index 311807e..589c197 100644
--- a/src/ch/epfl/xblast/ArgumentChecker.java
+++ b/src/ch/epfl/xblast/ArgumentChecker.java
@@ -16,11 +16,10 @@ public final class ArgumentChecker {
16 * @throws IllegalArgumentException if the value is inferior to 0 16 * @throws IllegalArgumentException if the value is inferior to 0
17 */ 17 */
18 public static int requireNonNegative(int value) { 18 public static int requireNonNegative(int value) {
19 if (value >= 0) { 19 if (value >= 0)
20 return value; 20 return value;
21 } else { 21 else
22 throw new IllegalArgumentException(); 22 throw new IllegalArgumentException();
23 }
24 } 23 }
25 24
26} 25}
diff --git a/src/ch/epfl/xblast/Time.java b/src/ch/epfl/xblast/Time.java
index d39c3e3..7c84257 100644
--- a/src/ch/epfl/xblast/Time.java
+++ b/src/ch/epfl/xblast/Time.java
@@ -1,6 +1,13 @@
1package ch.epfl.xblast; 1package ch.epfl.xblast;
2 2
3/**
4 * Time unit constants.
5 *
6 * @author Pacien TRAN-GIRARD (261948)
7 * @author Timothée FLOURE (257420)
8 */
3public interface Time { 9public interface Time {
10
4 /** 11 /**
5 * Number of seconds per minute. 12 * Number of seconds per minute.
6 */ 13 */
@@ -14,10 +21,11 @@ public interface Time {
14 /** 21 /**
15 * Number of microseconds per second. 22 * Number of microseconds per second.
16 */ 23 */
17 int US_PER_S = 1000*MS_PER_S; 24 int US_PER_S = 1000 * MS_PER_S;
18 25
19 /** 26 /**
20 * Number of nanoseconds per second. 27 * Number of nanoseconds per second.
21 */ 28 */
22 int NS_PER_S = 1000*US_PER_S; 29 int NS_PER_S = 1000 * US_PER_S;
30
23} 31}
diff --git a/src/ch/epfl/xblast/server/Block.java b/src/ch/epfl/xblast/server/Block.java
index fff3819..c90a469 100644
--- a/src/ch/epfl/xblast/server/Block.java
+++ b/src/ch/epfl/xblast/server/Block.java
@@ -31,12 +31,12 @@ public enum Block {
31 CRUMBLING_WALL, 31 CRUMBLING_WALL,
32 32
33 /** 33 /**
34 * Bonus increasing the maximun number of bombs. 34 * Bonus increasing the maximum number of bombs.
35 */ 35 */
36 BONUS_BOMB(Bonus.INC_BOMB), 36 BONUS_BOMB(Bonus.INC_BOMB),
37 37
38 /** 38 /**
39 * Nomus increasing the range of the bombs. 39 * Bonus increasing the range of the bombs.
40 */ 40 */
41 BONUS_RANGE(Bonus.INC_RANGE); 41 BONUS_RANGE(Bonus.INC_RANGE);
42 42
@@ -87,7 +87,7 @@ public enum Block {
87 } 87 }
88 88
89 /** 89 /**
90 * Returns T(this block is a bonus) 90 * Returns T(this block is a bonus).
91 * 91 *
92 * @return T(this block is a bonus) 92 * @return T(this block is a bonus)
93 */ 93 */
@@ -96,15 +96,13 @@ public enum Block {
96 } 96 }
97 97
98 /** 98 /**
99 * Return the bonus associated with the block. 99 * Returns the bonus associated with the block.
100 * 100 *
101 * @throws NoSuchElementException if there is no such bonus.
102 * @return the bonus associated with the block. 101 * @return the bonus associated with the block.
102 * @throws NoSuchElementException if there is no such bonus.
103 */ 103 */
104 public Bonus associatedBonus() { 104 public Bonus associatedBonus() {
105 if (this.maybeAssociatedBonus == null) { 105 if (this.maybeAssociatedBonus == null) throw new NoSuchElementException();
106 throw new NoSuchElementException();
107 }
108 return this.maybeAssociatedBonus; 106 return this.maybeAssociatedBonus;
109 } 107 }
110 108
diff --git a/src/ch/epfl/xblast/server/Bonus.java b/src/ch/epfl/xblast/server/Bonus.java
index 81ae7dd..09a2248 100644
--- a/src/ch/epfl/xblast/server/Bonus.java
+++ b/src/ch/epfl/xblast/server/Bonus.java
@@ -1,24 +1,33 @@
1package ch.epfl.xblast.server; 1package ch.epfl.xblast.server;
2 2
3/** 3/**
4 * @author TimothéE FLOURE (257420) 4 * Bonuses.
5 *
6 * @author Pacien TRAN-GIRARD (261948)
7 * @author Timothée FLOURE (257420)
5 */ 8 */
6public enum Bonus { 9public enum Bonus {
7 10
8 /** 11 /**
9 * Increase the maximum number of bombs used simultaneously. 12 * Increases the maximum number of bombs used simultaneously.
10 */ 13 */
11 INC_BOMB { 14 INC_BOMB {
12 @Override 15 @Override
13 public Player applyTo(Player player) { return null; } 16 public Player applyTo(Player player) {
17 // TODO
18 return null;
19 }
14 }, 20 },
15 21
16 /** 22 /**
17 * Increase the range of the bombs. 23 * Increases the range of the bombs.
18 */ 24 */
19 INC_RANGE { 25 INC_RANGE {
20 @Override 26 @Override
21 public Player applyTo(Player player) { return null; } 27 public Player applyTo(Player player) {
28 // TODO
29 return null;
30 }
22 }; 31 };
23 32
24 /** 33 /**
@@ -27,4 +36,5 @@ public enum Bonus {
27 * @param player receiving the bonus 36 * @param player receiving the bonus
28 */ 37 */
29 abstract public Player applyTo(Player player); 38 abstract public Player applyTo(Player player);
39
30} 40}
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index 3bd1961..e7e6ca7 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -1,17 +1,22 @@
1package ch.epfl.xblast.server; 1package ch.epfl.xblast.server;
2 2
3import ch.epfl.cs108.Sq;
4import ch.epfl.xblast.ArgumentChecker;
5import ch.epfl.xblast.Cell;
6import ch.epfl.xblast.PlayerID;
7
8import java.util.ArrayList;
3import java.util.List; 9import java.util.List;
4import java.util.Optional;
5import java.util.Objects; 10import java.util.Objects;
6import java.util.ArrayList;
7import java.util.Optional; 11import java.util.Optional;
8import ch.epfl.xblast.*; 12import java.util.stream.Collectors;
9import ch.epfl.cs108.Sq;
10 13
11/** 14/**
15 * GameState representing the current game state.
16 *
17 * @author Pacien TRAN-GIRARD (261948)
12 * @author Timothée FLOURE (257420) 18 * @author Timothée FLOURE (257420)
13 */ 19 */
14
15public final class GameState { 20public final class GameState {
16 21
17 private final int ticks; 22 private final int ticks;
@@ -24,8 +29,8 @@ public final class GameState {
24 /** 29 /**
25 * Compute the next state of a blast. 30 * Compute the next state of a blast.
26 * 31 *
27 * @param blasts0 existing particles 32 * @param blasts0 existing particles
28 * @param board0 the game's board 33 * @param board0 the game's board
29 * @param explosions0 active explosions 34 * @param explosions0 active explosions
30 * @return the position of the explosion's particles for the next state. 35 * @return the position of the explosion's particles for the next state.
31 */ 36 */
@@ -43,16 +48,16 @@ public final class GameState {
43 } 48 }
44 49
45 /** 50 /**
46 * Instanciates a new GameState. 51 * Instantiates a new GameState.
47 * 52 *
48 * @param ticks thie tick corresponding to the state 53 * @param ticks the tick corresponding to the state
49 * @param board the game's board 54 * @param board the game's board
50 * @param players list of the players 55 * @param players list of the players
51 * @param bombs list of the bombs 56 * @param bombs list of the bombs
52 * @param explosions list of the explosions 57 * @param explosions list of the explosions
53 * @param blasts 58 * @param blasts list of particle blasts
54 * @throws IllegalArguementException if ticks is negative or players does not contains 4 play