mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 08:11:54 +00:00
make manpower addition rate function of total manpower
This commit is contained in:
@@ -15,7 +15,7 @@ export class ControlPanel extends LitElement implements Layer {
|
|||||||
public uiState: UIState
|
public uiState: UIState
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
private attackRatio: number = .2;
|
private targetTroopRatio = 50;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
private _troops: number;
|
private _troops: number;
|
||||||
@@ -67,7 +67,7 @@ export class ControlPanel extends LitElement implements Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
targetTroops(): number {
|
targetTroops(): number {
|
||||||
return this._maxTroops * this.attackRatio
|
return this._manpower * this.targetTroopRatio / 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,11 +134,11 @@ export class ControlPanel extends LitElement implements Layer {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider-container">
|
<div class="slider-container">
|
||||||
<label for="numTroops">Attack Ratio: ${this.attackRatio * 100}%</label>
|
<label for="numTroops">Troops: ${this.targetTroopRatio}% (${renderTroops(this.targetTroops()) + ", delta: " + renderTroops(this.delta())})</label>
|
||||||
<input type="range" id="numTroops" min="1" max="10" value=${this.attackRatio * 10}
|
<input type="range" id="numTroops" min="0" max="100" .value=${this.targetTroopRatio}
|
||||||
@input=${(e: Event) => {
|
@input=${(e: Event) => {
|
||||||
this.attackRatio = parseInt((e.target as HTMLInputElement).value) / 10;
|
this.targetTroopRatio = parseInt((e.target as HTMLInputElement).value);
|
||||||
this.onAttackRatioChange(this.attackRatio);
|
this.onTroopChange(this.targetTroopRatio / 100);
|
||||||
}}>
|
}}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -132,19 +132,19 @@ export class DefaultConfig implements Config {
|
|||||||
|
|
||||||
maxManpower(player: Player): number {
|
maxManpower(player: Player): number {
|
||||||
let max = Math.sqrt(player.numTilesOwned()) * 3000 + 50000
|
let max = Math.sqrt(player.numTilesOwned()) * 3000 + 50000
|
||||||
const troops = Math.min(max, 2_000_000)
|
const manpower = Math.min(max, 2_000_000)
|
||||||
if (player.type() == PlayerType.Bot) {
|
if (player.type() == PlayerType.Bot) {
|
||||||
return troops
|
return manpower
|
||||||
}
|
}
|
||||||
return troops * 2
|
return manpower * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
manpowerAdditionRate(player: Player): number {
|
manpowerAdditionRate(player: Player): number {
|
||||||
let max = this.maxManpower(player)
|
let max = this.maxManpower(player)
|
||||||
|
|
||||||
let toAdd = 10 + (player.manpowerReserve() + Math.sqrt(player.manpowerReserve() * player.numTilesOwned())) / 100
|
let toAdd = 10 + (player.totalManpower() + Math.sqrt(player.totalManpower() * player.numTilesOwned())) / 100
|
||||||
|
|
||||||
const ratio = 1 - (player.manpowerReserve() / max)
|
const ratio = 1 - (player.totalManpower() / max)
|
||||||
toAdd *= ratio
|
toAdd *= ratio
|
||||||
toAdd *= .5
|
toAdd *= .5
|
||||||
// console.log(`to add ${toAdd}`)
|
// console.log(`to add ${toAdd}`)
|
||||||
@@ -158,7 +158,7 @@ export class DefaultConfig implements Config {
|
|||||||
return toAdd
|
return toAdd
|
||||||
}
|
}
|
||||||
goldAdditionRate(player: Player): number {
|
goldAdditionRate(player: Player): number {
|
||||||
return player.numTilesOwned() / 100
|
return (player.manpowerReserve() - player.troops()) / 1000
|
||||||
}
|
}
|
||||||
troopAdjustmentRate(player: Player): number {
|
troopAdjustmentRate(player: Player): number {
|
||||||
const maxDiff = player.totalManpower() / 250 + this.manpowerAdditionRate(player)
|
const maxDiff = player.totalManpower() / 250 + this.manpowerAdditionRate(player)
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ export class PlayerExecution implements Execution {
|
|||||||
}
|
}
|
||||||
this.player.addManpowerReserve(this.config.manpowerAdditionRate(this.player))
|
this.player.addManpowerReserve(this.config.manpowerAdditionRate(this.player))
|
||||||
this.player.addGold(this.config.goldAdditionRate(this.player))
|
this.player.addGold(this.config.goldAdditionRate(this.player))
|
||||||
this.player.addTroops(this.config.troopAdjustmentRate(this.player))
|
const adjustRate = this.config.troopAdjustmentRate(this.player)
|
||||||
|
this.player.addTroops(adjustRate)
|
||||||
|
this.player.removeManpowerReserve(adjustRate)
|
||||||
|
|
||||||
const alliances = Array.from(this.player.alliances())
|
const alliances = Array.from(this.player.alliances())
|
||||||
for (const alliance of alliances) {
|
for (const alliance of alliances) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export class PlayerImpl implements MutablePlayer {
|
|||||||
this._targetTroopRatio = .5
|
this._targetTroopRatio = .5
|
||||||
this._troops = manpower * this._targetTroopRatio;
|
this._troops = manpower * this._targetTroopRatio;
|
||||||
this._reserves = manpower * (1 - this._targetTroopRatio)
|
this._reserves = manpower * (1 - this._targetTroopRatio)
|
||||||
this._gold = manpower
|
this._gold = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
name(): string {
|
name(): string {
|
||||||
@@ -292,9 +292,6 @@ export class PlayerImpl implements MutablePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeGold(toRemove: Gold): void {
|
removeGold(toRemove: Gold): void {
|
||||||
if (toRemove > this._gold) {
|
|
||||||
throw Error(`cannot remove ${toRemove} from ${this} because only has ${this._gold}`)
|
|
||||||
}
|
|
||||||
this._gold -= toRemove
|
this._gold -= toRemove
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user