diff options
15 files changed, 33 insertions, 53 deletions
diff --git a/backend/build.gradle b/backend/build.gradle index d0a48095..e4055aa5 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -18,8 +18,8 @@ repositories { dependencies { compile 'com.google.code.gson:gson:2.8.0' compile 'ch.qos.logback:logback-classic:1.1.8' - compile 'org.hildan.livedoc:livedoc-springboot:1.2.0' - compile 'org.hildan.livedoc:livedoc-ui-webjar:1.2.0' + compile 'org.hildan.livedoc:livedoc-springboot:2.0.0' + compile 'org.hildan.livedoc:livedoc-ui-webjar:2.0.0' compile 'org.springframework.boot:spring-boot-starter-websocket' compile 'org.springframework.security:spring-security-core:4.2.0.RELEASE' diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java index f81ae09c..6609d2ad 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/ChooseNameAction.java @@ -4,15 +4,15 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; +import org.hildan.livedoc.core.annotations.ApiObjectProperty; @ApiObject(name = "Choose Name Action", - description = "The action to choose the player's name. This is the first action that should be called.", - group = "Actions") + description = "The action to choose the player's name. This is the first action that should be called.", + group = "Actions") public class ChooseNameAction { - @ApiObjectField(description = "The display name of the player. May contain spaces and special characters.", - required = true) + @ApiObjectProperty(description = "The display name of the player. May contain spaces and special characters.", + required = true) @NotNull @Size(min = 2, max = 20) private String playerName; diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java index dc4113f0..c0b72c38 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/CreateGameAction.java @@ -4,14 +4,10 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; -@ApiObject(name = "Create Game Action", - description = "The action to create a game.", - group = "Actions") +@ApiObject(name = "Create Game Action", description = "The action to create a game.", group = "Actions") public class CreateGameAction { - @ApiObjectField @NotNull @Size(min = 2, max = 30) private String gameName; diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java index ef0161b7..acb63772 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/JoinGameAction.java @@ -3,14 +3,10 @@ package org.luxons.sevenwonders.actions; import javax.validation.constraints.NotNull; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; -@ApiObject(name = "Join Game Action", - description = "The action to join a game.", - group = "Actions") +@ApiObject(name = "Join Game Action", description = "The action to join a game.", group = "Actions") public class JoinGameAction { - @ApiObjectField @NotNull private Long gameId; diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java index bc3e6821..d1f82267 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java @@ -3,15 +3,12 @@ package org.luxons.sevenwonders.actions; import javax.validation.constraints.NotNull; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; import org.luxons.sevenwonders.game.api.PlayerMove; -@ApiObject(name = "Prepare Move Action", - description = "The action to prepare the next move during a game.", - group = "Actions") +@ApiObject(name = "Prepare Move Action", description = "The action to prepare the next move during a game.", + group = "Actions") public class PrepareMoveAction { - @ApiObjectField @NotNull private PlayerMove move; diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java index 705d768c..d0a6d7fd 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/ReorderPlayersAction.java @@ -1,19 +1,15 @@ package org.luxons.sevenwonders.actions; import java.util.List; - import javax.validation.constraints.NotNull; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; @ApiObject(name = "Reorder Players Action", - description = "The action to update the order of the players around the table. Can only be called in the " - + "lobby by the owner of the game.", - group = "Actions") + description = "The action to update the order of the players around the table. Can only be called in the " + + "lobby by the owner of the game.", group = "Actions") public class ReorderPlayersAction { - @ApiObjectField @NotNull private List<String> orderedPlayers; diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java index 8806ced0..5dbfdc9e 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java +++ b/backend/src/main/java/org/luxons/sevenwonders/actions/UpdateSettingsAction.java @@ -3,16 +3,13 @@ package org.luxons.sevenwonders.actions; import javax.validation.constraints.NotNull; import org.hildan.livedoc.core.annotations.ApiObject; -import org.hildan.livedoc.core.annotations.ApiObjectField; import org.luxons.sevenwonders.game.api.CustomizableSettings; @ApiObject(name = "Update Settings Action", - description = "The action to update the settings of the game. Can only be called in the lobby by the owner" - + " of the game.", - group = "Actions") + description = "The action to update the settings of the game. Can only be called in the lobby by the owner" + + " of the game.", group = "Actions") public class UpdateSettingsAction { - @ApiObjectField @NotNull private CustomizableSettings settings; diff --git a/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java b/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java index 560c5571..9826a0ba 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java +++ b/backend/src/main/java/org/luxons/sevenwonders/doc/GlobalDocumentation.java @@ -3,8 +3,5 @@ package org.luxons.sevenwonders.doc; import org.hildan.livedoc.core.annotations.global.ApiGlobal; import org.hildan.livedoc.core.annotations.global.ApiGlobalSection; -@ApiGlobal(sections = { - @ApiGlobalSection(title = "First steps", paragraphs = {"Welcome to JsonDoc."}) -}) -public class GlobalDocumentation { -} +@ApiGlobal(sections = {@ApiGlobalSection(title = "First steps", paragraphs = {"Welcome to JsonDoc."})}) +public class GlobalDocumentation {} diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/api/HandCard.java b/backend/src/main/java/org/luxons/sevenwonders/game/api/HandCard.java index c6464da8..a97679c2 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/api/HandCard.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/api/HandCard.java @@ -4,8 +4,8 @@ import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.cards.Card; /** - * A card with contextual information relative to the hand it is sitting in. The extra information is especially - * useful because it frees the client from a painful business logic implementation. + * A card with contextual information relative to the hand it is sitting in. The extra information is especially useful + * because it frees the client from a painful business logic implementation. */ public class HandCard { diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java b/backend/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java index 6d464388..f0da6d63 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java @@ -71,8 +71,7 @@ public class GameDefinitionLoader { } private static Gson createGson() { - Type resourceTypeList = new TypeToken<List<ResourceType>>() { - }.getType(); + Type resourceTypeList = new TypeToken<List<ResourceType>>() {}.getType(); return new GsonBuilder().disableHtmlEscaping() .registerTypeAdapter(Resources.class, new ResourcesSerializer()) .registerTypeAdapter(ResourceType.class, new ResourceTypeSerializer()) diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ProductionSerializer.java b/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ProductionSerializer.java index 5c833ff8..178134bb 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ProductionSerializer.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ProductionSerializer.java @@ -4,6 +4,10 @@ import java.lang.reflect.Type; import java.util.Set; import java.util.stream.Collectors; +import org.luxons.sevenwonders.game.resources.Production; +import org.luxons.sevenwonders.game.resources.ResourceType; +import org.luxons.sevenwonders.game.resources.Resources; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -11,9 +15,6 @@ import com.google.gson.JsonNull; import com.google.gson.JsonParseException; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import org.luxons.sevenwonders.game.resources.Production; -import org.luxons.sevenwonders.game.resources.ResourceType; -import org.luxons.sevenwonders.game.resources.Resources; public class ProductionSerializer implements JsonSerializer<Production>, JsonDeserializer<Production> { diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.java b/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.java index 2786143b..9c27b2a1 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/data/serializers/ResourcesSerializer.java @@ -3,6 +3,9 @@ package org.luxons.sevenwonders.game.data.serializers; import java.lang.reflect.Type; import java.util.stream.Collectors; +import org.luxons.sevenwonders.game.resources.ResourceType; +import org.luxons.sevenwonders.game.resources.Resources; + import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -11,8 +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.resources.ResourceType; -import org.luxons.sevenwonders.game.resources.Resources; public class ResourcesSerializer implements JsonSerializer<Resources>, JsonDeserializer<Resources> { @@ -27,8 +28,8 @@ public class ResourcesSerializer implements JsonSerializer<Resources>, JsonDeser } @Override - public Resources deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { + public Resources deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { String s = json.getAsString(); Resources resources = new Resources(); for (char c : s.toCharArray()) { diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/moves/PlayFreeCardMove.java b/backend/src/main/java/org/luxons/sevenwonders/game/moves/PlayFreeCardMove.java index 35f38ce2..4e8eefa5 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/moves/PlayFreeCardMove.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/moves/PlayFreeCardMove.java @@ -20,8 +20,7 @@ public class PlayFreeCardMove extends CardFromHandMove { Board board = table.getBoard(getPlayerIndex()); if (!board.canPlayFreeCard(table.getCurrentAge())) { throw new InvalidMoveException( - String.format("Player %d cannot play the card %s for free", getPlayerIndex(), - getCard().getName())); + String.format("Player %d cannot play the card %s for free", getPlayerIndex(), getCard().getName())); } } diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/resources/Production.java b/backend/src/main/java/org/luxons/sevenwonders/game/resources/Production.java index f2f7b840..7fa83e51 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/game/resources/Production.java +++ b/backend/src/main/java/org/luxons/sevenwonders/game/resources/Production.java @@ -82,7 +82,7 @@ public class Production { } private static Set<ResourceType> findFirstAlternativeContaining(Set<Set<ResourceType>> alternatives, - ResourceType type) { + ResourceType type) { return alternatives.stream().filter(a -> a.contains(type)).findAny().orElse(null); } diff --git a/backend/src/main/java/org/luxons/sevenwonders/lobby/Player.java b/backend/src/main/java/org/luxons/sevenwonders/lobby/Player.java index 6143dfb5..496e1e67 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/lobby/Player.java +++ b/backend/src/main/java/org/luxons/sevenwonders/lobby/Player.java @@ -1,8 +1,9 @@ package org.luxons.sevenwonders.lobby; -import com.fasterxml.jackson.annotation.JsonIgnore; import org.luxons.sevenwonders.game.Game; +import com.fasterxml.jackson.annotation.JsonIgnore; + public class Player { private final String username; |