mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:10:42 +00:00
finish defense post
This commit is contained in:
@@ -202,12 +202,18 @@
|
||||
* add info view on top right DONE 11/30/2024
|
||||
* add info view for units DONE 11/30/2024
|
||||
* add defense post
|
||||
* bugfix: destroyers can't find path to dest and freeze
|
||||
* bugfix: when thread doesn't complete computation, do it in main
|
||||
* bugfix: destroyers can't find path to dst and freeze
|
||||
* bugfix: when trade ships captured don't render
|
||||
* bugfix: gameStop not found error
|
||||
* use mini A* for all pathfinding
|
||||
* log stack traces & display them on screen
|
||||
* record and replay games for debugging purposes
|
||||
* record single player game stats
|
||||
* add radiation from nuke
|
||||
* add cities
|
||||
* create behavior tests
|
||||
* create perf test
|
||||
* create alternate view to show friendly & enemy units
|
||||
* spread out calculate clusters
|
||||
* NPC has relations
|
||||
|
||||
@@ -84,7 +84,7 @@ export class TerritoryLayer implements Layer {
|
||||
if (tile.defenseBonuses().filter(db => db.unit.owner() == owner).length > 0) {
|
||||
this.paintCell(
|
||||
tile.cell(),
|
||||
colord({ r: 0, g: 0, b: 0 }),
|
||||
this.theme.defendedBorderColor(owner.info()),
|
||||
255
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -68,6 +68,7 @@ export interface Theme {
|
||||
playerInfoColor(id: PlayerID): Colord;
|
||||
territoryColor(playerInfo: PlayerInfo): Colord;
|
||||
borderColor(playerInfo: PlayerInfo): Colord;
|
||||
defendedBorderColor(playerInfo: PlayerInfo): Colord;
|
||||
terrainColor(tile: Tile): Colord;
|
||||
backgroundColor(): Colord;
|
||||
font(): string;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { pastelTheme } from "./PastelTheme";
|
||||
|
||||
export class DefaultConfig implements Config {
|
||||
defensePostRange(): number {
|
||||
return 20
|
||||
return 30
|
||||
}
|
||||
defensePostDefenseBonus(): number {
|
||||
return 3
|
||||
|
||||
@@ -5,7 +5,7 @@ export const devConfig = new class extends DefaultConfig {
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
const info = super.unitInfo(type)
|
||||
const oldCost = info.cost
|
||||
info.cost = (p: Player) => oldCost(p) / 1000
|
||||
info.cost = (p: Player) => oldCost(p) / 100000
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ export const devConfig = new class extends DefaultConfig {
|
||||
return 95
|
||||
}
|
||||
numSpawnPhaseTurns(): number {
|
||||
// return 40
|
||||
return 100
|
||||
return 40
|
||||
// return 100
|
||||
}
|
||||
gameCreationRate(): number {
|
||||
return 10 * 1000
|
||||
|
||||
@@ -6,6 +6,7 @@ import {PseudoRandom} from "../PseudoRandom";
|
||||
import {simpleHash} from "../Util";
|
||||
|
||||
export const pastelTheme = new class implements Theme {
|
||||
|
||||
private rand = new PseudoRandom(123)
|
||||
|
||||
private background = colord({r: 60, g: 60, b: 60});
|
||||
@@ -131,6 +132,14 @@ export const pastelTheme = new class implements Theme {
|
||||
b: Math.max(tc.b - 40, 0)
|
||||
})
|
||||
}
|
||||
defendedBorderColor(playerInfo: PlayerInfo): Colord {
|
||||
const bc = this.borderColor(playerInfo).rgba;
|
||||
return colord({
|
||||
r: Math.max(bc.r - 40, 0),
|
||||
g: Math.max(bc.g - 40, 0),
|
||||
b: Math.max(bc.b - 40, 0)
|
||||
})
|
||||
}
|
||||
|
||||
terrainColor(tile: Tile): Colord {
|
||||
let mag = tile.magnitude()
|
||||
|
||||
@@ -68,14 +68,14 @@ export class GameImpl implements MutableGame {
|
||||
addTileDefenseBonus(tile: Tile, unit: Unit, amount: number): DefenseBonus {
|
||||
const df = { unit: unit, tile: tile, amount: amount };
|
||||
(tile as TileImpl)._defenseBonuses.push(df)
|
||||
// this.eventBus.emit(new TileEvent(tile))
|
||||
this.eventBus.emit(new TileEvent(tile))
|
||||
return df
|
||||
}
|
||||
|
||||
removeTileDefenseBonus(bonus: DefenseBonus): void {
|
||||
const t = bonus.tile as TileImpl
|
||||
t._defenseBonuses = t._defenseBonuses.filter(db => db != bonus)
|
||||
// this.eventBus.emit(new TileEvent(bonus.tile))
|
||||
this.eventBus.emit(new TileEvent(bonus.tile))
|
||||
}
|
||||
|
||||
units(...types: UnitType[]): UnitImpl[] {
|
||||
|
||||
@@ -20,6 +20,10 @@ export class TileImpl implements Tile {
|
||||
private readonly _terrain: TerrainTileImpl
|
||||
) { }
|
||||
|
||||
terrainType(): TerrainType {
|
||||
return this._terrain.type
|
||||
}
|
||||
|
||||
defenseBonus(player: Player): number {
|
||||
if (this.owner() == player) {
|
||||
throw Error(`cannot get defense bonus of tile already owned by player`)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Cell, Tile } from "../game/Game";
|
||||
import { Cell, TerrainType, Tile } from "../game/Game";
|
||||
|
||||
export interface AStar {
|
||||
compute(): PathFindResultType
|
||||
@@ -26,6 +26,7 @@ export interface SearchNode {
|
||||
cost(): number
|
||||
cell(): Cell
|
||||
neighbors(): SearchNode[]
|
||||
terrainType(): TerrainType
|
||||
}
|
||||
export interface Point {
|
||||
x: number;
|
||||
|
||||
@@ -21,7 +21,7 @@ export class MiniAStar implements AStar {
|
||||
this.aStar = new SerialAStar(
|
||||
miniSrc,
|
||||
miniDst,
|
||||
(t => (t as TerrainTile).terrainType() == TerrainType.Ocean),
|
||||
canMove,
|
||||
iterations,
|
||||
maxTries
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user