mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-04 20:46:08 +00:00
Fix "Better troop management for nations 🤖" (#4265)
## Description: There was a check missing... The troop management stuff should be disabled for team games because nations can expect donations in that case, and its mainly relevant for FFAs. ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: FloPinguin
This commit is contained in:
@@ -851,12 +851,15 @@ export class AiAttackBehavior {
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hard & Impossible nations: returns true if `troops` is less than 20%
|
||||
* of the target's troop count, meaning the attack is too weak to be
|
||||
* worthwhile. Bots are exempt.
|
||||
* For Hard & Impossible nations in FFA: returns true if `troops` is less
|
||||
* than 20% of the target's troop count, meaning the attack is too weak to
|
||||
* be worthwhile. Bots and team games are exempt.
|
||||
*/
|
||||
private isAttackTooWeak(troops: number, target: Player): boolean {
|
||||
if (this.player.type() === PlayerType.Bot) return false;
|
||||
if (this.game.config().gameConfig().gameMode === GameMode.Team)
|
||||
return false;
|
||||
|
||||
const { difficulty } = this.game.config().gameConfig();
|
||||
return (
|
||||
(difficulty === Difficulty.Hard ||
|
||||
@@ -866,14 +869,18 @@ export class AiAttackBehavior {
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hard & Impossible nations: computes the max troops this nation can send
|
||||
* in an attack without letting its troop count drop below a fraction of its
|
||||
* strongest non-allied neighbor's troop count (Hard: 75%, Impossible: 90%).
|
||||
* Allied players and bot neighbors are not considered threats.
|
||||
* Bots are entirely exempt. Returns Infinity when no cap applies.
|
||||
* For Hard & Impossible nations in FFA: computes the max troops this nation
|
||||
* can send in an attack without letting its troop count drop below a
|
||||
* fraction of its strongest non-allied neighbor's troop count (Hard: 75%,
|
||||
* Impossible: 90%). Allied players and bot neighbors are not considered
|
||||
* threats. Bots and team games are entirely exempt. Returns Infinity when
|
||||
* no cap applies.
|
||||
*/
|
||||
private troopSendCap(): number {
|
||||
if (this.player.type() === PlayerType.Bot) return Infinity;
|
||||
if (this.game.config().gameConfig().gameMode === GameMode.Team)
|
||||
return Infinity;
|
||||
|
||||
const { difficulty } = this.game.config().gameConfig();
|
||||
let retainFraction: number;
|
||||
switch (difficulty) {
|
||||
|
||||
Reference in New Issue
Block a user