aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimothée Floure2016-03-14 14:08:15 +0100
committerTimothée Floure2016-03-14 14:08:15 +0100
commit06296e66cd53bc68198c3bfeace17f85707cc2f4 (patch)
tree8c53f38ef43f7a9f290d2e04b1ce2074529959a6 /src
parent7b228fed7b480cc5825bb168567a556269f785cb (diff)
downloadxblast-06296e66cd53bc68198c3bfeace17f85707cc2f4.tar.gz
Add the nextBlasts method to the GameState class
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/xblast/server/GameState.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java
index 685bc54..3bd1961 100644
--- a/src/ch/epfl/xblast/server/GameState.java
+++ b/src/ch/epfl/xblast/server/GameState.java
@@ -22,10 +22,31 @@ public final class GameState {
22 private final List<Sq<Cell>> blasts; 22 private final List<Sq<Cell>> blasts;
23 23
24 /** 24 /**
25 * Compute the next state of a blast.
26 *
27 * @param blasts0 existing particles
28 * @param board0 the game's board
29 * @param explosions0 active explosions
30 * @return the position of the explosion's particles for the next state.
31 */
32 private static List<Sq<Cell>> nextBlasts(List<Sq<Cell>> blasts0, Board board0, List<Sq<Sq<Cell>>> explosions0) {
33 List<Sq<Cell>> blasts1 = new ArrayList<>();
34 for (Sq<Cell> blastSeq : blasts0) {
35 if (!blastSeq.tail().isEmpty() && board0.blockAt(blastSeq.head()).isFree()) {
36 blasts1.add(blastSeq.tail());
37 }
38 }
39 for (Sq<Sq<Cell>> explosion0 : explosions0) {
40 blasts1.add(explosion0.head());
41 }
42 return blasts1;
43 }
44
45 /**
25 * Instanciates a new GameState. 46 * Instanciates a new GameState.
26 * 47 *
27 * @param ticks thie tick corresponding to the state 48 * @param ticks thie tick corresponding to the state
28 * @param board the board 49 * @param board the game's board
29 * @param players list of the players 50 * @param players list of the players
30 * @param bombs list of the bombs 51 * @param bombs list of the bombs
31 * @param explosions list of the explosions 52 * @param explosions list of the explosions