mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-20 09:10:09 +00:00
Merge v25 into main
This commit is contained in:
@@ -57,6 +57,7 @@ export class BotExecution implements Execution {
|
||||
}
|
||||
|
||||
this.behavior.handleAllianceRequests();
|
||||
this.behavior.handleAllianceExtensionRequests();
|
||||
this.maybeAttack();
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user