mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-15 15:06:08 +00:00
Merge branch 'main' into meta3
This commit is contained in:
@@ -4,9 +4,9 @@ import {
|
||||
Difficulty,
|
||||
Execution,
|
||||
Game,
|
||||
Nation,
|
||||
Player,
|
||||
PlayerID,
|
||||
PlayerInfo,
|
||||
PlayerType,
|
||||
Relation,
|
||||
TerrainType,
|
||||
@@ -43,6 +43,8 @@ export class FakeHumanExecution implements Execution {
|
||||
private lastEmojiSent = new Map<Player, Tick>();
|
||||
private lastNukeSent: [Tick, TileRef][] = [];
|
||||
private embargoMalusApplied = new Set<PlayerID>();
|
||||
private heckleEmoji: number[];
|
||||
private dogpileEmoji: number;
|
||||
|
||||
private portTargetRatio: number = 0.00005; // desired ports per tile
|
||||
private cityTargetRatio: number = 0.0001; // desired cities per tile
|
||||
@@ -57,10 +59,10 @@ export class FakeHumanExecution implements Execution {
|
||||
|
||||
constructor(
|
||||
gameID: GameID,
|
||||
private playerInfo: PlayerInfo,
|
||||
private nation: Nation,
|
||||
) {
|
||||
this.random = new PseudoRandom(
|
||||
simpleHash(playerInfo.id) + simpleHash(gameID),
|
||||
simpleHash(nation.playerInfo.id) + simpleHash(gameID),
|
||||
);
|
||||
this.attackRate = this.random.nextInt(40, 80);
|
||||
this.attackTick = this.random.nextInt(0, this.attackRate);
|
||||
@@ -124,15 +126,17 @@ export class FakeHumanExecution implements Execution {
|
||||
if (this.mg.inSpawnPhase()) {
|
||||
const rl = this.randomLand();
|
||||
if (rl == null) {
|
||||
consolex.warn(`cannot spawn ${this.playerInfo.name}`);
|
||||
consolex.warn(`cannot spawn ${this.nation.playerInfo.name}`);
|
||||
return;
|
||||
}
|
||||
this.mg.addExecution(new SpawnExecution(this.playerInfo, rl));
|
||||
this.mg.addExecution(new SpawnExecution(this.nation.playerInfo, rl));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.player == null) {
|
||||
this.player = this.mg.players().find((p) => p.id() == this.playerInfo.id);
|
||||
this.player = this.mg
|
||||
.players()
|
||||
.find((p) => p.id() == this.nation.playerInfo.id);
|
||||
if (this.player == null) {
|
||||
return;
|
||||
}
|
||||
@@ -303,7 +307,7 @@ export class FakeHumanExecution implements Execution {
|
||||
if (!this.lastEmojiSent.has(enemy)) {
|
||||
this.lastEmojiSent.set(enemy, this.mg.ticks());
|
||||
this.mg.addExecution(
|
||||
new EmojiExecution(this.player.id(), enemy.id(), "🖕"),
|
||||
new EmojiExecution(this.player.id(), enemy.id(), this.dogpileEmoji),
|
||||
);
|
||||
}
|
||||
return;
|
||||
@@ -317,7 +321,7 @@ export class FakeHumanExecution implements Execution {
|
||||
new EmojiExecution(
|
||||
this.player.id(),
|
||||
enemy.id(),
|
||||
this.random.randElement(["🤡", "😡"]),
|
||||
this.random.randElement(this.heckleEmoji),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -632,7 +636,7 @@ export class FakeHumanExecution implements Execution {
|
||||
|
||||
if (!builtDefensePost) {
|
||||
consolex.log(
|
||||
`[${this.playerInfo.name}] no valid tile found for Defense Post`,
|
||||
`[${this.nation.playerInfo.name}] no valid tile found for Defense Post`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -825,7 +829,7 @@ export class FakeHumanExecution implements Execution {
|
||||
let tries = 0;
|
||||
while (tries < 50) {
|
||||
tries++;
|
||||
const cell = this.playerInfo.nation.cell;
|
||||
const cell = this.nation.spawnCell;
|
||||
const x = this.random.nextInt(cell.x - delta, cell.x + delta);
|
||||
const y = this.random.nextInt(cell.y - delta, cell.y + delta);
|
||||
if (!this.mg.isValidCoord(x, y)) {
|
||||
|
||||
Reference in New Issue
Block a user