mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-01-30 10:40:13 +08:00
Use LinkedHashSets for players and obstacles to preserve order
This commit is contained in:
parent
a14608fb74
commit
bd7b8917a4
@ -5,6 +5,7 @@ package org.libertybikes.game.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -24,8 +25,8 @@ public class GameBoard {
|
||||
public final short[][] board = new short[BOARD_SIZE][BOARD_SIZE];
|
||||
|
||||
public final Set<Obstacle> obstacles = new HashSet<>();
|
||||
public final Set<MovingObstacle> movingObstacles = new HashSet<>();
|
||||
public final Set<Player> players = new HashSet<>();
|
||||
public final Set<MovingObstacle> movingObstacles = new LinkedHashSet<>();
|
||||
public final Set<Player> players = new LinkedHashSet<>();
|
||||
private final boolean[] takenPlayerSlots = new boolean[Player.MAX_PLAYERS];
|
||||
private GameMap gameMap;
|
||||
|
||||
|
@ -7,6 +7,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.json.bind.Jsonb;
|
||||
@ -98,7 +99,7 @@ public class JsonDataTest {
|
||||
|
||||
@Test
|
||||
public void testPlayerList() {
|
||||
Set<Player> players = new HashSet<>();
|
||||
Set<Player> players = new LinkedHashSet<>();
|
||||
players.add(new Player("123", "Bob", (short) 0, 9, 9));
|
||||
PlayerList list = new OutboundMessage.PlayerList(players);
|
||||
String bob = "{\"id\":\"123\",\"name\":\"Bob\",\"color\":\"#DF740C\",\"status\":\"Connected\",\"alive\":true,\"x\":9,\"y\":9,\"width\":3,\"height\":3,\"oldX\":9,\"oldY\":9,\"trailPosX\":10,\"trailPosY\":10,\"trailPosX2\":10,\"trailPosY2\":10}";
|
||||
|
Loading…
Reference in New Issue
Block a user