final POC
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user