final POC

This commit is contained in:
magdo
2025-11-24 23:28:57 +01:00
parent ce02f55a99
commit 6b3446e9b6
49 changed files with 4634 additions and 4620 deletions
@@ -81,15 +81,28 @@ export class CardDrawingService {
drawnCard.played = true;
drawnCard.playerid = playerId;
// Check if card has consequence field (joker/luck card) even without type
const hasConsequence = drawnCard.consequence !== undefined && drawnCard.consequence !== null;
// Prepare client data based on card type
// Only prepare for question cards (cards without consequence and with defined type)
let clientData: CardClientData | undefined;
try {
if (drawnCard.type !== undefined) {
if (!hasConsequence && drawnCard.type !== undefined) {
try {
clientData = this.cardProcessingService.prepareCardForClient(drawnCard);
} catch (error) {
// If client data preparation fails, still return the card but log the error
console.warn(`Failed to prepare client data for card ${drawnCard.cardid}:`, error);
}
} catch (error) {
// If client data preparation fails, still return the card but log the error
console.warn(`Failed to prepare client data for card ${drawnCard.cardid}:`, error);
} else if (!hasConsequence && drawnCard.type === undefined) {
// Card is missing type field - this shouldn't happen, log error
console.error(`Card ${drawnCard.cardid} is missing type field. Card data:`, {
cardId: drawnCard.cardid,
hasQuestion: !!drawnCard.question,
hasAnswer: !!drawnCard.answer,
hasConsequence,
cardKeys: Object.keys(drawnCard)
});
}
return {