Merge v25 into main

This commit is contained in:
Scott Anderson
2025-08-06 22:43:14 -04:00
18 changed files with 211 additions and 25 deletions
+1
View File
@@ -57,6 +57,7 @@ export class BotExecution implements Execution {
}
this.behavior.handleAllianceRequests();
this.behavior.handleAllianceExtensionRequests();
this.maybeAttack();
}
+1
View File
@@ -155,6 +155,7 @@ export class FakeHumanExecution implements Execution {
this.updateRelationsFromEmbargos();
this.behavior.handleAllianceRequests();
this.behavior.handleAllianceExtensionRequests();
this.handleUnits();
this.handleEmbargoesToHostileNations();
this.maybeAttack();
@@ -39,7 +39,7 @@ export class AllianceExtensionExecution implements Execution {
// Mark this player's intent to extend
alliance.addExtensionRequest(this.from);
if (alliance.canExtend()) {
if (alliance.bothAgreedToExtend()) {
alliance.extend();
mg.displayMessage(
+23
View File
@@ -9,6 +9,7 @@ import {
} from "../../game/Game";
import { PseudoRandom } from "../../PseudoRandom";
import { flattenedEmojiTable } from "../../Util";
import { AllianceExtensionExecution } from "../alliance/AllianceExtensionExecution";
import { AttackExecution } from "../AttackExecution";
import { EmojiExecution } from "../EmojiExecution";
@@ -37,6 +38,28 @@ export class BotBehavior {
}
}
handleAllianceExtensionRequests() {
for (const alliance of this.player.alliances()) {
// Alliance expiration tracked by Events Panel, only human ally can click Request to Renew
// Skip if no expiration yet/ ally didn't request extension yet/ bot already agreed to extend
if (!alliance.onlyOneAgreedToExtend()) continue;
// Nation is either Friendly or Neutral as an ally. Bot has no attitude
// If Friendly or Bot, always agree to extend. If Neutral, have random chance decide
const human = alliance.other(this.player);
if (
this.player.type() === PlayerType.FakeHuman &&
this.player.relation(human) === Relation.Neutral
) {
if (!this.random.chance(1.5)) continue;
}
this.game.addExecution(
new AllianceExtensionExecution(this.player, human.id()),
);
}
}
private emoji(player: Player, emoji: number) {
if (player.type() !== PlayerType.Human) return;
this.game.addExecution(new EmojiExecution(this.player, player.id(), emoji));