From 06296e66cd53bc68198c3bfeace17f85707cc2f4 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Mon, 14 Mar 2016 14:08:15 +0100 Subject: Add the nextBlasts method to the GameState class --- src/ch/epfl/xblast/server/GameState.java | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 @@ -21,11 +21,32 @@ public final class GameState { private final List>> explosions; private final List> blasts; + /** + * Compute the next state of a blast. + * + * @param blasts0 existing particles + * @param board0 the game's board + * @param explosions0 active explosions + * @return the position of the explosion's particles for the next state. + */ + private static List> nextBlasts(List> blasts0, Board board0, List>> explosions0) { + List> blasts1 = new ArrayList<>(); + for (Sq blastSeq : blasts0) { + if (!blastSeq.tail().isEmpty() && board0.blockAt(blastSeq.head()).isFree()) { + blasts1.add(blastSeq.tail()); + } + } + for (Sq> explosion0 : explosions0) { + blasts1.add(explosion0.head()); + } + return blasts1; + } + /** * Instanciates a new GameState. * * @param ticks thie tick corresponding to the state - * @param board the board + * @param board the game's board * @param players list of the players * @param bombs list of the bombs * @param explosions list of the explosions -- cgit v1.2.3