increase mirv price with total number of merged launched (#2621)

## Description:

To prevent MAD stalemates, have the price of MIRVs increase after each
launch. This will encourage players to launch a MIRV once they have
enough money for it. Also reduce the price of the first MIRV to 25
million to reduce snowballing, each subsequent MIRV cost an extra 15
million:

1. 25 million
2. 40 million
3. 60 million
4. etc



## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
This commit is contained in:
Evan
2025-12-14 19:52:54 -08:00
committed by GitHub
parent 4f6a433dc8
commit 71cf309252
9 changed files with 84 additions and 33 deletions
+11 -5
View File
@@ -487,7 +487,12 @@ export class DefaultConfig implements Config {
};
case UnitType.MIRV:
return {
cost: this.costWrapper(() => 35_000_000, UnitType.MIRV),
cost: (game: Game, player: Player) => {
if (player.type() === PlayerType.Human && this.infiniteGold()) {
return 0n;
}
return 25_000_000n + game.stats().numMirvsLaunched() * 15_000_000n;
},
territoryBound: false,
};
case UnitType.MIRVWarhead:
@@ -567,14 +572,15 @@ export class DefaultConfig implements Config {
private costWrapper(
costFn: (units: number) => number,
...types: UnitType[]
): (p: Player) => bigint {
return (p: Player) => {
if (p.type() === PlayerType.Human && this.infiniteGold()) {
): (g: Game, p: Player) => bigint {
return (game: Game, player: Player) => {
if (player.type() === PlayerType.Human && this.infiniteGold()) {
return 0n;
}
const numUnits = types.reduce(
(acc, type) =>
acc + Math.min(p.unitsOwned(type), p.unitsConstructed(type)),
acc +
Math.min(player.unitsOwned(type), player.unitsConstructed(type)),
0,
);
return BigInt(costFn(numUnits));