mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-24 01:53:37 +00:00
ports increase in price, NPC attack more frequently, tradeship destroyed if dst port destroyed or captured
This commit is contained in:
@@ -61,11 +61,7 @@ export class FakeHumanExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.player.troops() < this.mg.config().maxPopulation(this.player) / 4) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ticks % this.random.nextInt(10, 30) != 0) {
|
||||
if (ticks % this.random.nextInt(40, 80) != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -142,7 +138,7 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
|
||||
if (this.enemy) {
|
||||
if (this.player.sharesBorderWith(this.enemy)) {
|
||||
if (this.player.sharesBorderWith(this.enemy) && !this.player.isAlliedWith(this.enemy)) {
|
||||
this.sendAttack(this.enemy)
|
||||
}
|
||||
return
|
||||
@@ -151,7 +147,7 @@ export class FakeHumanExecution implements Execution {
|
||||
}
|
||||
|
||||
private handleUnits() {
|
||||
if (this.player.units(UnitType.Port).length == 0 && this.player.gold() > this.mg.unitInfo(UnitType.Port).cost) {
|
||||
if (this.player.units(UnitType.Port).length == 0 && this.player.gold() > this.mg.unitInfo(UnitType.Port).cost(this.player)) {
|
||||
const oceanTiles = Array.from(this.player.borderTiles()).filter(t => t.isOceanShore())
|
||||
if (oceanTiles.length > 0) {
|
||||
const buildTile = this.random.randElement(oceanTiles)
|
||||
@@ -162,25 +158,10 @@ export class FakeHumanExecution implements Execution {
|
||||
|
||||
handleAllianceRequests() {
|
||||
for (const req of this.player.incomingAllianceRequests()) {
|
||||
|
||||
if (req.requestor().numTilesOwned() > this.player.numTilesOwned() * 2) {
|
||||
req.accept()
|
||||
continue
|
||||
}
|
||||
if (req.recipient().numTilesOwned() > this.player.numTilesOwned()) {
|
||||
if (this.random.chance(2)) {
|
||||
req.accept()
|
||||
} else {
|
||||
req.reject()
|
||||
this.rejected.add(req.recipient())
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (this.random.chance(5)) {
|
||||
req.accept()
|
||||
} else {
|
||||
if (req.requestor().isTraitor() || req.requestor().alliances().length >= 3) {
|
||||
req.reject()
|
||||
this.rejected.add(req.recipient())
|
||||
} else {
|
||||
req.accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export class PortExecution implements Execution {
|
||||
|
||||
const portConnections = Array.from(this.portPaths.keys())
|
||||
|
||||
if (portConnections.length > 0 && this.random.chance(250 * this.player().units(UnitType.Port).length)) {
|
||||
if (portConnections.length > 0 && this.random.chance(250)) {
|
||||
const port = this.random.randElement(portConnections)
|
||||
const path = this.portPaths.get(port)
|
||||
if (path != null) {
|
||||
|
||||
@@ -44,6 +44,11 @@ export class TradeShipExecution implements Execution {
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
if (!this.dstPort.isActive() || !this.tradeShip.owner().isAlliedWith(this.dstPort.owner())) {
|
||||
this.tradeShip.delete()
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
|
||||
if (this.origOwner != this.tradeShip.owner()) {
|
||||
// Store as vairable in case ship is recaptured by previous owner
|
||||
@@ -82,17 +87,11 @@ export class TradeShipExecution implements Execution {
|
||||
}
|
||||
return
|
||||
}
|
||||
if(!this.dstPort.isActive() || !this.tradeShip.owner().isAlliedWith(this.dstPort.owner())) {
|
||||
this.tradeShip.delete()
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (this.index >= this.path.length) {
|
||||
this.active = false
|
||||
const dist = manhattanDist(this.srcPort.tile().cell(), this.dstPort.tile().cell())
|
||||
const gold = dist * dist
|
||||
const gold = this.mg.config().tradeShipGold(this.srcPort, this.dstPort)
|
||||
this.srcPort.owner().addGold(gold)
|
||||
this.dstPort.owner().addGold(gold)
|
||||
this.mg.displayMessage(`Trade ship from ${this.tradeShip.owner().displayName()} has reached your port, giving you ${renderNumber(gold)} gold`, MessageType.SUCCESS, this.dstPort.owner().id())
|
||||
|
||||
Reference in New Issue
Block a user