Skip to content

Commit

Permalink
#53 style: GameServiceImpl style 컨벤션에 맞게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwp031 committed Oct 10, 2023
1 parent 819939e commit c18c24a
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public class GameServiceImpl implements GameService {
private final GameRepository gameRepository;
private final ItemRepository itemRepository;
private final ItemService itemService;

@Override
public Game createGame(Long userAccountId, Long worldcupId, Long initialRound, PickType pickType) {
UserAccount userAccount = userAccountRepository.getReferenceById(userAccountId);
Worldcup worldcup = worldcupRepository.findById(worldcupId)
.orElseThrow(() -> new IllegalArgumentException("월드컵 아이디가 잘못됐습니다."));

RoundType initialRoundType = RoundType.getRoundType(initialRound);
Game game = Game.builder()
Game game = Game.builder()
.worldcup(worldcup)
.player(userAccount)
.gameType(GameType.TOURNAMENT)
Expand Down Expand Up @@ -71,7 +72,7 @@ public List<Round> initializeRounds(Worldcup worldcup, Game game, Long roundType
List<Item> items = worldcup.getItems();
List<Integer> pickForm = pickType.getPickOrder(roundType);
List<Round> initialRounds = new ArrayList<>();
for (int i = 0; i < pickForm.size(); i+=2) {
for (int i = 0; i < pickForm.size(); i += 2) {
Round round = Round.builder()
.worldcup(worldcup)
.game(game)
Expand All @@ -90,7 +91,7 @@ public Long getCurrentRoundOrderOnCurrentStage(Game game) {
AtomicReference<Long> roundSum = new AtomicReference<>((long) 0);
Arrays.stream(RoundType.values()).forEach(
r -> {
if (r.getStageOrder()>= game.getInitialRoundType().getStageOrder() && r.getStageOrder() < game.getCurrentRoundType().getStageOrder()) {
if (r.getStageOrder() >= game.getInitialRoundType().getStageOrder() && r.getStageOrder() < game.getCurrentRoundType().getStageOrder()) {
roundSum.updateAndGet(v -> v + r.getTotalRounds());
}
}
Expand Down Expand Up @@ -140,14 +141,14 @@ public Long getSimilarScore(Game source, Game target) {
long[] stageSplitIndexes = null;
long[] stagePoint = null;
if (source.getInitialRoundType().equals(RoundType.ROUND16)) {
stageSplitIndexes = new long[]{7,11,13,14};
stagePoint = new long[]{1,2,3,4};
stageSplitIndexes = new long[]{7, 11, 13, 14};
stagePoint = new long[]{1, 2, 3, 4};
} else if (source.getInitialRoundType().equals(RoundType.ROUND8)) {
stageSplitIndexes = new long[]{4, 6, 7};
stagePoint = new long[]{1,2,3};
stagePoint = new long[]{1, 2, 3};
} else if (source.getInitialRoundType().equals(RoundType.ROUND4)) {
stageSplitIndexes = new long[]{2, 3};
stagePoint = new long[]{1,2};
stagePoint = new long[]{1, 2};
} else {
throw new RuntimeException("16강 이후의 케이스는 아직 구현하지 않았습니다.");
}
Expand All @@ -160,7 +161,7 @@ public Long getSimilarScore(Game source, Game target) {
while (currentStageSplitIndex < stageSplitIndexes.length) {
List<Long> sourceSelectedItem = new ArrayList<>();
List<Long> targetSelectedItem = new ArrayList<>();
while (index<stageSplitIndexes[currentStageSplitIndex]) {
while (index < stageSplitIndexes[currentStageSplitIndex]) {
sourceSelectedItem.add(sourceRounds.get(index).getSelectedItem());
targetSelectedItem.add(targetRounds.get(index).getSelectedItem());
index += 1;
Expand Down

0 comments on commit c18c24a

Please sign in to comment.