mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:30:43 +00:00
improved player info rendering
This commit is contained in:
@@ -123,6 +123,17 @@ export class NameRenderer {
|
||||
|
||||
context.fillText(render.player.info().name, nameCenterX, nameCenterY - render.fontSize / 2);
|
||||
context.font = `bold ${render.fontSize}px ${this.theme.font()}`;
|
||||
context.fillText(String(Math.floor(render.player.troops())), nameCenterX, nameCenterY + render.fontSize);
|
||||
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"
|
||||
}
|
||||
else {
|
||||
troops = String(Math.floor(render.player.troops()))
|
||||
}
|
||||
context.fillText(troops, nameCenterX, nameCenterY + render.fontSize);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user