diff --git a/TODO.txt b/TODO.txt index 590bc5d1c..5f18b9929 100644 --- a/TODO.txt +++ b/TODO.txt @@ -137,6 +137,7 @@ * fake humans handle alliances * make alliances expire * make year clock +* block user inputs if too far behind server * BUG: FakeHuman don't be enemy if don't share border * BUG: when send boat only captures one pixel * store cookies diff --git a/src/client/ClientGame.ts b/src/client/ClientGame.ts index 3f532f440..98cd0f28c 100644 --- a/src/client/ClientGame.ts +++ b/src/client/ClientGame.ts @@ -273,9 +273,10 @@ export class ClientGame { } const tn = Array.from(bfs(tile, dist(tile, 10))) .filter(t => t.isOceanShore()) + .filter(t => t.owner() != this.myPlayer) .sort((a, b) => manhattanDist(tile.cell(), a.cell()) - manhattanDist(tile.cell(), b.cell())) if (tn.length > 0) { - this.sendBoatAttackIntent(targetID, tn[0].cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner)) + this.sendBoatAttackIntent(tn[0].owner().id(), tn[0].cell(), this.gs.config().boatAttackAmount(this.myPlayer, owner)) } } } diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index fe902e24a..4634d8411 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -19,7 +19,7 @@ export const devConfig = new class extends DefaultConfig { } numBots(): number { - return 1 + return 0 } diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index e0b4b7cc3..b725069f4 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -46,14 +46,14 @@ export class AttackExecution implements Execution { if (!this.active) { return } + this.mg = mg this.targetCell = null this._owner = mg.player(this._ownerID) - this.target = this._targetID == null ? mg.terraNullius() : mg.player(this._targetID) + this.target = this._targetID == this.mg.terraNullius().id() ? mg.terraNullius() : mg.player(this._targetID) this.troops = Math.min(this._owner.troops(), this.troops) this._owner.setTroops(this._owner.troops() - this.troops) - this.mg = mg for (const exec of mg.executions()) { if (exec.isActive() && exec instanceof AttackExecution && exec != this) { diff --git a/src/core/execution/BoatAttackExecution.ts b/src/core/execution/BoatAttackExecution.ts index 110f4f625..00445f2d2 100644 --- a/src/core/execution/BoatAttackExecution.ts +++ b/src/core/execution/BoatAttackExecution.ts @@ -57,7 +57,7 @@ export class BoatAttackExecution implements Execution { return } - if (this.targetID == null) { + if (this.targetID == null || this.targetID == this.mg.terraNullius().id()) { this.target = mg.terraNullius() } else { this.target = mg.player(this.targetID) @@ -67,11 +67,7 @@ export class BoatAttackExecution implements Execution { this.attacker.removeTroops(this.troops) this.src = this.closestShoreTile(this.attacker, this.cell) - if (this.target.isPlayer()) { - this.dst = this.closestShoreTile(this.target, this.cell) - } else { - this.dst = this.mg.tile(this.cell) - } + this.dst = this.mg.tile(this.cell) if (this.src == null || this.dst == null) { this.active = false diff --git a/src/core/game/TerraNulliusImpl.ts b/src/core/game/TerraNulliusImpl.ts index d7c910a3a..663586631 100644 --- a/src/core/game/TerraNulliusImpl.ts +++ b/src/core/game/TerraNulliusImpl.ts @@ -10,7 +10,7 @@ export class TerraNulliusImpl implements TerraNullius { } id(): PlayerID { - return 'TerraNulliusID'; + return null } ownsTile(cell: Cell): boolean { return this.tiles.has(cell);