mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 06:30:42 +00:00
use max troops instead of manpower for addition rate
This commit is contained in:
@@ -161,8 +161,8 @@ export class DefaultConfig implements Config {
|
||||
return (player.manpowerReserve() * 1.2 - player.troops()) / 1000
|
||||
}
|
||||
troopAdjustmentRate(player: Player): number {
|
||||
const maxDiff = player.totalManpower() / 300
|
||||
const target = player.totalManpower() * player.targetTroopRatio()
|
||||
const maxDiff = player.maxTroops() / 300
|
||||
const target = player.maxTroops() * player.targetTroopRatio()
|
||||
const diff = target - player.troops()
|
||||
if (Math.abs(diff) < maxDiff) {
|
||||
return diff
|
||||
|
||||
@@ -30,7 +30,9 @@ export class PlayerExecution implements Execution {
|
||||
if (ticks < this.config.numSpawnPhaseTurns()) {
|
||||
return
|
||||
}
|
||||
|
||||
this.player.addManpowerReserve(this.config.manpowerAdditionRate(this.player))
|
||||
this.player.setMaxTroops(Math.max(this.player.numTilesOwned() * 100, 50000))
|
||||
this.player.addGold(this.config.goldAdditionRate(this.player))
|
||||
const adjustRate = this.config.troopAdjustmentRate(this.player)
|
||||
this.player.addTroops(adjustRate)
|
||||
|
||||
@@ -200,6 +200,7 @@ export interface Player {
|
||||
manpowerReserve(): number
|
||||
// Number between 0, 1
|
||||
targetTroopRatio(): number
|
||||
maxTroops(): number
|
||||
}
|
||||
|
||||
export interface MutablePlayer extends Player {
|
||||
@@ -228,6 +229,7 @@ export interface MutablePlayer extends Player {
|
||||
addManpowerReserve(toAdd: number): void
|
||||
removeManpowerReserve(toRemove: number): void
|
||||
setTargetTroopRatio(target: number): void
|
||||
setMaxTroops(maxTroops: number): void
|
||||
}
|
||||
|
||||
export interface Game {
|
||||
|
||||
@@ -24,6 +24,7 @@ export class PlayerImpl implements MutablePlayer {
|
||||
private _troops: number
|
||||
private _reserves: number
|
||||
private _targetTroopRatio: number
|
||||
private _maxTroops: number
|
||||
|
||||
isTraitor_ = false
|
||||
|
||||
@@ -49,6 +50,7 @@ export class PlayerImpl implements MutablePlayer {
|
||||
this._troops = manpower * this._targetTroopRatio;
|
||||
this._reserves = manpower * (1 - this._targetTroopRatio)
|
||||
this._gold = 0
|
||||
this._maxTroops = 0
|
||||
}
|
||||
|
||||
name(): string {
|
||||
@@ -319,6 +321,13 @@ export class PlayerImpl implements MutablePlayer {
|
||||
this._targetTroopRatio = target
|
||||
}
|
||||
|
||||
maxTroops(): number {
|
||||
return this._maxTroops
|
||||
}
|
||||
setMaxTroops(maxTroops: number): void {
|
||||
this._maxTroops = maxTroops
|
||||
}
|
||||
|
||||
hash(): number {
|
||||
return simpleHash(this.id()) * (this.totalManpower() + this.numTilesOwned());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user