1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package ch.epfl.xblast.client;
import ch.epfl.xblast.Lists;
import ch.epfl.xblast.PlayerID;
import ch.epfl.xblast.SubCell;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
/**
* @author Timothée FLOURE (257420)
*/
public class PlayerTest {
private static final GameState.Player PLAYER_1 = new GameState.Player(PlayerID.PLAYER_1, 5, new SubCell(1,50), null);
private static final GameState.Player PLAYER_2 = new GameState.Player(PlayerID.PLAYER_2, 5, new SubCell(20,20), null);
private static final GameState.Player PLAYER_3 = new GameState.Player(PlayerID.PLAYER_3, 5, new SubCell(20,20), null);
private static final GameState.Player PLAYER_4 = new GameState.Player(PlayerID.PLAYER_4, 5, new SubCell(30,10), null);
private static final PlayerID CURRENT_PLAYER = PlayerID.PLAYER_3;
@Test
public void clientPlayerOder() {
List<GameState.Player> players = Arrays.asList(PLAYER_1,PLAYER_2,PLAYER_3,PLAYER_4);
List<GameState.Player> expectedOrder = Arrays.asList(PLAYER_4,PLAYER_2,PLAYER_3,PLAYER_1);
// Order the players
List<GameState.Player> computedOrder = Lists.sorted(
players,
GameState.Player
.POSITION_COMPARATOR
.thenComparing(GameState.Player.idPushingComparator(CURRENT_PLAYER)));
// Assert
Assert.assertEquals(expectedOrder,computedOrder);
}
}
|