mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 13:52:45 +00:00
Refactor attack rate
This commit is contained in:
@@ -13,12 +13,14 @@ export class BotExecution implements Execution {
|
||||
private active = true;
|
||||
private random: PseudoRandom;
|
||||
private attackRate: number;
|
||||
private attackTick: number;
|
||||
private mg: Game;
|
||||
private neighborsTerraNullius = true;
|
||||
|
||||
constructor(private bot: Player) {
|
||||
this.random = new PseudoRandom(simpleHash(bot.id()));
|
||||
this.attackRate = this.random.nextInt(10, 50);
|
||||
this.attackTick = this.random.nextInt(0, this.attackRate - 1);
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
@@ -36,9 +38,7 @@ export class BotExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ticks % this.attackRate != 0) {
|
||||
return;
|
||||
}
|
||||
if (ticks % this.attackRate != this.attackTick) return;
|
||||
|
||||
this.bot.incomingAllianceRequests().forEach((ar) => {
|
||||
if (ar.requestor().isTraitor()) {
|
||||
|
||||
@@ -44,6 +44,9 @@ export class FakeHumanExecution implements Execution {
|
||||
private lastNukeSent: [Tick, TileRef][] = [];
|
||||
private embargoMalusApplied = new Set<PlayerID>();
|
||||
|
||||
private attackRate: number;
|
||||
private attackTick: number;
|
||||
|
||||
constructor(
|
||||
gameID: GameID,
|
||||
private playerInfo: PlayerInfo,
|
||||
@@ -51,6 +54,8 @@ export class FakeHumanExecution implements Execution {
|
||||
this.random = new PseudoRandom(
|
||||
simpleHash(playerInfo.id) + simpleHash(gameID),
|
||||
);
|
||||
this.attackRate = this.random.nextInt(40, 80);
|
||||
this.attackTick = this.random.nextInt(0, this.attackRate - 1);
|
||||
}
|
||||
|
||||
init(mg: Game, ticks: number) {
|
||||
@@ -128,9 +133,7 @@ export class FakeHumanExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ticks % this.random.nextInt(40, 80) != 0) {
|
||||
return;
|
||||
}
|
||||
if (ticks % this.attackRate != this.attackTick) return;
|
||||
|
||||
if (
|
||||
this.player.troops() > 100_000 &&
|
||||
|
||||
Reference in New Issue
Block a user