mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-08 05:40:39 +00:00
put methods onto terraintile
This commit is contained in:
@@ -211,7 +211,7 @@ export class ClientGameRunner {
|
||||
}
|
||||
consolex.log(`clicked cell ${cell}`)
|
||||
const tile = this.gs.tile(cell)
|
||||
if (tile.isLand() && !tile.hasOwner() && this.gs.inSpawnPhase()) {
|
||||
if (tile.terrain().isLand() && !tile.hasOwner() && this.gs.inSpawnPhase()) {
|
||||
this.eventBus.emit(new SendSpawnIntentEvent(cell))
|
||||
return
|
||||
}
|
||||
@@ -233,13 +233,13 @@ export class ClientGameRunner {
|
||||
return
|
||||
}
|
||||
|
||||
if (tile.isLand()) {
|
||||
if (tile.terrain().isLand()) {
|
||||
if (tile.hasOwner()) {
|
||||
if (this.myPlayer.sharesBorderWith(tile.owner())) {
|
||||
this.eventBus.emit(new SendAttackIntentEvent(targetID, this.myPlayer.troops() * this.renderer.uiState.attackRatio))
|
||||
}
|
||||
} else {
|
||||
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.isLand(), dist(tile, 200)))) {
|
||||
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.terrain().isLand(), dist(tile, 200)))) {
|
||||
for (const n of t.neighbors()) {
|
||||
if (n.owner() == this.myPlayer) {
|
||||
this.eventBus.emit(new SendAttackIntentEvent(targetID, this.myPlayer.troops() * this.renderer.uiState.attackRatio))
|
||||
|
||||
@@ -61,7 +61,7 @@ export function createGrid(game: Game, player: Player, boundingBox: { min: Point
|
||||
const cell = new Cell(x * scalingFactor, y * scalingFactor);
|
||||
if (game.isOnMap(cell)) {
|
||||
const tile = game.tile(cell);
|
||||
grid[x - scaledBoundingBox.min.x][y - scaledBoundingBox.min.y] = tile.isLake() || tile.owner() === player; // TODO: okay if lake
|
||||
grid[x - scaledBoundingBox.min.x][y - scaledBoundingBox.min.y] = tile.terrain().isLake() || tile.owner() === player; // TODO: okay if lake
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export class PlayerInfoOverlay extends LitElement implements Layer {
|
||||
if (owner.isPlayer()) {
|
||||
this.player = owner;
|
||||
this.setVisible(true);
|
||||
} else if (!tile.isLand()) {
|
||||
} else if (!tile.terrain().isLand()) {
|
||||
const units = this.game.units(UnitType.Destroyer, UnitType.Battleship, UnitType.TradeShip)
|
||||
.filter(u => euclideanDist(worldCoord, u.tile().cell()) < 50)
|
||||
.sort(distSortUnit(tile));
|
||||
|
||||
@@ -239,7 +239,7 @@ export class RadialMenu implements Layer {
|
||||
const other = tile.owner()
|
||||
|
||||
if (this.game.inSpawnPhase()) {
|
||||
if (tile.isLand() && !tile.hasOwner()) {
|
||||
if (tile.terrain().isLand() && !tile.hasOwner()) {
|
||||
this.enableCenterButton(true)
|
||||
}
|
||||
return
|
||||
@@ -268,13 +268,13 @@ export class RadialMenu implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
if (tile.owner() != myPlayer && tile.isLand() && myPlayer.sharesBorderWith(other)) {
|
||||
if (tile.owner() != myPlayer && tile.terrain().isLand() && myPlayer.sharesBorderWith(other)) {
|
||||
if (other.isPlayer()) {
|
||||
if (!myPlayer.isAlliedWith(other)) {
|
||||
this.enableCenterButton(true)
|
||||
}
|
||||
} else {
|
||||
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.isLand(), dist(tile, 200)))) {
|
||||
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.terrain().isLand(), dist(tile, 200)))) {
|
||||
for (const n of t.neighbors()) {
|
||||
if (n.owner() == myPlayer) {
|
||||
this.enableCenterButton(true)
|
||||
@@ -321,7 +321,7 @@ export class RadialMenu implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
if (!tile.isLand()) {
|
||||
if (!tile.terrain().isLand()) {
|
||||
return
|
||||
}
|
||||
if (myPlayer.units(UnitType.TransportShip).length >= this.game.config().boatMaxNumber()) {
|
||||
@@ -330,7 +330,7 @@ export class RadialMenu implements Layer {
|
||||
|
||||
let myPlayerBordersOcean = false
|
||||
for (const bt of myPlayer.borderTiles()) {
|
||||
if (bt.isOceanShore()) {
|
||||
if (bt.terrain().isOceanShore()) {
|
||||
myPlayerBordersOcean = true
|
||||
break
|
||||
}
|
||||
@@ -340,7 +340,7 @@ export class RadialMenu implements Layer {
|
||||
otherPlayerBordersOcean = true
|
||||
} else {
|
||||
for (const bt of (other as Player).borderTiles()) {
|
||||
if (bt.isOceanShore()) {
|
||||
if (bt.terrain().isOceanShore()) {
|
||||
otherPlayerBordersOcean = true
|
||||
break
|
||||
}
|
||||
@@ -352,8 +352,8 @@ export class RadialMenu implements Layer {
|
||||
}
|
||||
|
||||
let nearOcean = false
|
||||
for (const t of bfs(tile, and(t => t.owner() == tile.owner() && t.isLand(), dist(tile, 25)))) {
|
||||
if (t.isOceanShore()) {
|
||||
for (const t of bfs(tile, and(t => t.owner() == tile.owner() && t.terrain().isLand(), dist(tile, 25)))) {
|
||||
if (t.terrain().isOceanShore()) {
|
||||
nearOcean = true
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user