Fix: Players don't auto-send emoji replies when donated to, unlike nations (#2808)

## 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
This commit is contained in:
bijx
2026-01-08 10:08:11 -05:00
committed by GitHub
parent 5d9b834696
commit 9512e480d2
2 changed files with 37 additions and 23 deletions
+18 -14
View File
@@ -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()}`,
+19 -9
View File
@@ -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}`,