From dd90f1b94513c9ce8b60e96360760840ebc7bcf2 Mon Sep 17 00:00:00 2001 From: waterricecake Date: Mon, 12 Aug 2024 01:10:40 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20:=20Game=20save=20=EC=A1=B0=EA=B1=B4?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mafia/mafiatogether/game/application/GameService.java | 2 +- src/main/java/mafia/mafiatogether/game/domain/Game.java | 4 ++++ .../mafia/mafiatogether/game/domain/status/DeletedStatus.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/mafia/mafiatogether/game/application/GameService.java b/src/main/java/mafia/mafiatogether/game/application/GameService.java index 050b945..e82a957 100644 --- a/src/main/java/mafia/mafiatogether/game/application/GameService.java +++ b/src/main/java/mafia/mafiatogether/game/application/GameService.java @@ -38,7 +38,7 @@ public RoomStatusResponse findStatus(final String code) { private StatusType checkStatusChanged(final Game game) { game.setStatsSnapshot(); final StatusType statusType = game.getStatusType(Clock.systemDefaultZone().millis()); - if (game.isStatusChanged()) { + if (game.isStatusChanged() && game.isNotDeleted()) { gameRepository.save(game); } return statusType; diff --git a/src/main/java/mafia/mafiatogether/game/domain/Game.java b/src/main/java/mafia/mafiatogether/game/domain/Game.java index 6846be4..d576ff2 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/Game.java +++ b/src/main/java/mafia/mafiatogether/game/domain/Game.java @@ -145,4 +145,8 @@ public void setStatsSnapshot() { public boolean isStatusChanged() { return !statusSnapshot.getType().equals(status.getType()); } + + public boolean isNotDeleted(){ + return !status.getType().equals(StatusType.WAIT); + } } diff --git a/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java b/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java index bea5330..d77757d 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java +++ b/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java @@ -15,6 +15,6 @@ public Status getNextStatus(Game room, Long now) { @Override public StatusType getType() { - throw new RoomException(ExceptionCode.DELETED_STATUS); + return StatusType.WAIT; } } From a7abe5fff1a1ea0987291ce7ecfa1b88e16b91a7 Mon Sep 17 00:00:00 2001 From: waterricecake Date: Mon, 12 Aug 2024 01:47:06 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix=20:=20Delete=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EC=8B=9C=20=EB=B0=98=ED=99=98=20Type=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/mafia/mafiatogether/game/domain/Game.java | 2 +- .../mafia/mafiatogether/game/domain/status/DeletedStatus.java | 2 +- .../mafia/mafiatogether/game/domain/status/StatusType.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/mafia/mafiatogether/game/domain/Game.java b/src/main/java/mafia/mafiatogether/game/domain/Game.java index d576ff2..c6477f5 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/Game.java +++ b/src/main/java/mafia/mafiatogether/game/domain/Game.java @@ -147,6 +147,6 @@ public boolean isStatusChanged() { } public boolean isNotDeleted(){ - return !status.getType().equals(StatusType.WAIT); + return !status.getType().equals(StatusType.DELETED); } } diff --git a/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java b/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java index d77757d..3c4bd5e 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java +++ b/src/main/java/mafia/mafiatogether/game/domain/status/DeletedStatus.java @@ -15,6 +15,6 @@ public Status getNextStatus(Game room, Long now) { @Override public StatusType getType() { - return StatusType.WAIT; + return StatusType.DELETED; } } diff --git a/src/main/java/mafia/mafiatogether/game/domain/status/StatusType.java b/src/main/java/mafia/mafiatogether/game/domain/status/StatusType.java index 4db41eb..2ab5315 100644 --- a/src/main/java/mafia/mafiatogether/game/domain/status/StatusType.java +++ b/src/main/java/mafia/mafiatogether/game/domain/status/StatusType.java @@ -10,5 +10,6 @@ public enum StatusType { VOTE_RESULT, NIGHT_INTRO, NIGHT, - END + END, + DELETED }