diff options
Diffstat (limited to 'test/ch/epfl')
-rw-r--r-- | test/ch/epfl/xblast/painter/BoardPainterTest.java | 42 | ||||
-rw-r--r-- | test/ch/epfl/xblast/painter/ExplosionPainterTest.java | 23 | ||||
-rw-r--r-- | test/ch/epfl/xblast/painter/PlayerPainterTest.java | 39 |
3 files changed, 57 insertions, 47 deletions
diff --git a/test/ch/epfl/xblast/painter/BoardPainterTest.java b/test/ch/epfl/xblast/painter/BoardPainterTest.java index 9ac8ad4..050e84f 100644 --- a/test/ch/epfl/xblast/painter/BoardPainterTest.java +++ b/test/ch/epfl/xblast/painter/BoardPainterTest.java | |||
@@ -1,34 +1,40 @@ | |||
1 | package ch.epfl.xblast.painter; | 1 | package ch.epfl.xblast.painter; |
2 | 2 | ||
3 | import ch.epfl.xblast.*; | 3 | import ch.epfl.xblast.Cell; |
4 | import ch.epfl.xblast.server.*; | 4 | import ch.epfl.xblast.server.Block; |
5 | import ch.epfl.xblast.server.painter.*; | 5 | import ch.epfl.xblast.server.Board; |
6 | 6 | import ch.epfl.xblast.server.painter.BlockImage; | |
7 | import java.util.Arrays; | 7 | import ch.epfl.xblast.server.painter.BoardPainter; |
8 | import java.util.HashMap; | ||
9 | |||
10 | import org.junit.Assert; | 8 | import org.junit.Assert; |
11 | import org.junit.Test; | 9 | import org.junit.Test; |
12 | 10 | ||
11 | import java.util.Arrays; | ||
12 | import java.util.HashMap; | ||
13 | |||
13 | /** | 14 | /** |
14 | * @author Timothée Floure (257420) | 15 | * @author Timothée Floure (257420) |
16 | * @author Pacien TRAN-GIRARD (261948) | ||
15 | */ | 17 | */ |
16 | public class BoardPainterTest { | 18 | public class BoardPainterTest { |
17 | 19 | ||
18 | public static Board createBoard() { | 20 | private static Board createBoard() { |
19 | Block __ = Block.FREE; | 21 | Block __ = Block.FREE; |
20 | Block XX = Block.INDESTRUCTIBLE_WALL; | 22 | Block XX = Block.INDESTRUCTIBLE_WALL; |
21 | Block xx = Block.DESTRUCTIBLE_WALL; | 23 | Block xx = Block.DESTRUCTIBLE_WALL; |
22 | return Board.ofQuadrantNWBlocksWalled(Arrays.asList(Arrays.asList(__, __, __, __, __, xx, __), | 24 | return Board.ofQuadrantNWBlocksWalled( |
23 | Arrays.asList(__, XX, xx, XX, xx, XX, xx), Arrays.asList(__, xx, __, __, __, xx, __), | 25 | Arrays.asList( |
24 | Arrays.asList(xx, XX, __, XX, XX, XX, XX), Arrays.asList(__, xx, __, xx, __, __, __), | 26 | Arrays.asList(__, __, __, __, __, xx, __), |
25 | Arrays.asList(xx, XX, xx, XX, xx, XX, __))); | 27 | Arrays.asList(__, XX, xx, XX, xx, XX, xx), |
28 | Arrays.asList(__, xx, __, __, __, xx, __), | ||
29 | Arrays.asList(xx, XX, __, XX, XX, XX, XX), | ||
30 | Arrays.asList(__, xx, __, xx, __, __, __), | ||
31 | Arrays.asList(xx, XX, xx, XX, xx, XX, __))); | ||
26 | } | 32 | } |
27 | 33 | ||
28 | @Test | 34 | @Test |
29 | public void byteForCellTest() { | 35 | public void byteForCellTest() { |
30 | // Create the blocks map | 36 | // Create the blocks map |
31 | HashMap<Block,BlockImage> blocksMap = new HashMap<>(); | 37 | HashMap<Block, BlockImage> blocksMap = new HashMap<>(); |
32 | 38 | ||
33 | // Fill the blocks map | 39 | // Fill the blocks map |
34 | blocksMap.put(Block.FREE, BlockImage.IRON_FLOOR); | 40 | blocksMap.put(Block.FREE, BlockImage.IRON_FLOOR); |
@@ -38,20 +44,18 @@ public class BoardPainterTest { | |||
38 | blocksMap.put(Block.BONUS_BOMB, BlockImage.BONUS_BOMB); | 44 | blocksMap.put(Block.BONUS_BOMB, BlockImage.BONUS_BOMB); |
39 | blocksMap.put(Block.BONUS_RANGE, BlockImage.BONUS_RANGE); | 45 | blocksMap.put(Block.BONUS_RANGE, BlockImage.BONUS_RANGE); |
40 | 46 | ||
41 | // Instanciates the painter | 47 | // Instantiates the painter |
42 | BoardPainter painter = new BoardPainter(blocksMap, BlockImage.IRON_FLOOR_S); | 48 | BoardPainter painter = new BoardPainter(blocksMap, BlockImage.IRON_FLOOR_S); |
43 | 49 | ||
44 | // Create a dummy board | 50 | // Create a dummy board |
45 | Board board = createBoard(); | 51 | Board board = createBoard(); |
46 | Cell freeCell = new Cell(2,1); | 52 | Cell freeCell = new Cell(2, 1); |
47 | Cell shadowedFreeCell = new Cell(1,1); | 53 | Cell shadowedFreeCell = new Cell(1, 1); |
48 | Cell walledCell = new Cell(0,0); | 54 | Cell walledCell = new Cell(0, 0); |
49 | 55 | ||
50 | Assert.assertEquals(painter.byteForCell(board, freeCell), BlockImage.IRON_FLOOR.ordinal()); | 56 | Assert.assertEquals(painter.byteForCell(board, freeCell), BlockImage.IRON_FLOOR.ordinal()); |
51 | Assert.assertEquals(painter.byteForCell(board, shadowedFreeCell), BlockImage.IRON_FLOOR_S.ordinal()); | 57 | Assert.assertEquals(painter.byteForCell(board, shadowedFreeCell), BlockImage.IRON_FLOOR_S.ordinal()); |
52 | Assert.assertEquals(painter.byteForCell(board, walledCell), BlockImage.DARK_BLOCK.ordinal()); | 58 | Assert.assertEquals(painter.byteForCell(board, walledCell), BlockImage.DARK_BLOCK.ordinal()); |
53 | |||
54 | } | 59 | } |
55 | 60 | ||
56 | |||
57 | } | 61 | } |
diff --git a/test/ch/epfl/xblast/painter/ExplosionPainterTest.java b/test/ch/epfl/xblast/painter/ExplosionPainterTest.java index 204b1ad..a6df54b 100644 --- a/test/ch/epfl/xblast/painter/ExplosionPainterTest.java +++ b/test/ch/epfl/xblast/painter/ExplosionPainterTest.java | |||
@@ -1,19 +1,21 @@ | |||
1 | package ch.epfl.xblast.painter; | 1 | package ch.epfl.xblast.painter; |
2 | 2 | ||
3 | import ch.epfl.xblast.*; | 3 | import ch.epfl.xblast.Cell; |
4 | import ch.epfl.xblast.server.*; | 4 | import ch.epfl.xblast.PlayerID; |
5 | import ch.epfl.xblast.server.painter.*; | 5 | import ch.epfl.xblast.server.Bomb; |
6 | 6 | import ch.epfl.xblast.server.painter.ExplosionPainter; | |
7 | import org.junit.Assert; | 7 | import org.junit.Assert; |
8 | import org.junit.Test; | 8 | import org.junit.Test; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * @author Timothée Floure (257420) | 11 | * @author Timothée Floure (257420) |
12 | * @author Pacien TRAN-GIRARD (261948) | ||
12 | */ | 13 | */ |
13 | public class ExplosionPainterTest { | 14 | public class ExplosionPainterTest { |
15 | |||
14 | @Test | 16 | @Test |
15 | public void byteForBombTest() { | 17 | public void byteForBombTest() { |
16 | Cell cell = new Cell(1,1); | 18 | Cell cell = new Cell(1, 1); |
17 | int range = 5; | 19 | int range = 5; |
18 | 20 | ||
19 | Bomb bomb1 = new Bomb(PlayerID.PLAYER_1, cell, 8, range); | 21 | Bomb bomb1 = new Bomb(PlayerID.PLAYER_1, cell, 8, range); |
@@ -29,9 +31,10 @@ public class ExplosionPainterTest { | |||
29 | 31 | ||
30 | @Test | 32 | @Test |
31 | public void byteForBlastTest() { | 33 | public void byteForBlastTest() { |
32 | Assert.assertEquals((byte) 15,ExplosionPainter.byteForBlast(true,true,true,true)); // NESW | 34 | Assert.assertEquals((byte) 15, ExplosionPainter.byteForBlast(true, true, true, true)); // NESW |
33 | Assert.assertEquals((byte) 0,ExplosionPainter.byteForBlast(false,false,false,false)); // nesw | 35 | Assert.assertEquals((byte) 0, ExplosionPainter.byteForBlast(false, false, false, false)); // nesw |
34 | Assert.assertEquals((byte) 13,ExplosionPainter.byteForBlast(true,true,false,true)); // NEsW | 36 | Assert.assertEquals((byte) 13, ExplosionPainter.byteForBlast(true, true, false, true)); // NEsW |
35 | Assert.assertEquals((byte) 4,ExplosionPainter.byteForBlast(false,true,false,false)); // nEsw | 37 | Assert.assertEquals((byte) 4, ExplosionPainter.byteForBlast(false, true, false, false)); // nEsw |
36 | } | 38 | } |
37 | } \ No newline at end of file | 39 | |
40 | } | ||
diff --git a/test/ch/epfl/xblast/painter/PlayerPainterTest.java b/test/ch/epfl/xblast/painter/PlayerPainterTest.java index 32b14a9..5eb20f4 100644 --- a/test/ch/epfl/xblast/painter/PlayerPainterTest.java +++ b/test/ch/epfl/xblast/painter/PlayerPainterTest.java | |||
@@ -1,22 +1,24 @@ | |||
1 | package ch.epfl.xblast.painter; | 1 | package ch.epfl.xblast.painter; |
2 | 2 | ||
3 | import ch.epfl.cs108.Sq; | 3 | import ch.epfl.cs108.Sq; |
4 | import ch.epfl.xblast.*; | 4 | import ch.epfl.xblast.Direction; |
5 | import ch.epfl.xblast.server.*; | 5 | import ch.epfl.xblast.PlayerID; |
6 | import ch.epfl.xblast.server.painter.*; | 6 | import ch.epfl.xblast.SubCell; |
7 | 7 | import ch.epfl.xblast.server.Player; | |
8 | import ch.epfl.xblast.server.painter.PlayerPainter; | ||
8 | import org.junit.Assert; | 9 | import org.junit.Assert; |
9 | import org.junit.Test; | 10 | import org.junit.Test; |
10 | 11 | ||
11 | /** | 12 | /** |
12 | * @author Timothée Floure (257420) | 13 | * @author Timothée Floure (257420) |
14 | * @author Pacien TRAN-GIRARD (261948) | ||
13 | */ | 15 | */ |
14 | public class PlayerPainterTest { | 16 | public class PlayerPainterTest { |
15 | 17 | ||
16 | private Player playerGenerator(PlayerID id,Direction direction,Player.LifeState.State state,SubCell position,int lives) { | 18 | private Player playerGenerator(PlayerID id, Direction direction, Player.LifeState.State state, SubCell position, int lives) { |
17 | Sq<Player.LifeState> lifeStates = Sq.constant(new Player.LifeState(lives, state)); | 19 | Sq<Player.LifeState> lifeStates = Sq.constant(new Player.LifeState(lives, state)); |
18 | Sq<Player.DirectedPosition> directedPositions = Player.DirectedPosition.stopped( | 20 | Sq<Player.DirectedPosition> directedPositions = Player.DirectedPosition.stopped( |
19 | new Player.DirectedPosition(position,direction) | 21 | new Player.DirectedPosition(position, direction) |
20 | ); | 22 | ); |
21 | // id, lifeStates, DirectedPositions, MaxBombs, BombRange | 23 | // id, lifeStates, DirectedPositions, MaxBombs, BombRange |
22 | return new Player(id, lifeStates, directedPositions, 1, 1); | 24 | return new Player(id, lifeStates, directedPositions, 1, 1); |
@@ -24,38 +26,39 @@ public class PlayerPainterTest { | |||
24 | 26 | ||
25 | @Test | 27 | @Test |
26 | public void byteForPlayerTest() { | 28 | public void byteForPlayerTest() { |
27 | SubCell position = new SubCell(1,1); | 29 | SubCell position = new SubCell(1, 1); |
28 | 30 | ||
29 | // Build the players | 31 | // Build the players |
30 | Player player1 = playerGenerator(PlayerID.PLAYER_1, | 32 | Player player1 = playerGenerator(PlayerID.PLAYER_1, |
31 | Direction.S, | 33 | Direction.S, |
32 | Player.LifeState.State.VULNERABLE, | 34 | Player.LifeState.State.VULNERABLE, |
33 | position, | 35 | position, |
34 | 5 //lives | 36 | 5 // lives |
35 | ); | 37 | ); |
36 | Player player2 = playerGenerator(PlayerID.PLAYER_2, | 38 | Player player2 = playerGenerator(PlayerID.PLAYER_2, |
37 | Direction.S, | 39 | Direction.S, |
38 | Player.LifeState.State.DYING, | 40 | Player.LifeState.State.DYING, |
39 | position, | 41 | position, |
40 | 1 //lives | 42 | 1 // lives |
41 | ); | 43 | ); |
42 | Player player3 = playerGenerator(PlayerID.PLAYER_3, | 44 | Player player3 = playerGenerator(PlayerID.PLAYER_3, |
43 | Direction.N, | 45 | Direction.N, |
44 | Player.LifeState.State.VULNERABLE, | 46 | Player.LifeState.State.VULNERABLE, |