From 61515172c7c897c91c5314b31c878bb57aea6772 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 27 Nov 2024 14:05:47 -0800 Subject: [PATCH] make shells free --- src/core/configuration/DefaultConfig.ts | 2 +- src/core/configuration/DevConfig.ts | 2 +- src/core/game/PlayerImpl.ts | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 44875c2c8..5fd401740 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -36,7 +36,7 @@ export class DefaultConfig implements Config { } case UnitType.Shell: return { - cost: (p: Player) => (p.units(UnitType.Destroyer).length + 1) * 500_000, + cost: (p: Player) => 0, territoryBound: false } case UnitType.Port: diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index dca20c927..ce09d8320 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -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) => 0 * oldCost(p) / 10000 + info.cost = (p: Player) => oldCost(p) / 10 return info } diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index 05c98b08c..dc3e82874 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -278,6 +278,9 @@ export class PlayerImpl implements MutablePlayer { } removeGold(toRemove: Gold): void { + if (toRemove > this._gold) { + throw Error(`Player ${this} does not enough gold (${toRemove} vs ${this._gold}))`) + } this._gold -= toRemove }