From 3cd6084bdf0baed8fa395e04343e69cedb2e3db5 Mon Sep 17 00:00:00 2001 From: luiso Date: Sat, 10 Jun 2023 17:00:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GamePlay/domain/action/implement/Action29.java | 14 +++++++++++++- .../GamePlay/domain/action/implement/Action4.java | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action29.java b/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action29.java index 8f1c613..9efc1f9 100644 --- a/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action29.java +++ b/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action29.java @@ -1,5 +1,7 @@ package com.semoss.agricola.GamePlay.domain.action.implement; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.semoss.agricola.GamePlay.domain.History; import com.semoss.agricola.GamePlay.domain.action.DoType; import com.semoss.agricola.GamePlay.domain.action.component.PlaceAction; @@ -10,6 +12,8 @@ import com.semoss.agricola.GamePlay.domain.resource.ResourceStructInterface; import com.semoss.agricola.GamePlay.domain.resource.ResourceType; import com.semoss.agricola.GamePlay.dto.AgricolaActionRequest; +import com.semoss.agricola.GamePlay.exception.IllegalRequestException; +import com.semoss.agricola.util.ObjectMapperSingleton; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -41,7 +45,15 @@ public History runAction(Player player, Player startingPlayer, int round, List< // TODO: Memento로 실패 시 롤백 PlaceAction placeAction = (PlaceAction) getActions().get(0); - Long cardId = (Long) acts.get(0).getActs(); + Long cardId; + try { + AgricolaActionRequest.ActionFormat actionFormat = acts.get(0); + ObjectMapper objectMapper = ObjectMapperSingleton.getInstance(); + String jsonString = objectMapper.writeValueAsString(actionFormat.getActs()); + cardId = objectMapper.readValue(jsonString, Long.class); + } catch (JsonProcessingException e){ + throw new IllegalRequestException("요청 필드 오류"); + } // 플레이어가 내려놓은 직업 카드 계산 int occupationCount = 0; diff --git a/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action4.java b/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action4.java index 89be18c..0ccb563 100644 --- a/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action4.java +++ b/src/main/java/com/semoss/agricola/GamePlay/domain/action/implement/Action4.java @@ -1,5 +1,7 @@ package com.semoss.agricola.GamePlay.domain.action.implement; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.semoss.agricola.GamePlay.domain.History; import com.semoss.agricola.GamePlay.domain.action.DoType; import com.semoss.agricola.GamePlay.domain.action.component.PlaceAction; @@ -10,6 +12,8 @@ import com.semoss.agricola.GamePlay.domain.resource.ResourceStructInterface; import com.semoss.agricola.GamePlay.domain.resource.ResourceType; import com.semoss.agricola.GamePlay.dto.AgricolaActionRequest; +import com.semoss.agricola.GamePlay.exception.IllegalRequestException; +import com.semoss.agricola.util.ObjectMapperSingleton; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -40,7 +44,15 @@ public History runAction(Player player, Player startingPlayer, int round, List Date: Sat, 10 Jun 2023 22:31:06 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EB=9D=BC=EC=9A=B4=EB=93=9C=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/semoss/agricola/GamePlay/domain/AgricolaGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/semoss/agricola/GamePlay/domain/AgricolaGame.java b/src/main/java/com/semoss/agricola/GamePlay/domain/AgricolaGame.java index 7a2027b..80c986b 100644 --- a/src/main/java/com/semoss/agricola/GamePlay/domain/AgricolaGame.java +++ b/src/main/java/com/semoss/agricola/GamePlay/domain/AgricolaGame.java @@ -46,7 +46,7 @@ public class AgricolaGame implements Game { @Getter public static class GameState { - private int round = -1; + private int round = 0; private GameProgress gameProgress; @JsonProperty("playerId") @JsonIdentityReference(alwaysAsId = true)