Require sealed challengers to bid above the base price
This commit is contained in:
parent
42e27f2d58
commit
c9377b0a30
6 changed files with 32 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "outpost-engine",
|
||||
"version": "0.10.12",
|
||||
"version": "0.10.13",
|
||||
"description": "Unofficial Outpost rules engine for boardgamers.space",
|
||||
"license": "AGPL-3.0",
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ export function chooseMove(state: GameState, seat: number): Move {
|
|||
return chooseExchange(state, seat, player);
|
||||
case "auction": {
|
||||
const auction = state.auction;
|
||||
// fastBid: bid the max affordable when the list price is reachable,
|
||||
// fastBid: bid the max affordable when the list price can be exceeded,
|
||||
// otherwise pass (the sealed bid keeps a weak hand hidden).
|
||||
if (auction?.bids) {
|
||||
const max = handValue(player) + (auction.upgrade ? upgradeDiscount(player, auction.upgrade) : 0);
|
||||
if (max >= auctionCard(auction).price) {
|
||||
if (max > auctionCard(auction).price) {
|
||||
return { action: "bid", amount: max };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,3 +374,23 @@ test("fastBid: auto-pass replays identically from a stripped log", () => {
|
|||
assert.equal(replayed.auction?.highBidder, strong);
|
||||
assert.equal(replayed.auction?.highBid, 26);
|
||||
});
|
||||
|
||||
test("fastBid: other bidders must exceed the base price", () => {
|
||||
const state = fastGame();
|
||||
const opener = open(state);
|
||||
const second = seatAfter(state, opener);
|
||||
const before = structuredClone(state);
|
||||
assert.throws(() => applyMove(state, { action: "bid", amount: 25 }, second), /at least 26/);
|
||||
assert.deepEqual(state, before);
|
||||
applyMove(state, { action: "bid", amount: 26 }, second);
|
||||
assert.equal(state.auction?.bids?.[second], 26);
|
||||
});
|
||||
|
||||
test("fastBid: a public maximum equal to base price auto-passes", () => {
|
||||
const state = fastGame();
|
||||
const opener = state.activeSeat;
|
||||
const second = seatAfter(state, opener);
|
||||
state.players[second]!.hand = Array.from({ length: 5 }, () => ({ t: "ore", v: 5 }));
|
||||
open(state);
|
||||
assert.equal(state.auction?.bids?.[second], 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -658,7 +658,7 @@ function moveBidPass(state: GameState, _move: Move & { action: "bidPass" }, seat
|
|||
}
|
||||
|
||||
/**
|
||||
* Auto-pass the seats that cannot reach a fast auction's list price. The
|
||||
* Auto-pass the seats that cannot exceed a fast auction's list price. The
|
||||
* public bound (each card worth its deck max — public information) always
|
||||
* applies; the true hand value is only consulted for seats that opted into
|
||||
* autoPassBids, and both are recorded in the move's info.autoPassed and
|
||||
|
|
@ -670,7 +670,7 @@ function fastAutoPass(state: GameState, auction: NonNullable<GameState["auction"
|
|||
if (!bids) {
|
||||
return [];
|
||||
}
|
||||
const price = auctionPrice(auction);
|
||||
const price = auctionPrice(auction) + 1;
|
||||
const seats = replayMode
|
||||
? replayAutoPassed
|
||||
: state.players.flatMap((p, seat) => {
|
||||
|
|
@ -719,8 +719,8 @@ function moveFastBid(
|
|||
// placeholder (the resolution comes from the recorded MoveInfo) and skips
|
||||
// validation, which the server already did live.
|
||||
if (!replayMode) {
|
||||
if (!Number.isInteger(move.amount) || move.amount < auctionPrice(auction)) {
|
||||
err(`bid must be at least ${auctionPrice(auction)}`);
|
||||
if (!Number.isInteger(move.amount) || move.amount < auctionPrice(auction) + 1) {
|
||||
err(`bid must be at least ${auctionPrice(auction) + 1}`);
|
||||
}
|
||||
assertCanPayBidFor(player, auction, move.amount);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
);
|
||||
const due = $derived(store.auctionDue());
|
||||
const fast = $derived(store.fastBid);
|
||||
const minBid = $derived(fast ? (spec?.price ?? 0) : (auction?.highBid ?? 0) + 1);
|
||||
const minBid = $derived(fast ? (spec?.price ?? 0) + 1 : (auction?.highBid ?? 0) + 1);
|
||||
const maxBid = $derived(store.maxBid);
|
||||
const pendingNames = $derived(store.fastBidPending.map(nameOf).join(", "));
|
||||
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
{#if store.myBidTurn}
|
||||
{#if maxBid < minBid}
|
||||
<div class="controls">
|
||||
<span class="cantbid">You can't match the list price (your max is ◈ {maxBid}).</span>
|
||||
<span class="cantbid">Minimum bid is ◈ {minBid}; your maximum is ◈ {maxBid}.</span>
|
||||
<button class="confirm" onclick={() => store.passBid()}>Pass</button>
|
||||
</div>
|
||||
{:else}
|
||||
|
|
|
|||
|
|
@ -769,7 +769,7 @@ export class ViewerStore {
|
|||
return;
|
||||
}
|
||||
// fastBid: the floor is the list price, not the (hidden) high bid.
|
||||
this.bidAmount = s.auction.bids ? auctionCard(s.auction).price : s.auction.highBid + 1;
|
||||
this.bidAmount = s.auction.bids ? auctionCard(s.auction).price + 1 : s.auction.highBid + 1;
|
||||
}
|
||||
|
||||
/** Clamp a typed bid into [min, maxBid] so the input never holds an unaffordable/illegal value. */
|
||||
|
|
@ -778,7 +778,7 @@ export class ViewerStore {
|
|||
if (!s?.auction || !Number.isFinite(value)) {
|
||||
return;
|
||||
}
|
||||
const min = s.auction.bids ? auctionCard(s.auction).price : s.auction.highBid + 1;
|
||||
const min = s.auction.bids ? auctionCard(s.auction).price + 1 : s.auction.highBid + 1;
|
||||
this.bidAmount = Math.min(this.maxBid, Math.max(min, Math.floor(value)));
|
||||
}
|
||||
|
||||
|
|
@ -788,7 +788,7 @@ export class ViewerStore {
|
|||
return;
|
||||
}
|
||||
const amount = Math.floor(this.bidAmount);
|
||||
const min = s.auction.bids ? auctionCard(s.auction).price : s.auction.highBid + 1;
|
||||
const min = s.auction.bids ? auctionCard(s.auction).price + 1 : s.auction.highBid + 1;
|
||||
if (!Number.isInteger(amount) || amount < min || amount > this.maxBid) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue