Show the printed price when you are the only buyer left (#167)
In the shuffled decks a plant's extra copies are numbered 13.1 / 13.2, and the sole-buyer confirmation used that number as the price, so it asked "Buy Power Plant 13 (Deck 1) for $13.1?". The engine already charges the printed number (Math.floor), so only the dialog was wrong. Round it down the same way; the Recharged $1 discount plant is unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b06e7f3e66
commit
ed4738e2ea
2 changed files with 30 additions and 3 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
26
viewer/tests/unit/sole-buyer-price.spec.ts
Normal file
26
viewer/tests/unit/sole-buyer-price.spec.ts
Normal file
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue