Skip to content

Commit

Permalink
Fix: 단순 값이 추가되는 경우 V2로 사용하지 않고 V1에 필드 값을 추가(V2 삭제, V1에 percentage 값 추…
Browse files Browse the repository at this point in the history
…가) (#302)
  • Loading branch information
hee9841 authored Nov 8, 2024
1 parent 51075f1 commit 9c69238
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public record MyProfileResponseV1(
@Schema(description = "다음 레벨 이름")
String nextLevelName,
@Schema(description = "다음 레벨까지 남은 거리")
String nextLevelKm
String nextLevelKm,
@Schema(description = "퍼센테이지값", example = "0.728")
double percentage
) {

public static MyProfileResponseV1 from(MyProfileResponse myProfileResponse) {
Expand All @@ -23,7 +25,18 @@ public static MyProfileResponseV1 from(MyProfileResponse myProfileResponse) {
Level.formatExp(myProfileResponse.currentExpMeter()),
Level.formatLevelName(myProfileResponse.nextLevel()),
Level.formatExp(myProfileResponse.nextLevelEndExpMeter()
- myProfileResponse.currentExpMeter())
- myProfileResponse.currentExpMeter()),
calPercentageValue(
myProfileResponse.nextLevelStartExpMeter(),
myProfileResponse.nextLevelEndExpMeter(),
myProfileResponse.currentExpMeter()
)
);
}

private static double calPercentageValue(int nextStartMeter, int nextEndExpMeter, int currentExpMeter) {
double leftNextLevelMeter = nextEndExpMeter - currentExpMeter;
double divisorMeter = nextEndExpMeter - nextStartMeter;
return 1 - (leftNextLevelMeter / divisorMeter);
}
}

This file was deleted.

This file was deleted.

0 comments on commit 9c69238

Please sign in to comment.