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

[BE] 김경규 강화하기 #8

Open
wants to merge 33 commits into
base: koungq
Choose a base branch
from
Open

Conversation

KoungQ
Copy link
Member

@KoungQ KoungQ commented May 30, 2024

No description provided.

@KoungQ KoungQ self-assigned this May 30, 2024
@KoungQ KoungQ changed the title 김경규 강화하기 [BE] 김경규 강화하기 May 30, 2024
import static leets.enhance.domain.item.entity.Status.*;

@Entity
@Table(name = "item")
Copy link
Member

Choose a reason for hiding this comment

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

엔티티하고 테이블 어노테이션은 중복된 기능을 가지는데 둘 다 사용한 이유가 있을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

굳이 안써도 될 어노테이션이었네요 놓친 부분 감사합니다 👍

Copy link
Member

@rootTiket rootTiket left a comment

Choose a reason for hiding this comment

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

미션고생하셨습니다 ! 배울 부분이 많았어요

Comment on lines +8 to +33
public enum SuccessProbability {

MIN(0, 0.9), // 파괴됐을 경우
LEVEL_1(1, 0.9),
LEVEL_2(2, 0.8),
LEVEL_3(3, 0.7),
LEVEL_4(4, 0.5),
LEVEL_5(5, 0.3),
LEVEL_6(6, 0.1),
MAX(7, 0.03);

private final int currentLevel;
private final double probability;

SuccessProbability(int currentLevel, double probability) {
this.currentLevel = currentLevel;
this.probability = probability;
}

public static double getProbability(int level) {
return Arrays.stream(values())
.filter(probability -> probability.getCurrentLevel() == level)
.map(SuccessProbability::getProbability)
.findAny()
.orElse(MAX.probability);
}
Copy link
Member

Choose a reason for hiding this comment

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

하나의 레벨 enum으로 파괴확률과 성공확률을 관리하는건 어떨까요? 성공과 파괴는 상태이지 하나의 객체로 보기는 어렵다는 생각이 듭니다 어떻게 생각하시나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

하나의 Probability로 처리하는게 더 좋아보이긴 하네요 감사합니당 👍


public Item getItem(Long itemId) {
return itemRepository.findById(itemId)
.orElseThrow(() -> new InvalidAccessException(INVALID_ITEM));
Copy link
Member

Choose a reason for hiding this comment

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

여유가 되신다면 에러 커스텀도 해주시면 코드 읽을 때 어떤 에러인지 보기 쉬울 것 같아요 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

커스텀 한거에요 👍

Comment on lines +47 to +50
@PrePersist
public void init() {
this.booster = 3;
}
Copy link
Member

Choose a reason for hiding this comment

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

따로 추가하는 로직을 구현하지 않고 유저 생성시 함께 생성되는 것이 인상깊었습니다 멋있어요

Copy link
Member Author

Choose a reason for hiding this comment

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

감사합니다 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants