always recalc name, NPCs spawn warships less frequently

This commit is contained in:
Evan
2024-12-27 10:59:41 -08:00
parent 2ceeda051d
commit bb968ec6b6
3 changed files with 11 additions and 11 deletions
+6 -6
View File
@@ -1,5 +1,5 @@
import {Game, Player, Tile, Cell} from '../../core/game/Game';
import {calculateBoundingBox, within} from '../../core/Util';
import { Game, Player, Tile, Cell } from '../../core/game/Game';
import { calculateBoundingBox, within } from '../../core/Util';
export interface Point {
x: number;
@@ -38,8 +38,8 @@ export function placeName(game: Game, player: Player): [position: Cell, fontSize
return [center, fontSize]
}
export function createGrid(game: Game, player: Player, boundingBox: {min: Point; max: Point}, scalingFactor: number): boolean[][] {
const scaledBoundingBox: {min: Point; max: Point} = {
export function createGrid(game: Game, player: Player, boundingBox: { min: Point; max: Point }, scalingFactor: number): boolean[][] {
const scaledBoundingBox: { min: Point; max: Point } = {
min: {
x: Math.floor(boundingBox.min.x / scalingFactor),
y: Math.floor(boundingBox.min.y / scalingFactor)
@@ -73,7 +73,7 @@ export function findLargestInscribedRectangle(grid: boolean[][]): Rectangle {
const rows = grid[0].length;
const cols = grid.length;
const heights: number[] = new Array(cols).fill(0);
let largestRect: Rectangle = {x: 0, y: 0, width: 0, height: 0};
let largestRect: Rectangle = { x: 0, y: 0, width: 0, height: 0 };
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
@@ -102,7 +102,7 @@ export function findLargestInscribedRectangle(grid: boolean[][]): Rectangle {
export function largestRectangleInHistogram(widths: number[]): Rectangle {
const stack: number[] = [];
let maxArea = 0;
let largestRect: Rectangle = {x: 0, y: 0, width: 0, height: 0};
let largestRect: Rectangle = { x: 0, y: 0, width: 0, height: 0 };
for (let i = 0; i <= widths.length; i++) {
const h = i === widths.length ? 0 : widths[i];
+4 -4
View File
@@ -102,10 +102,10 @@ export class NameLayer implements Layer {
const currTick = this.game.ticks()
const recalcRate = this.game.inSpawnPhase() ? 2 : 10
for (const render of this.renders) {
const territoryUpdated = render.boundingBox == null || render.player.lastTileChange() > render.lastBoundingCalculatedTick
if (!territoryUpdated) {
continue
}
// const territoryUpdated = render.boundingBox == null || render.player.lastTileChange() > render.lastBoundingCalculatedTick
// if (!territoryUpdated) {
// continue
// }
if (currTick - render.lastBoundingCalculatedTick > recalcRate) {
render.lastBoundingCalculatedTick = currTick
render.boundingBox = calculateBoundingBox(render.player.borderTiles());
+1 -1
View File
@@ -226,7 +226,7 @@ export class FakeHumanExecution implements Execution {
}
private maybeSpawnWarship(shipType: UnitType.Destroyer | UnitType.Battleship): boolean {
if (!this.random.chance(30)) {
if (!this.random.chance(50)) {
return false
}
const ports = this.player.units(UnitType.Port)