From 085610b35b7e85cfbec43a1ceb7c38a4b15fe3c2 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Sun, 8 May 2016 14:33:25 +0200 Subject: Minor changes to the comments and variables --- src/ch/epfl/xblast/client/GameStateDeserializer.java | 11 +++++++---- src/ch/epfl/xblast/client/ImageCollection.java | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/client/GameStateDeserializer.java b/src/ch/epfl/xblast/client/GameStateDeserializer.java index 1fb1c61..f1327e3 100644 --- a/src/ch/epfl/xblast/client/GameStateDeserializer.java +++ b/src/ch/epfl/xblast/client/GameStateDeserializer.java @@ -32,7 +32,7 @@ public final class GameStateDeserializer { private final static int PLAYER_TOTAL_SIZE = NUMBER_OF_PLAYERS * PLAYER_CHUNK_SIZE; /** - * Various + * Scores & Time */ private final static int TIME_LINE_SIZE = (Ticks.GAME_DURATION / 2); private final static int SCORE_SEPARATION_SIZE = 8; @@ -68,7 +68,7 @@ public final class GameStateDeserializer { private static List deserializePlayers(List serializedPlayers) { List players = new ArrayList<>(); - for (int i = 0; i < NUMBER_OF_PLAYERS; i++) { + for (int i = 0; i < NUMBER_OF_PLAYERS; i++) { // ugly players.add( deserializePlayer( serializedPlayers.subList(i * PLAYER_CHUNK_SIZE, (i+1) * PLAYER_CHUNK_SIZE), i @@ -87,11 +87,14 @@ public final class GameStateDeserializer { */ private static Player deserializePlayer(List serializedPlayer, int i) { PlayerID id = PlayerID.values()[i]; + int lives = Byte.toUnsignedInt(serializedPlayer.get(0)); + SubCell position = new SubCell( Byte.toUnsignedInt(serializedPlayer.get(1)), Byte.toUnsignedInt(serializedPlayer.get(2)) ); + Image image = (new ImageCollection(PLAYER_IMAGES_FOLDER)).imageOrNull(Byte.toUnsignedInt(serializedPlayer.get(3))); return new Player(id, lives, position, image); @@ -164,9 +167,9 @@ public final class GameStateDeserializer { * @param serializedData the serialized gameState * @return a new GameState build from the serialized data. */ - public static GameState deserialize(List serializedData) { + public static GameState deserialize(List serializedData) { // Ugly - // Build the indexes + // Build the indexes (Ugly) int boardBeginIndex = 0; // First element int boardEndIndex = (boardBeginIndex) + Byte.toUnsignedInt(serializedData.get(boardBeginIndex)); int explosionsBeginIndex = boardEndIndex + 1; diff --git a/src/ch/epfl/xblast/client/ImageCollection.java b/src/ch/epfl/xblast/client/ImageCollection.java index 4f54f3b..ee0e8cf 100644 --- a/src/ch/epfl/xblast/client/ImageCollection.java +++ b/src/ch/epfl/xblast/client/ImageCollection.java @@ -14,8 +14,8 @@ public final class ImageCollection { /** * Bounds of the file ID in the filename. */ - private final int FILENAME_ID_BEGIN_INDEX = 0; - private final int FILENAME_ID_END_INDEX = 2; + private static final int FILENAME_ID_BEGIN_INDEX = 0; + private static final int FILENAME_ID_END_INDEX = 2; /** * Directory related to the ImageCollection. -- cgit v1.2.3