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 -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())