mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 05:04:36 +00:00
17 lines
471 B
TypeScript
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
|
|
} |