mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-12 00:43:57 +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 fallbackTiles: { tile: TileRef; weight: number }[] = [];
|
||||||
|
|
||||||
const validTiles = this.toConquer.filter((tile) => {
|
const validTiles = this.toConquer.filter((tile) => {
|
||||||
const onBorder = this.mg
|
const neighbors = this.mg.neighbors(tile);
|
||||||
.neighbors(tile)
|
const onBorder = neighbors.some(
|
||||||
.some((t) => this.mg.owner(t) === this._owner);
|
(t) => this.mg.owner(t) === this._owner,
|
||||||
|
);
|
||||||
return this.mg.owner(tile) === this.target && onBorder;
|
return this.mg.owner(tile) === this.target && onBorder;
|
||||||
});
|
});
|
||||||
if (validTiles.length === 0) {
|
if (validTiles.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user