make place name for efficient during spawn

This commit is contained in:
evanpelle
2025-01-21 08:00:44 -08:00
committed by Evan
parent e4f0d76733
commit 8fea4d7bfa
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -4,7 +4,7 @@ import { getConfig } from "./configuration/Config";
import { EventBus } from "./EventBus";
import { Executor } from "./execution/ExecutionManager";
import { WinCheckExecution } from "./execution/WinCheckExecution";
import { Cell, DisplayMessageUpdate, Game, GameUpdateType, MessageType, MutableGame, NameViewData, Player, PlayerActions, PlayerID, PlayerProfile, UnitType } from "./game/Game";
import { Cell, DisplayMessageUpdate, Game, GameUpdateType, MessageType, MutableGame, NameViewData, Player, PlayerActions, PlayerID, PlayerProfile, PlayerType, UnitType } from "./game/Game";
import { createGame } from "./game/GameImpl";
import { loadTerrainMap as loadGameMap } from "./game/TerrainMapLoader";
import { GameConfig, Turn } from "./Schemas";
@@ -62,8 +62,14 @@ export class GameRunner {
this.game.addExecution(...this.execManager.createExecs(this.turns[this.currTurn]))
this.currTurn++
const updates = this.game.executeNextTick()
// TODO: make name rendering more efficient in spawn phase.
if (this.game.inSpawnPhase() || this.game.ticks() % 30 == 0) {
if (this.game.inSpawnPhase() && this.game.ticks() % 2 == 0) {
this.game.players()
.filter(p => p.type() == PlayerType.Human || p.type() == PlayerType.FakeHuman)
.forEach(p => this.playerViewData[p.id()] = placeName(this.game, p))
}
if (this.game.ticks() < 3 || this.game.ticks() % 30 == 0) {
this.game.players().forEach(p => {
this.playerViewData[p.id()] = placeName(this.game, p)
})
+1 -1
View File
@@ -26,7 +26,7 @@ export class DevConfig extends DefaultConfig {
unitInfo(type: UnitType): UnitInfo {
const info = super.unitInfo(type)
const oldCost = info.cost
info.cost = (p: Player) => oldCost(p) / 10000
// info.cost = (p: Player) => oldCost(p) / 10000
return info
}