Skip to content

Commit

Permalink
refactor : 불필요한 필드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
waterricecake committed Aug 7, 2024
1 parent a6e0358 commit bf1b4bc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/mafia/mafiatogether/game/domain/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -100,7 +100,7 @@ public List<Player> getWinners() {
}

public List<Player> getLosers() {
if (players.getWinnerJobType().equals(JobType.MAFIA)){
if (players.getWinnerJobType().equals(JobType.MAFIA)) {
return players.getNotMafias();
}
return players.getMafias();
Expand All @@ -110,15 +110,15 @@ public String getWinnerJob() {
return players.getWinnerJobType().name();
}

public void publishVoteExecuteEvent(){
public void publishVoteExecuteEvent() {
registerEvent(new VoteExecuteEvent(this.code));
}

public void executeTarget(String target) {
players.executeTarget(target);
}

public void publicClearVoteEvent(){
public void publicClearVoteEvent() {
registerEvent(new ClearVoteEvent(this.code));
}

Expand All @@ -130,19 +130,19 @@ public void publishClearJobTargetEvent() {
registerEvent(new ClearJobTargetEvent(this.code));
}

public void publishDeleteGameEvent(){
public void publishDeleteGameEvent() {
registerEvent(new DeleteGameEvent(this.code));
}

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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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<Player> getMafias(){
public List<Player> getMafias() {
return players.stream()
.filter(player -> player.isMafia())
.toList();
}

public List<Player> getNotMafias(){
public List<Player> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ResponseEntity<Void> modifyStatus(
@PlayerInfo final PlayerInfoDto playerInfoDto,
@RequestBody final RoomModifyRequest request
) {
gameService.modifyStatus(playerInfoDto.code(), request);
gameService.modifyStatus(playerInfoDto.code());
return ResponseEntity.ok().build();
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/mafia/mafiatogether/job/domain/jobtype/Job.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit bf1b4bc

Please sign in to comment.