fix: binarysearch 상한 에러

This commit is contained in:
2022-07-29 01:24:09 +09:00
parent a4ff1f44ba
commit fba60df9d1
4 changed files with 11 additions and 4 deletions
+3 -1
View File
@@ -1,4 +1,5 @@
import bs from 'binary-search';
import { clamp } from 'lodash';
const defenceMap: [number,string][] = [
[0, "△"],
@@ -13,5 +14,6 @@ export function formatDefenceTrain(defenceTrain: number): string {
if(idx >= 0){
return defenceMap[idx][1]??'?';
}
return defenceMap[-(idx + 1)][1]??'?';
const uidx = clamp(-idx - 1, 0, defenceMap.length - 1);
return defenceMap[uidx][1]??'?';
}