mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 08:44:53 +00:00
only break alliance if more than 100 tiles destroyed on nuke
This commit is contained in:
@@ -5,7 +5,7 @@ export const devConfig = new class extends DefaultConfig {
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
const info = super.unitInfo(type)
|
||||
const oldCost = info.cost
|
||||
// info.cost = (p: Player) => oldCost(p) / 1000
|
||||
info.cost = (p: Player) => oldCost(p) / 1000000
|
||||
return info
|
||||
}
|
||||
maxUnitCost(): number {
|
||||
|
||||
@@ -74,23 +74,29 @@ export class NukeExecution implements Execution {
|
||||
const ratio = Object.fromEntries(
|
||||
this.mg.players().map(p => [p.id(), (p.troops() + p.workers()) / p.numTilesOwned()])
|
||||
)
|
||||
const others = new Set<MutablePlayer>()
|
||||
const attacked = new Map<MutablePlayer, number>()
|
||||
for (const tile of toDestroy) {
|
||||
const owner = tile.owner()
|
||||
if (owner.isPlayer()) {
|
||||
const mp = this.mg.player(owner.id())
|
||||
mp.relinquish(tile)
|
||||
mp.removeTroops(2 * ratio[mp.id()])
|
||||
others.add(mp)
|
||||
if (!attacked.has(mp)) {
|
||||
attacked.set(mp, 0)
|
||||
}
|
||||
const prev = attacked.get(mp)
|
||||
attacked.set(mp, prev + 1)
|
||||
}
|
||||
if (tile.isLand()) {
|
||||
this.mg.addFallout(tile)
|
||||
}
|
||||
}
|
||||
for (const other of others) {
|
||||
const alliance = this.player.allianceWith(other)
|
||||
if (alliance != null) {
|
||||
this.player.breakAlliance(alliance)
|
||||
for (const [other, tilesDestroyed] of attacked) {
|
||||
if (tilesDestroyed > 100) {
|
||||
const alliance = this.player.allianceWith(other)
|
||||
if (alliance != null) {
|
||||
this.player.breakAlliance(alliance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user