Skip to content

Commit

Permalink
Merge pull request #21 from ijehyunpark/feature/card-communication
Browse files Browse the repository at this point in the history
Draft: 입력 버그 수정
  • Loading branch information
ijehyunpark authored Jun 10, 2023
2 parents 4f7bd04 + 0cae9ad commit 73b5cca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -40,7 +44,15 @@ public History runAction(Player player, Player startingPlayer, int round, List<A
// 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;
Expand Down

0 comments on commit 73b5cca

Please sign in to comment.