make unit cost scale up w/ # units

This commit is contained in:
Evan
2024-11-25 11:42:40 -08:00
parent 5997262416
commit 6fd35b00cd
4 changed files with 8 additions and 9 deletions
+1 -3
View File
@@ -193,12 +193,10 @@
* destroyer can capture trade ships DONE 11/22/2024
* have bots recapture after nuclear blast DONE 11/24/2022
* BUG: destroys destroy trade ships instead of capturing them DONE 11/25/2024
* nukes break alliance
* nukes break alliance DONE 11/25/2024
* don't capture trade ships if allied with either port
* make ports cost more for more ports
* BUG: Destroyers destroy instead of capture trade ships
* NPC has relations
* make NPC difficult scale better (not just start troops)
* add battleship
* add defense post
* add radiation from nuke
+4 -4
View File
@@ -12,7 +12,7 @@ export class DefaultConfig implements Config {
}
tradeShipGold(src: Unit, dst: Unit): Gold {
const dist = manhattanDist(src.tile().cell(), dst.tile().cell())
return 10000 + 50 * dist
return 10000 + 50 * Math.pow(dist, 1.1)
}
unitInfo(type: UnitType): UnitInfo {
switch (type) {
@@ -23,7 +23,7 @@ export class DefaultConfig implements Config {
}
case UnitType.Destroyer:
return {
cost: () => 250_000,
cost: (p: Player) => (p.units(UnitType.Destroyer).length + 1) * 250_000,
territoryBound: false
}
case UnitType.Port:
@@ -48,7 +48,7 @@ export class DefaultConfig implements Config {
}
case UnitType.MissileSilo:
return {
cost: () => 2_500_000,
cost: () => 1_000_000,
territoryBound: true
}
default:
@@ -207,7 +207,7 @@ export class DefaultConfig implements Config {
}
goldAdditionRate(player: Player): number {
return Math.sqrt(player.workers() * player.numTilesOwned()) / 250
return Math.sqrt(player.workers() * player.numTilesOwned()) / 200
}
troopAdjustmentRate(player: Player): number {
+1 -1
View File
@@ -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) / 100
// info.cost = (p: Player) => oldCost(p) / 100
return info
}
+2 -1
View File
@@ -332,9 +332,10 @@ export class PlayerImpl implements MutablePlayer {
}
buildUnit(type: UnitType, troops: number, spawnTile: Tile): UnitImpl {
const cost = this.gs.unitInfo(type).cost(this)
const b = new UnitImpl(type, this.gs, spawnTile, troops, this);
this._units.push(b);
this.removeGold(this.gs.unitInfo(type).cost(this))
this.removeGold(cost)
this.removeTroops(troops)
this.gs.fireUnitUpdateEvent(b, b.tile());
return b;