Resolve redacted card removals from public played actions
This commit is contained in:
parent
686d30f485
commit
26d7a2f2b7
6 changed files with 38 additions and 10 deletions
|
|
@ -321,3 +321,5 @@ Viewer 0.1.100 fixes mobile map controls wrapping into a tall block and overlapp
|
|||
Viewer 0.1.101 names publicly played action cards in Since your last turn summaries, retaining resource and other outcomes. It resolves the card from the frame's public Playing ActionCard log entry and the public catalog; drawn/hidden cards are never used to infer a name. Checked replay tests and existing public game-history examples. Engine remains 0.4.78.
|
||||
|
||||
Viewer 0.1.102 / engine 0.4.79 labels Spies hand choices by current owner, including the opponent whose hand remains redacted in public state. Mixed hands are grouped by civilization and card type while preserving original selection indices. Objective choices show progress for their current owner and end-of-age condition status. Checked ownership/progress against both owners' private views, lack of choice exposure to the opponent, and desktop/mobile layouts.
|
||||
|
||||
Viewer 0.1.103 fixes journal “Action card · Card 0” entries. Redacted card-removal records now use the same actor's public Playing ActionCard ID for the name and exact-card link. Genuinely hidden discards stay generic. Verified the reported game's history for all three seats and regression coverage for redacted plays versus hidden discards. Engine remains 0.4.79.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.102",
|
||||
"version": "0.1.103",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.102",
|
||||
"version": "0.1.103",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.102",
|
||||
"version": "0.1.103",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { readableHistory } from './structured-log.ts';
|
||||
import { readableHistory, playedCardId } from './structured-log.ts';
|
||||
import { activeHistory } from './active-history.ts';
|
||||
import type { Game, JournalEntry, JournalToken, LoggedAction, Pile, Player, Resource } from './types.ts';
|
||||
import type { View } from './types.ts';
|
||||
|
|
@ -393,9 +393,8 @@ export function journal(
|
|||
const name = entry.title.slice('Action card · '.length);
|
||||
const cardIds = (action.items ?? []).filter(item => item.player === entry.player).flatMap(item => {
|
||||
if (typeof item.origin?.CivilCard === 'number') return [item.origin.CivilCard];
|
||||
const hand = item.HandCard;
|
||||
return hand?.to === 'PlayToDiscard' && hand.card && typeof hand.card === 'object' &&
|
||||
'ActionCard' in hand.card && typeof hand.card.ActionCard === 'number' ? [hand.card.ActionCard] : [];
|
||||
const played = playedCardId(action, item);
|
||||
return played === undefined ? [] : [played];
|
||||
});
|
||||
entry.card = view?.cardCatalog?.find(card => cardIds.includes(card.id) && card.name === name);
|
||||
entry.kind = 'card';
|
||||
|
|
|
|||
|
|
@ -67,3 +67,21 @@ test('played action cards and their research results link to the exact public ca
|
|||
assert.ok(!entries.some(entry => entry.title === 'Action Card'));
|
||||
assert.equal(JSON.stringify(game), before);
|
||||
});
|
||||
|
||||
test('redacted card removal resolves the public played card while hidden discards stay unnamed', () => {
|
||||
const game = fixture('action_cards/advance.outcome2');
|
||||
const actions = game.log![0].rounds[0].turns[0].actions!;
|
||||
const played = actions[0];
|
||||
played.items![0].HandCard!.card = {ActionCard:0};
|
||||
const card = {id:2,name:'Advance',description:'Gain an advance.',free:true,tactics:null};
|
||||
const context = {players:[],cardCatalog:[card],logOriginNames:{'{"CivilCard":2}':'Advance'}};
|
||||
let entries = journal(game,context);
|
||||
assert.equal(entries[0].card?.id,2);
|
||||
assert.equal(entries[0].title,'Action card · Advance');
|
||||
assert.ok(!entries.some(entry=>/Card 0/.test(entry.text)));
|
||||
played.action = {Response:{SelectHandCards:[]}};
|
||||
entries = journal(game,context);
|
||||
assert.equal(entries[0].card,undefined);
|
||||
assert.equal(entries[0].title,'Action Card');
|
||||
assert.ok(!entries.some(entry=>/Card 0/.test(entry.text)));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,9 +22,20 @@ const pileText = (pile: Pile): string =>
|
|||
.join(' and ');
|
||||
const actor = (game: Game, player: number): string =>
|
||||
game.players.find((p) => p.id === player)?.name ?? `Player ${player + 1}`;
|
||||
export function playedCardId(action: LoggedAction, item: Item): number | undefined {
|
||||
const hand = item.HandCard;
|
||||
if (hand?.to !== 'PlayToDiscard') return undefined;
|
||||
const card = hand.card;
|
||||
if (card && typeof card === 'object' && 'ActionCard' in card && typeof card.ActionCard === 'number' && card.ActionCard > 0) return card.ActionCard;
|
||||
const playing = typeof action.action === 'object' && action.action?.Playing;
|
||||
if (item.player === action.player && playing && typeof playing === 'object' && 'ActionCard' in playing && typeof playing.ActionCard === 'number' && playing.ActionCard > 0) return playing.ActionCard;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function source(item: Item, context?: Context): string {
|
||||
const origin = item.origin ?? {};
|
||||
const label = context?.logOriginNames?.[JSON.stringify(origin)];
|
||||
if (origin.CivilCard === 0) return 'Action card';
|
||||
if (origin.CivilCard !== undefined) {
|
||||
const card = context?.cardCatalog?.find(card => card.id === origin.CivilCard);
|
||||
return `Action card · ${card?.name ?? label ?? `Card ${origin.CivilCard}`}`;
|
||||
|
|
@ -59,9 +70,7 @@ function lines(game: Game, action: LoggedAction, context?: Context): string[] {
|
|||
if (collect && action.items?.length)
|
||||
add(action.player ?? action.items[0].player, 'Collect', `Use city ${collect.city_position}`);
|
||||
for (const item of action.items ?? []) {
|
||||
const played = item.HandCard?.to === 'PlayToDiscard' && item.HandCard.card &&
|
||||
typeof item.HandCard.card === 'object' && 'ActionCard' in item.HandCard.card
|
||||
? item.HandCard.card.ActionCard : undefined;
|
||||
const played = playedCardId(action, item);
|
||||
const origin = typeof played === 'number'
|
||||
? source({ ...item, origin: { CivilCard: played } }, context)
|
||||
: source(item, context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue