mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 11:08:10 +00:00
have playerexecution check & delete units on death. fixes bug where units weren't being captured when player dies
This commit is contained in:
@@ -190,14 +190,14 @@
|
||||
* make two nukes: atom & hydrogen DONE 11/20/2024
|
||||
* NPC builds ports DONE 11/20/2024
|
||||
* BUG: fix matchmaking DONE 11/22/2024
|
||||
* destroyer can capture trade ships
|
||||
* destroyer can capture trade ships DONE 11/22/2024
|
||||
* NPC has relations
|
||||
* make NPC difficult scale better (not just start troops)
|
||||
* add battleship
|
||||
* add defense post
|
||||
* add radiation from nuke
|
||||
* only show units you can build in the build menu
|
||||
* REFACTOR: make TransportShip follow build unit flow
|
||||
* NPC has relations
|
||||
* use twitter emojis
|
||||
* private game shows how many players joined
|
||||
* optimize sendBoat function
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DefaultConfig } from "./DefaultConfig";
|
||||
export const devConfig = new class extends DefaultConfig {
|
||||
unitInfo(type: UnitType): UnitInfo {
|
||||
const info = super.unitInfo(type)
|
||||
info.cost = 100
|
||||
info.cost = 0
|
||||
return info
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export class PlayerExecution implements Execution {
|
||||
private config: Config
|
||||
private lastCalc = 0
|
||||
private mg: MutableGame
|
||||
private active = true
|
||||
|
||||
constructor(private playerID: PlayerID) {
|
||||
}
|
||||
@@ -30,8 +31,28 @@ export class PlayerExecution implements Execution {
|
||||
if (ticks < this.config.numSpawnPhaseTurns()) {
|
||||
return
|
||||
}
|
||||
const popInc = this.config.populationIncreaseRate(this.player)
|
||||
|
||||
this.player.units().forEach(u => {
|
||||
const tileOwner = u.tile().owner()
|
||||
if (u.info().territoryBound) {
|
||||
if (tileOwner.isPlayer()) {
|
||||
if (tileOwner != this.player) {
|
||||
this.mg.player(tileOwner.id()).captureUnit(u)
|
||||
}
|
||||
} else {
|
||||
u.delete()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!this.player.isAlive()) {
|
||||
this.player.units().forEach(u => u.delete())
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const popInc = this.config.populationIncreaseRate(this.player)
|
||||
this.player.addWorkers(popInc * (1 - this.player.targetTroopRatio()))// (1 - this.player.targetTroopRatio()))
|
||||
this.player.addTroops(popInc * this.player.targetTroopRatio())
|
||||
this.player.addGold(this.config.goldAdditionRate(this.player))
|
||||
@@ -46,20 +67,6 @@ export class PlayerExecution implements Execution {
|
||||
}
|
||||
}
|
||||
|
||||
this.player.units().forEach(u => {
|
||||
const tileOwner = u.tile().owner()
|
||||
if (u.info().territoryBound) {
|
||||
if (tileOwner.isPlayer()) {
|
||||
if (tileOwner != this.player) {
|
||||
this.mg.player(tileOwner.id()).captureUnit(u)
|
||||
}
|
||||
} else {
|
||||
u.delete()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
if (ticks - this.lastCalc > this.ticksPerClusterCalc) {
|
||||
this.lastCalc = ticks
|
||||
@@ -187,6 +194,6 @@ export class PlayerExecution implements Execution {
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.player == null || this.player.isAlive()
|
||||
return this.active
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user