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: NONE 싱글톤 에러 픽스 #66

Merged
merged 1 commit into from
May 31, 2024
Merged

fix: NONE 싱글톤 에러 픽스 #66

merged 1 commit into from
May 31, 2024

Conversation

waterricecake
Copy link
Contributor

이전 PR 에서 Player.NONE이 싱글톤이면서 문제가 발생
이름을 빈칸으로 반환시 Player.NONE을 반환하면서 문제가 발생

    public Player getPlayer(final String name) {
        if (name.isBlank()) {
            return Player.NONE;
        }
        if (!players.containsKey(name)) {
            throw new RoomException(ExceptionCode.INVALID_PLAYER);
        }
        return players.get(name);
    }

이전에 어떠한 이유로 Player.NONE을 사망처리하였을때 (투표 기권으로 Player.NONE이 사망 등) Player.NONE이 싱글톤으로 모든 상황에서 사망처리되어

    public String executeSkill(final String name, final String targetName) {
        final Player player = getPlayer(name);
        final Player target = getPlayer(targetName);
        if (!target.isAlive()) {
            throw new PlayerException(ExceptionCode.NOT_ALIVE_PLAYER);
        }
        return player.getJob().applySkill(target, jobTarget);
    }

에서 사망처리됨
그래서 일단 이 부분을

    public String executeSkill(final String name, final String targetName) {
        final Player player = getPlayer(name);
        final Player target = getPlayer(targetName);
        if (!target.isAlive() && !target.equals(Player.NONE)) {
            throw new PlayerException(ExceptionCode.NOT_ALIVE_PLAYER);
        }
        return player.getJob().applySkill(target, jobTarget);
    }

으로 바꿔둠
더 좋은 방법이 있는지 (있다면 getName을 따로 쓰는 방법인거 같은데) 잘 모르겠음...

@waterricecake waterricecake added bug Something isn't working Backend Hotfix labels May 30, 2024
@waterricecake waterricecake requested a review from thdwoqor May 30, 2024 12:32
@waterricecake waterricecake self-assigned this May 30, 2024
@thdwoqor thdwoqor merged commit 8662e88 into dev May 31, 2024
1 check passed
waterricecake added a commit that referenced this pull request Oct 14, 2024
@waterricecake waterricecake deleted the fix/13 branch October 14, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend bug Something isn't working Hotfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants