From 8dc6941fe7354b2d9e71ce097ed856d6564f97d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9odore=20L=C3=A9on?= Date: Mon, 2 Jun 2025 22:27:24 +0200 Subject: [PATCH] Fix : Donation when max pop already reached (#904) ## Description: Only donate up to what the receiving player can get so we don't silently loose troops See the chat here : ![image](https://github.com/user-attachments/assets/95b0917c-b7f3-47a0-b3a0-156110e727aa) ## Please complete the following: - [x] I have added screenshots for all UI updates - [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: theodoreleon.aetarax --------- Co-authored-by: tnhnblgl <51187395+tnhnblgl@users.noreply.github.com> --- src/core/execution/DonateTroopExecution.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/execution/DonateTroopExecution.ts b/src/core/execution/DonateTroopExecution.ts index 40fde1781..3e362f611 100644 --- a/src/core/execution/DonateTroopExecution.ts +++ b/src/core/execution/DonateTroopExecution.ts @@ -30,6 +30,10 @@ export class DonateTroopsExecution implements Execution { if (this.troops === null) { this.troops = mg.config().defaultDonationAmount(this.sender); } + const maxDonation = + mg.config().maxPopulation(this.recipient) - + this.recipient.totalPopulation(); + this.troops = Math.min(this.troops, maxDonation); } tick(ticks: number): void { @@ -41,7 +45,7 @@ export class DonateTroopsExecution implements Execution { this.recipient.updateRelation(this.sender, 50); } else { consolex.warn( - `cannot send tropps from ${this.sender} to ${this.recipient}`, + `cannot send troops from ${this.sender} to ${this.recipient}`, ); } this.active = false;