diff options
Diffstat (limited to 'src/main/java/fr/umlv')
43 files changed, 1249 insertions, 1249 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/board/Board.java b/src/main/java/fr/umlv/java/wallj/board/Board.java index c697cc2..a4ac421 100644 --- a/src/main/java/fr/umlv/java/wallj/board/Board.java +++ b/src/main/java/fr/umlv/java/wallj/board/Board.java | |||
@@ -1,68 +1,68 @@ | |||
1 | package fr.umlv.java.wallj.board; | 1 | package fr.umlv.java.wallj.board; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.model.BlockType; | 3 | import fr.umlv.java.wallj.model.BlockType; |
4 | import fr.umlv.java.wallj.utils.Matrix; | 4 | import fr.umlv.java.wallj.utils.Matrix; |
5 | 5 | ||
6 | /** | 6 | /** |
7 | * An immutable BlockType matrix. | 7 | * An immutable BlockType matrix. |
8 | * | 8 | * |
9 | * @author Pacien TRAN-GIRARD | 9 | * @author Pacien TRAN-GIRARD |
10 | */ | 10 | */ |
11 | public final class Board { | 11 | public final class Board { |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Board Builder | 14 | * Board Builder |
15 | */ | 15 | */ |
16 | public static final class Builder { | 16 | public static final class Builder { |
17 | private final BlockType[][] map; | 17 | private final BlockType[][] map; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @param width width in tiles | 20 | * @param width width in tiles |
21 | * @param height height in tiles | 21 | * @param height height in tiles |
22 | */ | 22 | */ |
23 | public Builder(int width, int height) { | 23 | public Builder(int width, int height) { |
24 | this.map = new BlockType[width][height]; | 24 | this.map = new BlockType[width][height]; |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @param pos the tile position vector | 28 | * @param pos the tile position vector |
29 | * @param type the BlockType to set | 29 | * @param type the BlockType to set |
30 | * @return the Builder | 30 | * @return the Builder |
31 | */ | 31 | */ |
32 | public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { | 32 | public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { |
33 | map[pos.getCol()][pos.getRow()] = type; | 33 | map[pos.getCol()][pos.getRow()] = type; |
34 | return this; | 34 | return this; |
35 | } | 35 | } |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * @return the immutable Board | 38 | * @return the immutable Board |
39 | */ | 39 | */ |
40 | public Board build() { | 40 | public Board build() { |
41 | return new Board(map); | 41 | return new Board(map); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | private final BlockType[][] map; | 45 | private final BlockType[][] map; |
46 | 46 | ||
47 | private Board(BlockType[][] map) { | 47 | private Board(BlockType[][] map) { |
48 | int w = Matrix.getWidth(map), h = Matrix.getHeight(map); | 48 | int w = Matrix.getWidth(map), h = Matrix.getHeight(map); |
49 | this.map = new BlockType[h][w]; | 49 | this.map = new BlockType[h][w]; |
50 | for (int row = 0; row < h; ++row) System.arraycopy(map[row], 0, this.map[row], 0, w); | 50 | for (int row = 0; row < h; ++row) System.arraycopy(map[row], 0, this.map[row], 0, w); |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * @param pos the tile position vector | 54 | * @param pos the tile position vector |
55 | * @return the element at the given position | 55 | * @return the element at the given position |
56 | */ | 56 | */ |
57 | public BlockType getBlockTypeAt(TileVec2 pos) { | 57 | public BlockType getBlockTypeAt(TileVec2 pos) { |
58 | return map[pos.getCol()][pos.getRow()]; | 58 | return map[pos.getCol()][pos.getRow()]; |
59 | } | 59 | } |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * @return the dimension of the Board | 62 | * @return the dimension of the Board |
63 | */ | 63 | */ |
64 | public TileVec2 getDim() { | 64 | public TileVec2 getDim() { |
65 | return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); | 65 | return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); |
66 | } | 66 | } |
67 | 67 | ||
68 | } | 68 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java index 4f67458..9f5736a 100644 --- a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java +++ b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java | |||
@@ -1,5 +1,5 @@ | |||
1 | package fr.umlv.java.wallj.board; | 1 | package fr.umlv.java.wallj.board; |
2 | 2 | ||
3 | public class BoardConverter { | 3 | public class BoardConverter { |
4 | //TODO | 4 | //TODO |
5 | } | 5 | } |
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java index 3d8386a..a9dca27 100644 --- a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java +++ b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java | |||
@@ -1,71 +1,71 @@ | |||
1 | package fr.umlv.java.wallj.board; | 1 | package fr.umlv.java.wallj.board; |
2 | 2 | ||
3 | import fr.umlv.java.wallj.model.BlockType; | 3 | import fr.umlv.java.wallj.model.BlockType; |
4 | import fr.umlv.java.wallj.utils.Matrix; | 4 | import fr.umlv.java.wallj.utils.Matrix; |
5 | 5 | ||
6 | import java.io.IOException; | 6 | import java.io.IOException; |
7 | import java.nio.file.Files; | 7 | import java.nio.file.Files; |
8 | import java.nio.file.Path; | 8 | import java.nio.file.Path; |
9 | import java.util.List; | 9 | import java.util.List; |
10 | import java.util.ListIterator; | 10 | import java.util.ListIterator; |
11 | import java.util.stream.Collectors; | 11 | import java.util.stream.Collectors; |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Board deserializer. | 14 | * Board deserializer. |
15 | * | 15 | * |