From 9512e480d2cc833bbb64942d48d750db7000cf30 Mon Sep 17 00:00:00 2001 From: bijx Date: Thu, 8 Jan 2026 10:08:11 -0500 Subject: [PATCH] Fix: Players don't auto-send emoji replies when donated to, unlike nations (#2808) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description: The new (awesome) nation emoji updates had a small bug in them when I was playtesting with a friend where donating troops to them (a human player) would result in the player automatically sending an emoji reply. Sometimes these replies were negative-connotations like ❓ and 🥱, which could impact how other players perceive their donation attempt. This PR fixes that issue. ### Example of player nation sending emojis automatically https://github.com/user-attachments/assets/99689966-b784-4c3f-b43b-953a4a102e2d ### Donating to player after fix https://github.com/user-attachments/assets/ace0c1ee-3eb8-4240-9c78-167dd773cfb2 ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: bijx --- src/core/execution/DonateGoldExecution.ts | 32 ++++++++++++---------- src/core/execution/DonateTroopExecution.ts | 28 +++++++++++++------ 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/core/execution/DonateGoldExecution.ts b/src/core/execution/DonateGoldExecution.ts index da292be9f..623fe6f90 100644 --- a/src/core/execution/DonateGoldExecution.ts +++ b/src/core/execution/DonateGoldExecution.ts @@ -5,6 +5,7 @@ import { Gold, Player, PlayerID, + PlayerType, } from "../game/Game"; import { PseudoRandom } from "../PseudoRandom"; import { assertNever, toInt } from "../Util"; @@ -60,21 +61,24 @@ export class DonateGoldExecution implements Execution { this.recipient.updateRelation(this.sender, relationUpdate); } - // Select emoji based on donation value - const emoji = - relationUpdate >= 50 - ? EMOJI_LOVE - : relationUpdate > 0 - ? EMOJI_DONATION_OK - : EMOJI_DONATION_TOO_SMALL; + // Only AI nations auto-respond with emojis, human players should not + if (this.recipient.type() === PlayerType.Nation) { + // Select emoji based on donation value + const emoji = + relationUpdate >= 50 + ? EMOJI_LOVE + : relationUpdate > 0 + ? EMOJI_DONATION_OK + : EMOJI_DONATION_TOO_SMALL; - this.mg.addExecution( - new EmojiExecution( - this.recipient, - this.sender.id(), - this.random.randElement(emoji), - ), - ); + this.mg.addExecution( + new EmojiExecution( + this.recipient, + this.sender.id(), + this.random.randElement(emoji), + ), + ); + } } else { console.warn( `cannot send gold from ${this.sender.name()} to ${this.recipient.name()}`, diff --git a/src/core/execution/DonateTroopExecution.ts b/src/core/execution/DonateTroopExecution.ts index d91313079..54992a2c3 100644 --- a/src/core/execution/DonateTroopExecution.ts +++ b/src/core/execution/DonateTroopExecution.ts @@ -1,4 +1,11 @@ -import { Difficulty, Execution, Game, Player, PlayerID } from "../game/Game"; +import { + Difficulty, + Execution, + Game, + Player, + PlayerID, + PlayerType, +} from "../game/Game"; import { PseudoRandom } from "../PseudoRandom"; import { assertNever } from "../Util"; import { EmojiExecution } from "./EmojiExecution"; @@ -54,15 +61,18 @@ export class DonateTroopsExecution implements Execution { this.recipient.updateRelation(this.sender, 50); } - this.mg.addExecution( - new EmojiExecution( - this.recipient, - this.sender.id(), - this.random.randElement( - this.troops >= minTroops ? EMOJI_LOVE : EMOJI_DONATION_TOO_SMALL, + // Only AI nations auto-respond with emojis, human players should not + if (this.recipient.type() === PlayerType.Nation) { + this.mg.addExecution( + new EmojiExecution( + this.recipient, + this.sender.id(), + this.random.randElement( + this.troops >= minTroops ? EMOJI_LOVE : EMOJI_DONATION_TOO_SMALL, + ), ), - ), - ); + ); + } } else { console.warn( `cannot send troops from ${this.sender} to ${this.recipient}`,