Allow attacking allies or teammates if player is disconnected (#2144)

## Description:

This will allow players to conquer land from afk teammates in team
games.

No troop loss if attacking afk teammate.

Also remove the team check in attack execution because we already do an
isFriendly check.

## 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:

evan
This commit is contained in:
evanpelle
2025-10-06 14:25:46 -07:00
committed by GitHub
parent fa7b7fceb3
commit 469a14d62a
3 changed files with 7 additions and 7 deletions
+4
View File
@@ -669,6 +669,10 @@ export class DefaultConfig implements Config {
}
if (attacker.isPlayer() && defender.isPlayer()) {
if (defender.isDisconnected() && attacker.isOnSameTeam(defender)) {
// No troop loss if defender is disconnected.
mag = 0;
}
if (
attacker.type() === PlayerType.Human &&
defender.type() === PlayerType.Bot
-7
View File
@@ -100,13 +100,6 @@ export class AttackExecution implements Execution {
this.active = false;
return;
}
if (this._owner.isOnSameTeam(this.target)) {
console.warn(
`${this._owner.displayName()} cannot attack ${this.target.displayName()} because they are on the same team`,
);
this.active = false;
return;
}
}
this.startTroops ??= this.mg
+3
View File
@@ -746,6 +746,9 @@ export class PlayerImpl implements Player {
}
isFriendly(other: Player): boolean {
if (other.isDisconnected()) {
return false;
}
return this.isOnSameTeam(other) || this.isAlliedWith(other);
}