From b21b0b854de124776d547c9cb2d42443396833f9 Mon Sep 17 00:00:00 2001 From: jbion Date: Tue, 20 Dec 2016 22:47:25 +0100 Subject: Add test for ScienceProgressSerializer --- .../org/luxons/sevenwonders/game/boards/Science.java | 2 +- .../data/serializers/ScienceProgressSerializer.java | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Science.java b/src/main/java/org/luxons/sevenwonders/game/boards/Science.java index f3d6a681..71687657 100644 --- a/src/main/java/org/luxons/sevenwonders/game/boards/Science.java +++ b/src/main/java/org/luxons/sevenwonders/game/boards/Science.java @@ -32,7 +32,7 @@ public class Science { } public int size() { - return quantities.size() + jokers; + return quantities.values().stream().mapToInt(q -> q).sum() + jokers; } public int computePoints() { diff --git a/src/main/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.java b/src/main/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.java index 0535b90a..b6e38540 100644 --- a/src/main/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.java +++ b/src/main/java/org/luxons/sevenwonders/game/data/serializers/ScienceProgressSerializer.java @@ -2,6 +2,10 @@ package org.luxons.sevenwonders.game.data.serializers; import java.lang.reflect.Type; +import org.luxons.sevenwonders.game.boards.Science; +import org.luxons.sevenwonders.game.boards.ScienceType; +import org.luxons.sevenwonders.game.effects.ScienceProgress; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -10,9 +14,6 @@ import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import org.luxons.sevenwonders.game.boards.Science; -import org.luxons.sevenwonders.game.boards.ScienceType; -import org.luxons.sevenwonders.game.effects.ScienceProgress; public class ScienceProgressSerializer implements JsonSerializer, JsonDeserializer { @@ -47,9 +48,17 @@ public class ScienceProgressSerializer implements JsonSerializer