Files
OpenFrontIO/src/client/graphics/Utils.ts
T
2024-09-03 19:13:42 -07:00

17 lines
471 B
TypeScript

export function renderTroops(troops: number): string {
let troopsStr = ''
troops = troops / 10
if (troops > 100000) {
troopsStr = String(Math.floor(troops / 1000)) + "K"
} else if (troops > 10000) {
troopsStr = String((troops / 1000).toFixed(1)) + "K"
} else if (troops > 1000) {
troopsStr = String((troops / 1000).toFixed(2)) + "K"
}
else {
troopsStr = String(Math.floor(troops))
}
return troopsStr
}