Files
core/hwe/ts/utilGame/formatDefenceTrain.ts

18 lines
427 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import bs from 'binary-search';
const defenceMap: [number,string][] = [
[0, "△"],
[60, "○"],
[80, "◎"],
[90, "☆"],
[999, "×"],
]
export function formatDefenceTrain(defenceTrain: number): string {
const idx = bs(defenceMap, defenceTrain, ([defenceKey], needle) => defenceKey - needle);
if(idx >= 0){
return defenceMap[idx][1]??'?';
}
const uidx = (~idx) - 1;
return defenceMap[uidx][1]??'?';
}