mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 22:41:57 +00:00
remove BuildValidator
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import { BuildValidator } from "../game/BuildValidator";
|
||||
import { AllPlayers, Cell, Execution, MutableGame, MutablePlayer, MutableUnit, Player, PlayerID, Tile, Unit, UnitType } from "../game/Game";
|
||||
import { AStar, PathFinder } from "../PathFinding";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
import { bfs, dist, manhattanDist } from "../Util";
|
||||
import { TradeShipExecution } from "./TradeShipExecution";
|
||||
import { Cell, Execution, MutableGame, MutablePlayer, MutableUnit, Player, PlayerID, Tile, Unit, UnitType } from "../game/Game";
|
||||
|
||||
export class MissileSiloExecution implements Execution {
|
||||
|
||||
@@ -26,7 +21,7 @@ export class MissileSiloExecution implements Execution {
|
||||
tick(ticks: number): void {
|
||||
if (this.silo == null) {
|
||||
const tile = this.mg.tile(this.cell)
|
||||
if (!new BuildValidator(this.mg).canBuild(this.player, tile, UnitType.MissileSilo)) {
|
||||
if (!this.player.canBuild(UnitType.MissileSilo, tile)) {
|
||||
console.warn(`player ${this.player} cannot build port at ${this.cell}`)
|
||||
this.active = false
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { BuildValidator } from "../game/BuildValidator";
|
||||
import { Cell, Execution, MutableGame, MutablePlayer, PlayerID, Tile, MutableUnit, UnitType } from "../game/Game";
|
||||
import { PathFinder } from "../PathFinding";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
@@ -35,7 +34,7 @@ export class NukeExecution implements Execution {
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.nuke == null) {
|
||||
if (new BuildValidator(this.mg).canBuild(this.player, this.dst, UnitType.Nuke)) {
|
||||
if (this.player.canBuild(UnitType.Nuke, this.dst)) {
|
||||
const spawn = this.player.units(UnitType.MissileSilo)
|
||||
.sort((a, b) => manhattanDist(a.tile().cell(), this.cell) - manhattanDist(b.tile().cell(), this.cell))[0]
|
||||
this.nuke = this.player.buildUnit(UnitType.Nuke, 0, spawn.tile())
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { BuildValidator } from "../game/BuildValidator";
|
||||
import { AllPlayers, Cell, Execution, MutableGame, MutablePlayer, MutableUnit, Player, PlayerID, Tile, Unit, UnitType } from "../game/Game";
|
||||
import { AStar, PathFinder } from "../PathFinding";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
@@ -30,7 +29,7 @@ export class PortExecution implements Execution {
|
||||
tick(ticks: number): void {
|
||||
if (this.port == null) {
|
||||
const tile = this.mg.tile(this.cell)
|
||||
if (!new BuildValidator(this.mg).canBuild(this.player, tile, UnitType.Port)) {
|
||||
if (!this.player.canBuild(UnitType.Port, tile)) {
|
||||
console.warn(`player ${this.player} cannot build port at ${this.cell}`)
|
||||
this.active = false
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { BuildValidator } from "../game/BuildValidator";
|
||||
import { AllPlayers, Cell, Execution, MutableGame, MutablePlayer, MutableUnit, Player, PlayerID, Tile, Unit, UnitType } from "../game/Game";
|
||||
import { AStar, PathFinder } from "../PathFinding";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
|
||||
Reference in New Issue
Block a user