1 | package org.hplr.game.core.usecases.service; | |
2 | ||
3 | import lombok.RequiredArgsConstructor; | |
4 | import lombok.extern.slf4j.Slf4j; | |
5 | ||
6 | import org.hplr.game.core.enums.Status; | |
7 | import org.hplr.game.core.model.Game; | |
8 | import org.hplr.game.core.model.GameSide; | |
9 | import org.hplr.game.core.model.GameValidator; | |
10 | import org.hplr.game.core.model.vo.GameArmy; | |
11 | import org.hplr.game.core.model.vo.GameSidePlayerData; | |
12 | import org.hplr.game.core.usecases.port.dto.CreatedGameSaveSecondSideDto; | |
13 | import org.hplr.game.core.usecases.port.in.SetSecondSideUseCaseInterface; | |
14 | import org.hplr.game.core.usecases.port.out.command.SaveGameSecondSideCommandInterface; | |
15 | import org.hplr.game.core.usecases.port.out.query.SelectGameByGameIdQueryInterface; | |
16 | ||
17 | import org.hplr.user.core.model.Player; | |
18 | ||
19 | import org.hplr.user.core.usecases.port.out.query.SelectPlayerByUserIdQueryInterface; | |
20 | import org.springframework.stereotype.Service; | |
21 | ||
22 | import java.util.*; | |
23 | ||
24 | @Slf4j | |
25 | @Service | |
26 | @RequiredArgsConstructor | |
27 | public class SetSecondSideUseCaseService implements SetSecondSideUseCaseInterface { | |
28 | ||
29 | final SelectPlayerByUserIdQueryInterface selectPlayerByUserIdQueryInterface; | |
30 | final SelectGameByGameIdQueryInterface selectGameByGameIdQueryInterface; | |
31 | final SaveGameSecondSideCommandInterface saveGameSecondSideCommandInterface; | |
32 | ||
33 | @Override | |
34 | public UUID setSecondSideForGame(CreatedGameSaveSecondSideDto createdGameSaveSecondSideDto) { | |
35 | ||
36 | Game game = selectGameByGameIdQueryInterface | |
37 | .selectGameByGameId(createdGameSaveSecondSideDto.gameId()) | |
38 | .map(Game::fromDto) | |
39 |
1
1. lambda$setSecondSideForGame$0 : replaced return value with null for org/hplr/game/core/usecases/service/SetSecondSideUseCaseService::lambda$setSecondSideForGame$0 → KILLED |
.orElseThrow(() -> new NoSuchElementException("Game not found!")); |
40 | List<GameSidePlayerData> sidePlayerList = createdGameSaveSecondSideDto | |
41 | .playerDataList() | |
42 | .stream() | |
43 | .map(player -> { | |
44 | Optional<Player> dbFetchedPlayer = selectPlayerByUserIdQueryInterface | |
45 | .selectPlayerByUserId(player.playerId()) | |
46 | .map(Player::fromDto); | |
47 |
2
1. lambda$setSecondSideForGame$2 : replaced return value with null for org/hplr/game/core/usecases/service/SetSecondSideUseCaseService::lambda$setSecondSideForGame$2 → KILLED 2. lambda$setSecondSideForGame$1 : replaced return value with null for org/hplr/game/core/usecases/service/SetSecondSideUseCaseService::lambda$setSecondSideForGame$1 → KILLED |
return dbFetchedPlayer.map(value -> new GameSidePlayerData( |
48 | value, | |
49 | GameArmy.fromDto( | |
50 | player.primaryArmy() | |
51 | ), | |
52 | player.allyArmyList().stream().map(GameArmy::fromDto).toList() | |
53 | )).orElse(null); | |
54 | }).toList().stream().filter(Objects::nonNull).toList(); | |
55 | GameSide secondGameSide = GameSide.fromDto(createdGameSaveSecondSideDto.allegiance(), sidePlayerList, game.getGameData().gameTurnLength()); | |
56 |
1
1. setSecondSideForGame : removed call to org/hplr/game/core/model/Game::setSecondGameSide → KILLED |
game.setSecondGameSide(secondGameSide); |
57 |
1
1. setSecondSideForGame : removed call to org/hplr/game/core/model/GameValidator::validateSecondSide → KILLED |
GameValidator.validateSecondSide(game); |
58 |
1
1. setSecondSideForGame : removed call to org/hplr/game/core/model/Game::setGameStatus → KILLED |
game.setGameStatus(Status.AWAITING); |
59 |
1
1. setSecondSideForGame : removed call to org/hplr/game/core/usecases/port/out/command/SaveGameSecondSideCommandInterface::saveGameSecondSide → KILLED |
saveGameSecondSideCommandInterface.saveGameSecondSide(game.toSnapshot()); |
60 |
1
1. setSecondSideForGame : replaced return value with null for org/hplr/game/core/usecases/service/SetSecondSideUseCaseService::setSecondSideForGame → KILLED |
return secondGameSide.getSideId().sideId(); |
61 | } | |
62 | ||
63 | ||
64 | } | |
Mutations | ||
39 |
1.1 |
|
47 |
1.1 2.2 |
|
56 |
1.1 |
|
57 |
1.1 |
|
58 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |