From bf1b4bce65ce4b538df8ddd7ec22214463813eb6 Mon Sep 17 00:00:00 2001 From: waterricecake Date: Wed, 7 Aug 2024 11:37:30 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=95=84=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/application/GameService.java | 2 +- .../mafia/mafiatogether/game/domain/Game.java | 18 +++++++++--------- .../game/domain/PlayerCollection.java | 12 ++++++------ .../mafiatogether/game/ui/GameController.java | 2 +- .../mafiatogether/job/domain/jobtype/Job.java | 2 -- .../application/GameEventListenerTest.java | 5 ++--- .../mafiatogether/job/domain/PoliceTest.java | 1 - 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/main/java/mafia/mafiatogether/game/application/GameService.java b/src/main/java/mafia/mafiatogether/game/application/GameService.java index e8406ade..1cdb4af8 100644 --- a/src/main/java/mafia/mafiatogether/game/application/GameService.java +++ b/src/main/java/mafia/mafiatogether/game/application/GameService.java @@ -45,7 +45,7 @@ private StatusType checkStatusChanged(final Game game) { return statusType; } - public void modifyStatus(final String code, final RoomModifyRequest request) { + public void modifyStatus(final String code) { final Room room = roomRepository.findById(code) .orElseThrow(() -> new RoomException(ExceptionCode.INVALID_NOT_FOUND_ROOM_CODE)); Game game = Game.create(room, Clock.systemDefaultZone().millis()); diff --git a/src/main/java/mafia/mafiatogether/game/domain/Game.java b/src/main/java/mafia/mafiatogether/game/domain/Game.java index 38be03d5..8d4534cd 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/Game.java +++ b/src/main/java/mafia/mafiatogether/game/domain/Game.java @@ -6,9 +6,9 @@ import lombok.Getter; import mafia.mafiatogether.game.application.dto.event.ClearJobTargetEvent; import mafia.mafiatogether.game.application.dto.event.ClearVoteEvent; -import mafia.mafiatogether.game.application.dto.event.StartGameEvent; import mafia.mafiatogether.game.application.dto.event.DeleteGameEvent; import mafia.mafiatogether.game.application.dto.event.JobExecuteEvent; +import mafia.mafiatogether.game.application.dto.event.StartGameEvent; import mafia.mafiatogether.game.application.dto.event.VoteExecuteEvent; import mafia.mafiatogether.game.domain.status.DayIntroStatus; import mafia.mafiatogether.game.domain.status.Status; @@ -43,12 +43,12 @@ public static Game create(final Room room, final Long now) { status, room.getRoomInfo(), room.getMaster().getName(), - PlayerCollection.creat(room.getParticipants()), + PlayerCollection.create(room.getParticipants()), status ); } - public Game(){ + public Game() { this.players = new PlayerCollection(); } @@ -100,7 +100,7 @@ public List getWinners() { } public List getLosers() { - if (players.getWinnerJobType().equals(JobType.MAFIA)){ + if (players.getWinnerJobType().equals(JobType.MAFIA)) { return players.getNotMafias(); } return players.getMafias(); @@ -110,7 +110,7 @@ public String getWinnerJob() { return players.getWinnerJobType().name(); } - public void publishVoteExecuteEvent(){ + public void publishVoteExecuteEvent() { registerEvent(new VoteExecuteEvent(this.code)); } @@ -118,7 +118,7 @@ public void executeTarget(String target) { players.executeTarget(target); } - public void publicClearVoteEvent(){ + public void publicClearVoteEvent() { registerEvent(new ClearVoteEvent(this.code)); } @@ -130,7 +130,7 @@ public void publishClearJobTargetEvent() { registerEvent(new ClearJobTargetEvent(this.code)); } - public void publishDeleteGameEvent(){ + public void publishDeleteGameEvent() { registerEvent(new DeleteGameEvent(this.code)); } @@ -138,11 +138,11 @@ public void skipStatus(final Long now) { status = status.getNextStatus(this, now); } - public void setStatsSnapshot(){ + public void setStatsSnapshot() { this.statusSnapshot = status; } - public boolean isStatusChanged(){ + public boolean isStatusChanged() { return !statusSnapshot.getType().equals(status.getType()); } } diff --git a/src/main/java/mafia/mafiatogether/game/domain/PlayerCollection.java b/src/main/java/mafia/mafiatogether/game/domain/PlayerCollection.java index ee77a698..92120ba4 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/PlayerCollection.java +++ b/src/main/java/mafia/mafiatogether/game/domain/PlayerCollection.java @@ -20,7 +20,7 @@ public PlayerCollection() { this.players = new ArrayList<>(); } - public static PlayerCollection creat(ParticipantCollection participants) { + public static PlayerCollection create(ParticipantCollection participants) { final PlayerCollection playerCollection = new PlayerCollection(); for (Participant participant : participants.getParticipants()) { playerCollection.getPlayers().add(Player.create(participant.getName())); @@ -59,27 +59,27 @@ public Long getAlivePlayerCount() { .count(); } - public JobType getWinnerJobType(){ - if (getAliveMafiaCount() == 0){ + public JobType getWinnerJobType() { + if (getAliveMafiaCount() == 0) { return JobType.CITIZEN; } return JobType.MAFIA; } - public List getMafias(){ + public List getMafias() { return players.stream() .filter(player -> player.isMafia()) .toList(); } - public List getNotMafias(){ + public List getNotMafias() { return players.stream() .filter(player -> !player.isMafia()) .toList(); } public void executeTarget(final String target) { - if (target == null || target.isBlank()){ + if (target == null || target.isBlank()) { return; } final Player targetPlayer = findByName(target); diff --git a/src/main/java/mafia/mafiatogether/game/ui/GameController.java b/src/main/java/mafia/mafiatogether/game/ui/GameController.java index c64f02d4..0abb85fe 100644 --- a/src/main/java/mafia/mafiatogether/game/ui/GameController.java +++ b/src/main/java/mafia/mafiatogether/game/ui/GameController.java @@ -32,7 +32,7 @@ public ResponseEntity modifyStatus( @PlayerInfo final PlayerInfoDto playerInfoDto, @RequestBody final RoomModifyRequest request ) { - gameService.modifyStatus(playerInfoDto.code(), request); + gameService.modifyStatus(playerInfoDto.code()); return ResponseEntity.ok().build(); } diff --git a/src/main/java/mafia/mafiatogether/job/domain/jobtype/Job.java b/src/main/java/mafia/mafiatogether/job/domain/jobtype/Job.java index 89f97351..7a8c9297 100644 --- a/src/main/java/mafia/mafiatogether/job/domain/jobtype/Job.java +++ b/src/main/java/mafia/mafiatogether/job/domain/jobtype/Job.java @@ -1,9 +1,7 @@ package mafia.mafiatogether.job.domain.jobtype; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import java.util.List; import java.util.Map; -import mafia.mafiatogether.job.domain.PlayerJob; @JsonIgnoreProperties(ignoreUnknown = true) public interface Job { diff --git a/src/test/java/mafia/mafiatogether/game/application/GameEventListenerTest.java b/src/test/java/mafia/mafiatogether/game/application/GameEventListenerTest.java index 9f4990e8..f55905f6 100644 --- a/src/test/java/mafia/mafiatogether/game/application/GameEventListenerTest.java +++ b/src/test/java/mafia/mafiatogether/game/application/GameEventListenerTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.SoftAssertions.assertSoftly; import java.time.Clock; -import java.util.List; import mafia.mafiatogether.chat.domain.ChatRepository; import mafia.mafiatogether.game.domain.Game; import mafia.mafiatogether.game.domain.GameRepository; @@ -12,10 +11,10 @@ import mafia.mafiatogether.global.ControllerTest; import mafia.mafiatogether.job.application.PlayerService; import mafia.mafiatogether.job.application.dto.request.PlayerExecuteAbilityRequest; -import mafia.mafiatogether.job.domain.PlayerJob; -import mafia.mafiatogether.job.domain.PlayerJobRepository; import mafia.mafiatogether.job.domain.JobTarget; import mafia.mafiatogether.job.domain.JobTargetRepository; +import mafia.mafiatogether.job.domain.PlayerJob; +import mafia.mafiatogether.job.domain.PlayerJobRepository; import mafia.mafiatogether.job.domain.jobtype.JobType; import mafia.mafiatogether.room.domain.Room; import mafia.mafiatogether.room.domain.RoomInfo; diff --git a/src/test/java/mafia/mafiatogether/job/domain/PoliceTest.java b/src/test/java/mafia/mafiatogether/job/domain/PoliceTest.java index 1b32ab9c..38155c77 100644 --- a/src/test/java/mafia/mafiatogether/job/domain/PoliceTest.java +++ b/src/test/java/mafia/mafiatogether/job/domain/PoliceTest.java @@ -15,7 +15,6 @@ @SuppressWarnings("NonAsciiCharacters") class PoliceTest { - private static final String CODE = "1234567890"; private static final String MAFIA = "mafia"; private static final String CITIZEN = "citizen"; private static final String POLICE = "police";