Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : Game save 조건 추가 #95

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mafia/mafiatogether/game/domain/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public Status getNextStatus(Game room, Long now) {

@Override
public StatusType getType() {
throw new RoomException(ExceptionCode.DELETED_STATUS);
return StatusType.WAIT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeletedStatus.getType에 반환값을 주고 (Wait) 이거 면 저장 로직에서 제외시켜 주었습니다.

반환값이 StatusType.Deleted 만들어서 Deleted 상태이면 저장하지 않게하는게 이해하기 편할꺼같아
Deleted 상태 값을 반환하는데 Wait이 나오는게 조금 어색한거같아

Copy link
Contributor Author

@waterricecake waterricecake Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 그게 더 나을려나 난 WaitStatus로 이름을 바꿀까 생각했었는데... 생각해보면 Game의 Delete니까 그게 더 맞을꺼란 생각도 들고... 오키
fix : Delete 상태시 반환 Type 추가

}
}
Loading