mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-07 12:45:58 +00:00
Fix train was destroyed message spam (#2774)
## Description: Trains are made of a primary unit (`TrainExecution.train`) followed by 6 cars (`TrainExecution.cars`). Currently when any of the units is destroyed, a message "Your Train was destroyed" is shown. In worst case scenario, when all cars are blasted by a nuke, 7 messages are displayed to the user, but the train continues. Since the actual logic is unaffected as long as the primary unit stays alive, displaying messages is confusing. This PR fixes it. The message is only displayed when the primary unit is destroyed. The following cars are only there for fancy visuals. ## Screencast ##### Current - multiple messages for single train https://github.com/user-attachments/assets/3df04c71-d899-4f68-af83-36c9d0ffa730 First nuke was a test. Second nuke destroyed the entire train, prompting 7 messages. Third nuke destroyed one full train and then some. Prompting many too many messages. ##### Fixed - one message, only if train was fully destroyed https://github.com/user-attachments/assets/1f3840a7-6c62-487d-af3a-82de39dad9e8 First train was only partially destroyed, no message was shown, delivery mission completed A+. Following 2 trains had the front engine destroyed and therefore were promptly decommissioned. ## Please complete the following: - [x] I have added screenshots for all UI updates - [ ] I process any text displayed to the user through translateText() and I've added it to the en.json file - [ ] 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: moleole
This commit is contained in:
committed by
GitHub
parent
ae6293f6da
commit
ab5b044362
@@ -14,8 +14,8 @@ import { TrainStation } from "../game/TrainStation";
|
||||
export class TrainExecution implements Execution {
|
||||
private active = true;
|
||||
private mg: Game | null = null;
|
||||
private train: Unit | null = null;
|
||||
private cars: Unit[] = [];
|
||||
private train: Unit | null = null; // primary unit
|
||||
private cars: Unit[] = []; // stored back to front
|
||||
private hasCargo: boolean = false;
|
||||
private currentTile: number = 0;
|
||||
private spacing = 2;
|
||||
@@ -69,6 +69,7 @@ export class TrainExecution implements Execution {
|
||||
if (this.train === null) {
|
||||
throw new Error("Not initialized");
|
||||
}
|
||||
|
||||
if (!this.train.isActive() || !this.activeSourceOrDestination()) {
|
||||
this.deleteTrain();
|
||||
return;
|
||||
@@ -113,7 +114,7 @@ export class TrainExecution implements Execution {
|
||||
this.cars.push(
|
||||
this.player.buildUnit(UnitType.Train, tile, {
|
||||
targetUnit: this.destination.unit,
|
||||
trainType: TrainType.Engine,
|
||||
trainType: TrainType.TailEngine,
|
||||
}),
|
||||
);
|
||||
for (let i = 0; i < this.numCars; i++) {
|
||||
|
||||
Reference in New Issue
Block a user