no attack if not connected to the empty land.

This commit is contained in:
evanpelle
2024-10-02 17:34:28 -07:00
parent 0654bc1712
commit 088e3a41ff
3 changed files with 27 additions and 9 deletions
+1 -1
View File
@@ -153,7 +153,7 @@
* make create/break alliance single button DONE 10/1/2024
* add request attack other players DONE 10/2/2024
* Improve alliance icon DONE 10/2/2024
* BUG: center button should be disabled select island
* BUG: center button should be disabled select island DONE 10/2/2024
* BUG: boat icon appears when click inland
* BUG: double tap zooms on mobile
* Make fake humans spawn by their country
+12 -5
View File
@@ -169,11 +169,18 @@ export class ClientGame {
}
if (tile.isLand()) {
for (const border of this.myPlayer.borderTiles()) {
for (const n of border.neighbors()) {
if (n.owner() == tile.owner()) {
this.eventBus.emit(new SendAttackIntentEvent(targetID))
return
if (tile.hasOwner()) {
if (this.myPlayer.sharesBorderWith(tile.owner())) {
this.eventBus.emit(new SendAttackIntentEvent(targetID))
}
} else {
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.isLand(), dist(tile, 200)))) {
for (const n of t.neighbors()) {
if (n.owner() == this.myPlayer) {
this.eventBus.emit(new SendAttackIntentEvent(targetID))
break outer_loop
}
}
}
}
+14 -3
View File
@@ -1,7 +1,7 @@
import {EventBus} from "../../../core/EventBus";
import {Cell, Game, Player, PlayerID} from "../../../core/game/Game";
import {ClientID} from "../../../core/Schemas";
import {manhattanDist, manhattanDistWrapped, sourceDstOceanShore} from "../../../core/Util";
import {and, bfs, dist, manhattanDist, manhattanDistWrapped, sourceDstOceanShore} from "../../../core/Util";
import {ContextMenuEvent, MouseUpEvent} from "../../InputHandler";
import {SendAllianceRequestIntentEvent, SendAttackIntentEvent, SendBoatAttackIntentEvent, SendBreakAllianceIntentEvent, SendSpawnIntentEvent, SendTargetPlayerIntentEvent} from "../../Transport";
import {TransformHandler} from "../TransformHandler";
@@ -231,8 +231,19 @@ export class RadialMenu implements Layer {
}
if (tile.owner() != myPlayer && tile.isLand() && myPlayer.sharesBorderWith(other)) {
if (!other.isPlayer() || !myPlayer.isAlliedWith(other)) {
this.renderCenterButton(true)
if (other.isPlayer()) {
if (!myPlayer.isAlliedWith(other)) {
this.renderCenterButton(true)
}
} else {
outer_loop: for (const t of bfs(tile, and(t => !t.hasOwner() && t.isLand(), dist(tile, 200)))) {
for (const n of t.neighbors()) {
if (n.owner() == myPlayer) {
this.renderCenterButton(true)
break outer_loop
}
}
}
}
}