improved player troops count rendering

This commit is contained in:
evanpelle
2024-08-24 13:17:00 -07:00
parent d91561c79e
commit 3c3bb7af54
2 changed files with 14 additions and 12 deletions
+11 -9
View File
@@ -123,17 +123,19 @@ export class NameRenderer {
context.fillText(render.player.info().name, nameCenterX, nameCenterY - render.fontSize / 2);
context.font = `bold ${render.fontSize}px ${this.theme.font()}`;
let troops: string = ""
if (render.player.troops() > 100000) {
troops = String(Math.floor(render.player.troops() / 1000)) + "K"
} else if (render.player.troops() > 10000) {
troops = String((render.player.troops() / 1000).toFixed(1)) + "K"
} else if (render.player.troops() > 1000) {
troops = String((render.player.troops() / 1000).toFixed(2)) + "K"
let troopsStr: string = ""
let troops = render.player.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 {
troops = String(Math.floor(render.player.troops()))
troopsStr = String(Math.floor(troops))
}
context.fillText(troops, nameCenterX, nameCenterY + render.fontSize);
context.fillText(troopsStr, nameCenterX, nameCenterY + render.fontSize);
}
}
+3 -3
View File
@@ -7,7 +7,7 @@ export const devConfig = new class extends DefaultConfig {
return 2 * 1000
}
lobbyLifetime(): number {
return 10 * 1000
return 5 * 1000
}
turnIntervalMs(): number {
return 100
@@ -16,14 +16,14 @@ export const devConfig = new class extends DefaultConfig {
return devPlayerConfig
}
numBots(): number {
return 0
return 500
}
}
export const devPlayerConfig = new class extends DefaultPlayerConfig {
startTroops(playerInfo: PlayerInfo): number {
if (playerInfo.isBot) {
return 5000
return 1000
}
return 5000
}