From f3866e8b99b2bc8956763f9bd7884d7e5311aaf0 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Mon, 2 Jan 2017 19:09:52 +0100 Subject: Code cleaning --- src/main/java/org/luxons/sevenwonders/game/Player.java | 8 ++------ .../game/data/serializers/NumericEffectSerializer.java | 4 ++-- .../luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java | 2 +- .../org/luxons/sevenwonders/game/effects/ProductionIncrease.java | 1 + .../org/luxons/sevenwonders/repositories/PlayerRepository.java | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/luxons/sevenwonders/game/Player.java b/src/main/java/org/luxons/sevenwonders/game/Player.java index 3e25cb80..c8c1509c 100644 --- a/src/main/java/org/luxons/sevenwonders/game/Player.java +++ b/src/main/java/org/luxons/sevenwonders/game/Player.java @@ -14,13 +14,9 @@ public class Player { private transient Game game; - public Player(String userName) { + public Player(String userName, String displayName) { this.userName = userName; - } - - public Player(String displayName, String userName) { - this(userName); - setDisplayName(displayName); + this.displayName = displayName; } public String getUserName() { diff --git a/src/main/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializer.java b/src/main/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializer.java index 8f50db29..c1a51f24 100644 --- a/src/main/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializer.java +++ b/src/main/java/org/luxons/sevenwonders/game/data/serializers/NumericEffectSerializer.java @@ -19,7 +19,7 @@ public class NumericEffectSerializer implements JsonSerializer, JsonDese @Override public JsonElement serialize(Effect effect, Type typeOfSrc, JsonSerializationContext context) { - int value = 0; + int value; if (MilitaryReinforcements.class.equals(typeOfSrc)) { value = ((MilitaryReinforcements)effect).getCount(); } else if (GoldIncrease.class.equals(typeOfSrc)) { @@ -27,7 +27,7 @@ public class NumericEffectSerializer implements JsonSerializer, JsonDese } else if (RawPointsIncrease.class.equals(typeOfSrc)) { value = ((RawPointsIncrease)effect).getPoints(); } else { - throw new IllegalArgumentException("Unknown numeric effet " + typeOfSrc.getTypeName()); + throw new IllegalArgumentException("Unknown numeric effect " + typeOfSrc.getTypeName()); } return new JsonPrimitive(value); } diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java b/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java index 79216c93..8f4340cf 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/InstantOwnBoardEffect.java @@ -10,7 +10,7 @@ public abstract class InstantOwnBoardEffect implements Effect { apply(table.getBoard(playerIndex)); } - public abstract void apply(Board board); + protected abstract void apply(Board board); @Override public int computePoints(Table table, int playerIndex) { diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java b/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java index ff2a59c7..9724dfcd 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/ProductionIncrease.java @@ -17,6 +17,7 @@ public class ProductionIncrease extends InstantOwnBoardEffect { this.production = production; } + @Override public void apply(Board board) { board.getProduction().addAll(production); } diff --git a/src/main/java/org/luxons/sevenwonders/repositories/PlayerRepository.java b/src/main/java/org/luxons/sevenwonders/repositories/PlayerRepository.java index e671088f..cd63c440 100644 --- a/src/main/java/org/luxons/sevenwonders/repositories/PlayerRepository.java +++ b/src/main/java/org/luxons/sevenwonders/repositories/PlayerRepository.java @@ -21,7 +21,7 @@ public class PlayerRepository { } private Player createPlayer(String userName, String displayName) { - Player player = new Player(displayName, userName); + Player player = new Player(userName, displayName); add(player); return player; } -- cgit