Players can select a non-allied recipient and explicitly pay a whole-spice bribe outside Mentat and open decision/response windows. The server derives private payment limits from uncommitted spice and existing joint Truthtrance completion checks on isolated copies. Target-specific Bureaucrat guards preserve supported redirect/allow continuations. Reserved bids, sealed spending and incoming escrow cannot be spent twice. No strategic AI negotiation or mode/publication changes. The panel separates deferred incoming bribes from spendable supply, disables stale/invalid selections and uses existing request/version fencing. The chronicle now describes actual payment and next-Mentat spendability rather than a promise. Internal guidance and the implementation checklist record this boundary. The separate Emperor gift/Bureaucrat source ambiguity remains explicitly pending. Independent review found no material issue. Focused tests cover out-of-turn payment, JSON escrow/collection, private budgets, invalid targets/amounts, phase/response gates, reserved bids, joint promises, supported redirection and rendered controls. Existing Bureaucrat SQLite/all-four legal response tests pass. The new HTTP test races duplicate submissions and verifies one debit, refreshed private balances and stale/over-budget rejection. Types, lint, all 4968 offline tests, production build and 49 HTTP tests pass on stable source. Preliminary checks caught a typed fixture opener and semantic-status/internal-link/template lint requirements and the new SSR test needed the existing Vinext Link alias. All were corrected before the final4 run. Browser QA used genuine fresh Basic setup with a human payer and Easy AI recipient: 11 rejected by controls, 4 paid from10 leaving6, one public payment entry and unchanged recipient spendable10 with4 in escrow after refresh. Keyboard selection and amount access passed. At390px the panel fits with16px text and44px-or-larger controls; linked rules and back navigation work. Screenshot capture timed out; full visual/assistive and all-configuration acceptance remain open. Browser transport loss was not injected; HTTP concurrency is separately covered. This is playability evidence, not difficulty calibration. All 1418 original rooms, 2991 seats and auxiliary rows are unchanged. SQLite integrity and foreign keys pass. The healthy server was reused without restart, migration, reset or recurring maintenance. Private evidence: 20260921-bribe-controls. Verified source tree: b9a8594c5dcd85f78974c9647f24f5f6eba60a38c9dcd2badcf4529d1e825ae1
54 lines
3.3 KiB
TypeScript
54 lines
3.3 KiB
TypeScript
'use client';
|
|
import { useId, useState } from 'react';
|
|
import Link from 'next/link';
|
|
import type { Action, GameView } from '@/game/engine';
|
|
import { bribeAction } from '@/game/bribe-options';
|
|
import { faction } from '@/game/catalog';
|
|
import { Button } from '@/components/ui/button';
|
|
|
|
export function Bribes({ game: g, act, busy }: {
|
|
game: GameView; act: (action: Action) => void; busy: boolean;
|
|
}) {
|
|
const [target, setTarget] = useState('');
|
|
const [amount, setAmount] = useState('1');
|
|
const description = useId();
|
|
if (g.status !== 'playing') return null;
|
|
const options = g.bribeOptions;
|
|
const recipient = options.targets.find(candidate => candidate.id === target);
|
|
const player = recipient && g.players.find(candidate => candidate.id === recipient.id);
|
|
const action = bribeAction(options, target, Number(amount));
|
|
return (
|
|
<details className="notice bribe-panel">
|
|
<summary>Bribes{options.incoming > 0 ? ` · ${options.incoming} spice awaiting Mentat` : ''}</summary>
|
|
<p id={description}>Pay another non-allied faction now. The amount is public; the recipient can spend their share only from the next Mentat Pause. A message or promise alone does not pay spice.</p>
|
|
<p>Your incoming bribes: <strong>{options.incoming} spice</strong>, separate from your spendable supply.</p>
|
|
{options.blocked ? <output className="bribe-status">{options.blocked}</output> : null}
|
|
{options.targets.length === 0 ? <p>No non-allied recipient is available.</p> : (
|
|
<div className="bribe-fields">
|
|
<label>Bribe recipient
|
|
<select value={recipient ? target : ''} onChange={event => setTarget(event.target.value)} disabled={busy || !!options.blocked}>
|
|
<option value="">Choose a faction</option>
|
|
{options.targets.map(candidate => {
|
|
const seat = g.players.find(player => player.id === candidate.id)!;
|
|
return <option key={seat.id} value={seat.id}>{seat.name} · {faction(seat.faction).name}</option>;
|
|
})}
|
|
</select>
|
|
</label>
|
|
<label>Bribe amount
|
|
<input type="number" inputMode="numeric" min={1} max={recipient?.maximum ?? options.available}
|
|
step={1} value={amount} onChange={event => setAmount(event.target.value)}
|
|
disabled={busy || !!options.blocked || !recipient} aria-describedby={description} />
|
|
</label>
|
|
<Button className="game-action" disabled={busy || !action} onClick={() => { if (action) act(action); }}>
|
|
{player && action ? `Pay ${Number(amount)} spice to ${player.name}` : 'Pay bribe'}
|
|
</Button>
|
|
</div>
|
|
)}
|
|
<p>{recipient ? `You may pay up to ${recipient.maximum} spice to this recipient.` : `Uncommitted spice: ${options.available}. Choose a recipient to see the payment limit.`}</p>
|
|
{recipient?.limitation ? <p>{recipient.limitation}</p> : null}
|
|
{recipient && !options.blocked && !action ? <output className="bribe-status">{recipient.maximum < 1 ? 'No spice is available for this payment.' : `Enter a whole number from 1 to ${recipient.maximum}.`}</output> : null}
|
|
<p>Eligible Bureaucrats may divert two spice to the Bank. AI opponents can receive spice, but do not negotiate deals yet. <Link href="/rules?topic=bribes#bribes">Bribe rules</Link></p>
|
|
</details>
|
|
);
|
|
}
|