Skip to content

Commit 7670d22

Browse files
committed
Added a threshold to prevent alerts for attacks with fewer than 1/5 of the player's troops
1 parent fe98e93 commit 7670d22

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/client/graphics/layers/AlertFrame.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ export class AlertFrame extends LitElement implements Layer {
171171
currentTick - this.lastAlertTick < ALERT_COOLDOWN_TICKS;
172172

173173
// Find new attacks that we haven't seen yet
174+
const playerTroops = myPlayer.troops();
175+
const minAttackTroopsThreshold = playerTroops / 5; // 1/5 of current troops
176+
174177
for (const attack of incomingAttacks) {
175178
// Only alert for non-retreating attacks
176179
if (!attack.retreating && !this.seenAttackIds.has(attack.id)) {
@@ -180,10 +183,14 @@ export class AlertFrame extends LitElement implements Layer {
180183
ourAttackTick !== undefined &&
181184
currentTick - ourAttackTick < RETALIATION_WINDOW_TICKS;
182185

186+
// Check if attack is too small (less than 1/5 of our troops)
187+
const isSmallAttack = attack.troops < minAttackTroopsThreshold;
188+
183189
// Don't alert if:
184190
// 1. We're in cooldown from a recent alert
185-
// 2. This is a retaliation (we attacked them within 10 seconds)
186-
if (!inCooldown && !isRetaliation) {
191+
// 2. This is a retaliation (we attacked them within 15 seconds)
192+
// 3. The attack is too small (less than 1/5 of our troops)
193+
if (!inCooldown && !isRetaliation && !isSmallAttack) {
187194
this.seenAttackIds.add(attack.id);
188195
this.activateAlert();
189196
} else {

0 commit comments

Comments
 (0)