mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:30:43 +00:00
bots don't attack allies
This commit is contained in:
@@ -115,6 +115,7 @@
|
||||
* game mobile friendly DONE 9/16/2024
|
||||
* UI: basic win condition & popup DONE 9/16/2024
|
||||
* right click popup alliance option
|
||||
* BUG: can't ally same person twice
|
||||
* make fake humans easier
|
||||
* click alliance sends alliance request
|
||||
* notification for alliance request
|
||||
|
||||
@@ -64,7 +64,11 @@ export class BotExecution implements Execution {
|
||||
|
||||
const toAttack = border[this.random.nextInt(0, border.length)]
|
||||
const owner = toAttack.owner()
|
||||
|
||||
if (owner.isPlayer()) {
|
||||
if (this.bot.alliedWith(owner)) {
|
||||
return
|
||||
}
|
||||
if (owner.type() == PlayerType.FakeHuman) {
|
||||
if (!this.random.chance(2)) {
|
||||
return
|
||||
|
||||
@@ -138,6 +138,7 @@ export interface Player {
|
||||
incomingAllianceRequests(): AllianceRequest[]
|
||||
outgoingAllianceRequests(): AllianceRequest[]
|
||||
alliances(): Alliance[]
|
||||
alliedWith(other: Player): boolean
|
||||
toString(): string
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,11 @@ export class PlayerImpl implements MutablePlayer {
|
||||
return this.gs.alliances_.filter(a => a.requestor() == this || a.recipient() == this)
|
||||
}
|
||||
|
||||
alliedWith(other: Player): boolean {
|
||||
return this.alliances().find(a => a.recipient() == other || a.requestor() == other) != null
|
||||
}
|
||||
|
||||
|
||||
hash(): number {
|
||||
return simpleHash(this.id()) * (this.troops() + this.numTilesOwned());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user