mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 05:03:50 +00:00
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 :  ## 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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user