fix: utilGame format에서 한단계 다르게 차이나는 버그 수정

This commit is contained in:
2022-08-21 18:53:55 +09:00
parent 78a9641c14
commit a5e481af96
5 changed files with 182 additions and 23 deletions
+16 -17
View File
@@ -1,24 +1,23 @@
import bs from 'binary-search';
import { clamp } from 'lodash-es';
import bs from "binary-search";
const connectMap: [number, string][] = [
[0, '안함'],
[50, '무관심'],
[100, '보통'],
[400, '가끔'],
[200, '자주'],
[800, '열심'],
[1600, '중독'],
[3200, '폐인'],
[6400, '경고'],
[12800, '헐...'],
]
[0, "안함"],
[50, "무관심"],
[100, "보통"],
[200, "가끔"],
[400, "자주"],
[800, "열심"],
[1600, "중독"],
[3200, "폐인"],
[6400, "경고"],
[12800, "헐..."],
];
export function formatConnectScore(connect: number) {
const idx = bs(connectMap, connect, ([key], needle) => key - needle);
if (idx >= 0) {
return connectMap[idx][1] ?? '?';
return connectMap[idx][1] ?? "?";
}
const uidx = clamp(-idx - 1, 0, connectMap.length - 1);
return connectMap[uidx][1] ?? '?';
}
const uidx = (~idx) - 1;
return connectMap[uidx][1];
}
+1 -2
View File
@@ -1,5 +1,4 @@
import bs from 'binary-search';
import { clamp } from 'lodash-es';
const defenceMap: [number,string][] = [
[0, "△"],
@@ -14,6 +13,6 @@ export function formatDefenceTrain(defenceTrain: number): string {
if(idx >= 0){
return defenceMap[idx][1]??'?';
}
const uidx = clamp(-idx - 1, 0, defenceMap.length - 1);
const uidx = (~idx) - 1;
return defenceMap[uidx][1]??'?';
}
+1 -2
View File
@@ -1,5 +1,4 @@
import bs from 'binary-search';
import { clamp } from 'lodash-es';
export const DexLevelMap: [number, string, string][] = [
[0, 'navy', 'F-'],
@@ -39,7 +38,7 @@ export type DexInfo = {
export function formatDexLevel(dex: number): DexInfo {
const rawIdx = bs(DexLevelMap, dex, ([dexKey], needle) => dexKey - needle);
const level = rawIdx >= 0 ? rawIdx : clamp(-(rawIdx + 1), 0, DexLevelMap.length - 1);
const level = rawIdx >= 0 ? rawIdx : (~rawIdx) - 1;
const [, color, name] = DexLevelMap[level];
+1 -2
View File
@@ -1,5 +1,4 @@
import bs from 'binary-search';
import { clamp } from 'lodash-es';
const hornorMap: [number, string][] = [
[0, '전무'],
@@ -23,6 +22,6 @@ export function formatHonor(experience: number): string {
if (idx >= 0) {
return hornorMap[idx][1] ?? '?';
}
const uidx = clamp(-idx - 1, 0, hornorMap.length - 1);
const uidx = (~idx) - 1;
return hornorMap[uidx][1] ?? '?';
}