diff --git a/viewer/src/components/Game.vue b/viewer/src/components/Game.vue index 1213e4b..488663f 100644 --- a/viewer/src/components/Game.vue +++ b/viewer/src/components/Game.vue @@ -1993,15 +1993,16 @@ export default class Game extends Vue { return remaining.length === 1 && remaining[0].id === this.player; } - // Minimum price the sole buyer pays: the plant number, or $1 for the recharged - // discount plant (the cheapest in the market) — mirrors the engine's minimum bid. + // Minimum price the sole buyer pays: the printed plant number, or $1 for the recharged + // discount plant (the cheapest in the market) — mirrors the engine's minimum bid. The + // shuffled decks number their extra copies 13.1 / 13.2, which still cost $13. soleBuyerPrice(): number { if (!this.soleBuyerPlant) return 0; const discounted = this.G!.options.variant === 'recharged' && this.G!.plantDiscountActive && this.G!.actualMarket[0]?.number === this.soleBuyerPlant.number; - return discounted ? 1 : this.soleBuyerPlant.number; + return discounted ? 1 : Math.floor(this.soleBuyerPlant.number); } confirmSoleBuyerPurchase() { diff --git a/viewer/tests/unit/sole-buyer-price.spec.ts b/viewer/tests/unit/sole-buyer-price.spec.ts new file mode 100644 index 0000000..283b748 --- /dev/null +++ b/viewer/tests/unit/sole-buyer-price.spec.ts @@ -0,0 +1,26 @@ +import Game from '@/components/Game.vue'; +import { expect } from 'chai'; + +const options = (Game as any).options; +const price = (number: number, { variant = 'recharged', discount = false, cheapest = 3 } = {}) => + options.methods.soleBuyerPrice.call({ + soleBuyerPlant: { number }, + G: { options: { variant }, plantDiscountActive: discount, actualMarket: [{ number: cheapest }] }, + }); + +describe('sole buyer price', () => { + it('charges the printed number for the shuffled decks’ extra copies', () => { + expect(price(13.1)).to.equal(13); + expect(price(7.2)).to.equal(7); + expect(price(13)).to.equal(13); + }); + + it('still charges $1 for the recharged discount plant, whichever copy it is', () => { + expect(price(6.1, { discount: true, cheapest: 6.1 })).to.equal(1); + expect(price(6.1, { variant: 'original', discount: true, cheapest: 6.1 })).to.equal(6); + }); + + it('is $0 with no plant chosen', () => { + expect(options.methods.soleBuyerPrice.call({ soleBuyerPlant: null })).to.equal(0); + }); +});