From 712e824ffc859509dc9588a9cd2898834a732a39 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 16 Jul 2025 15:50:15 -0700 Subject: [PATCH] Revert MIRV attacks enemy units (#1452) This reverts commit 185fcb5fb0e65c309f1a7640772b3c752de3901f. ## Description: This change made the MIRV way too powerful. If two players MIRV each other it creates a stalemate because it takes so long to recover. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/core/execution/MIRVExecution.ts | 33 +++++++---------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/core/execution/MIRVExecution.ts b/src/core/execution/MIRVExecution.ts index ede8218ce..6b2b66a23 100644 --- a/src/core/execution/MIRVExecution.ts +++ b/src/core/execution/MIRVExecution.ts @@ -2,8 +2,8 @@ import { Execution, Game, MessageType, - nukeTypes, Player, + TerraNullius, Unit, UnitType, } from "../game/Game"; @@ -27,7 +27,7 @@ export class MirvExecution implements Execution { private pathFinder: ParabolaPathFinder; - private targetPlayer: Player; + private targetPlayer: Player | TerraNullius; private separateDst: TileRef; @@ -42,13 +42,7 @@ export class MirvExecution implements Execution { this.random = new PseudoRandom(mg.ticks() + simpleHash(this.player.id())); this.mg = mg; this.pathFinder = new ParabolaPathFinder(mg); - const target = this.mg.owner(this.dst); - if (!target.isPlayer()) { - console.warn(`cannot MIRV unowned land`); - this.active = false; - return; - } - this.targetPlayer = target as Player; + this.targetPlayer = this.mg.owner(this.dst); this.speed = this.mg.config().defaultNukeSpeed(); // Record stats @@ -95,19 +89,6 @@ export class MirvExecution implements Execution { private separate() { if (this.nuke === null) throw new Error("uninitialized"); const dsts: TileRef[] = [this.dst]; - for (const unit of this.targetPlayer.units()) { - if ( - unit.type() === UnitType.TradeShip || - nukeTypes.includes(unit.type()) - ) { - continue; - } - if (this.isNukeTooCloseToExisting(unit.tile(), dsts)) { - continue; - } - dsts.push(unit.tile()); - } - let attempts = 1000; while (attempts > 0 && dsts.length < this.warheadCount) { attempts--; @@ -117,11 +98,12 @@ export class MirvExecution implements Execution { } dsts.push(potential); } + console.log(`dsts: ${dsts.length}`); dsts.sort( (a, b) => this.mg.manhattanDist(b, this.dst) - this.mg.manhattanDist(a, this.dst), ); - console.log(`MIRV created: ${dsts.length} warheads`); + console.log(`got ${dsts.length} dsts!!`); for (const [i, dst] of dsts.entries()) { this.mg.addExecution( @@ -131,6 +113,7 @@ export class MirvExecution implements Execution { dst, this.nuke.tile(), 15 + Math.floor((i / this.warheadCount) * 5), + // this.random.nextInt(5, 9), this.random.nextInt(0, 15), ), ); @@ -173,7 +156,7 @@ export class MirvExecution implements Execution { if (this.mg.owner(tile) !== this.targetPlayer) { continue; } - if (this.isNukeTooCloseToExisting(tile, taken)) { + if (this.proximityCheck(tile, taken)) { continue; } return tile; @@ -182,7 +165,7 @@ export class MirvExecution implements Execution { return null; } - private isNukeTooCloseToExisting(tile: TileRef, taken: TileRef[]): boolean { + private proximityCheck(tile: TileRef, taken: TileRef[]): boolean { for (const t of taken) { if (this.mg.manhattanDist(tile, t) < 25) { return true;