hidden card

This commit is contained in:
Didictateur 2025-11-25 22:21:20 +01:00
parent bf82284824
commit 886624f116
2 changed files with 10 additions and 2 deletions

View file

@ -320,7 +320,13 @@
const title = (cardObj && (cardObj.title || cardObj.cardId)) || (played && played.card && (played.card.title || played.card.cardId)) || 'Carte'; const title = (cardObj && (cardObj.title || cardObj.cardId)) || (played && played.card && (played.card.title || played.card.cardId)) || 'Carte';
// show player's color instead of their id; fallback to generic label // show player's color instead of their id; fallback to generic label
const actor = (owner === myPlayerId) ? 'Vous' : (playerColors[owner] ? playerColors[owner] : 'Adversaire'); const actor = (owner === myPlayerId) ? 'Vous' : (playerColors[owner] ? playerColors[owner] : 'Adversaire');
// If the played card is marked hidden, do not reveal the title to other players
const isHidden = (cardObj && cardObj.hidden) || (played && played.card && played.card.hidden);
if(isHidden && owner !== myPlayerId){
appendActivity(`${actor} : a joué une carte`);
} else {
appendActivity(`${actor} : a joué la carte "${title}"`); appendActivity(`${actor} : a joué la carte "${title}"`);
}
}catch(_){ } }catch(_){ }
}catch(e){ console.warn('card:played handler error', e); } }catch(e){ console.warn('card:played handler error', e); }
}); });

View file

@ -305,7 +305,9 @@ function buildDefaultDeck(){
const cardId = ascii.replace(/[^a-z0-9]+/gi,'_').toLowerCase(); const cardId = ascii.replace(/[^a-z0-9]+/gi,'_').toLowerCase();
// Use deterministic id equal to the slug so clients and server agree on identifiers across requests // Use deterministic id equal to the slug so clients and server agree on identifiers across requests
const id = cardId; const id = cardId;
return { id, cardId, title: cap(normalized), description: desc }; // mark some cards as hidden so their play isn't revealed publicly (mines, totems, immunities)
const hidden = /mine|totem|immun/i.test(cardId);
return { id, cardId, title: cap(normalized), description: desc, hidden: !!hidden };
}); });
} }