mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 00:21:55 +00:00
Optimize attack logic by reducing redundant neighbors() and owner() calls
This commit is contained in:
@@ -240,9 +240,10 @@ export class AttackExecution implements Execution {
|
||||
const fallbackTiles: { tile: TileRef; weight: number }[] = [];
|
||||
|
||||
const validTiles = this.toConquer.filter((tile) => {
|
||||
const onBorder = this.mg
|
||||
.neighbors(tile)
|
||||
.some((t) => this.mg.owner(t) === this._owner);
|
||||
const neighbors = this.mg.neighbors(tile);
|
||||
const onBorder = neighbors.some(
|
||||
(t) => this.mg.owner(t) === this._owner,
|
||||
);
|
||||
return this.mg.owner(tile) === this.target && onBorder;
|
||||
});
|
||||
if (validTiles.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user