ports increase in price, NPC attack more frequently, tradeship destroyed if dst port destroyed or captured

This commit is contained in:
Evan
2024-11-24 21:03:09 -08:00
parent 5431aff30c
commit 0b062179ac
10 changed files with 35 additions and 52 deletions
+6 -25
View File
@@ -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()
}
}
}
+1 -1
View File
@@ -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) {
+6 -7
View File
@@ -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())