aboutsummaryrefslogtreecommitdiff
path: root/src/ch/epfl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl')
-rw-r--r--src/ch/epfl/xblast/Lists.java16
-rw-r--r--src/ch/epfl/xblast/client/painter/TimeLinePainter.java5
-rw-r--r--src/ch/epfl/xblast/server/GameStateSerializer.java4
3 files changed, 19 insertions, 6 deletions
diff --git a/src/ch/epfl/xblast/Lists.java b/src/ch/epfl/xblast/Lists.java
index 3794c1e..526ebf4 100644
--- a/src/ch/epfl/xblast/Lists.java
+++ b/src/ch/epfl/xblast/Lists.java
@@ -130,12 +130,24 @@ public final class Lists {
130 * @param lists the lists to concatenate 130 * @param lists the lists to concatenate
131 * @param <T> the type of the list's elements 131 * @param <T> the type of the list's elements
132 * @return the list result of the concatenation 132 * @return the list result of the concatenation
133 * @deprecated Use List<T> concatenated(List<List<T>> lists) instead to avoid parametrized varargs.
133 */ 134 */
134 public static <T> List<T> concatenated(List<T>... lists) { 135 public static <T> List<T> concatenated(List<T>... lists) {
136 return concatenated(Arrays.asList(lists));
137 }
138
139 /**
140 * Returns an immutable copy of the given lists, concatenated.
141 *
142 * @param lists the lists to concatenate
143 * @param <T> the type of the list's elements
144 * @return the list result of the concatenation
145 */
146 public static <T> List<T> concatenated(List<List<T>> lists) {
135 return Collections.unmodifiableList( 147 return Collections.unmodifiableList(
136 Stream.of(lists) 148 lists.stream()
137 .map(List::stream) 149 .map(List::stream)
138 .reduce(Stream::concat).orElse(Stream.empty()) 150 .reduce(Stream::concat).orElseGet(Stream::empty)
139 .collect(Collectors.toList())); 151 .collect(Collectors.toList()));
140 } 152 }
141 153
diff --git a/src/ch/epfl/xblast/client/painter/TimeLinePainter.java b/src/ch/epfl/xblast/client/painter/TimeLinePainter.java
index 7912d88..c8b0bd5 100644
--- a/src/ch/epfl/xblast/client/painter/TimeLinePainter.java
+++ b/src/ch/epfl/xblast/client/painter/TimeLinePainter.java
@@ -5,6 +5,7 @@ import ch.epfl.xblast.client.ImageCollection;
5import ch.epfl.xblast.server.Ticks; 5import ch.epfl.xblast.server.Ticks;
6 6
7import java.awt.*; 7import java.awt.*;
8import java.util.Arrays;
8import java.util.Collections; 9import java.util.Collections;
9import java.util.List; 10import java.util.List;
10 11
@@ -31,9 +32,9 @@ public class TimeLinePainter {
31 * @return the list of images composing the time "line" 32 * @return the list of images composing the time "line"
32 */ 33 */
33 public static List<Image> buildTimeLine(int t) { 34 public static List<Image> buildTimeLine(int t) {
34 return Lists.concatenated( 35 return Lists.concatenated(Arrays.asList(
35 Collections.nCopies(t, LED_ON_IMG), 36 Collections.nCopies(t, LED_ON_IMG),
36 Collections.nCopies(TIME_LINE_SIZE - t, LED_OFF_IMG)); 37 Collections.nCopies(TIME_LINE_SIZE - t, LED_OFF_IMG)));
37 } 38 }
38 39
39} 40}
diff --git a/src/ch/epfl/xblast/server/GameStateSerializer.java b/src/ch/epfl/xblast/server/GameStateSerializer.java
index df448a5..b7d7758 100644
--- a/src/ch/epfl/xblast/server/GameStateSerializer.java
+++ b/src/ch/epfl/xblast/server/GameStateSerializer.java
@@ -143,11 +143,11 @@ public final class GameStateSerializer {
143 * @return the serialized GameState 143 * @return the serialized GameState
144 */ 144 */
145 public static List<Byte> serialize(BoardPainter bp, GameState gs) { 145 public static List<Byte> serialize(BoardPainter bp, GameState gs) {
146 return Lists.concatenated( 146 return Lists.concatenated(Arrays.asList(
147 compress(serializeBoard(bp, gs.board())), 147 compress(serializeBoard(bp, gs.board())),
148 compress(serializeExplosions(gs.bombedCells(), gs.blastedCells(), gs.board())), 148 compress(serializeExplosions(gs.bombedCells(), gs.blastedCells(), gs.board())),
149 serializePlayers(gs.players(), gs.ticks()), 149 serializePlayers(gs.players(), gs.ticks()),
150 serializeRemainingTime(gs.remainingTime())); 150 serializeRemainingTime(gs.remainingTime())));
151 } 151 }
152 152
153} 153}