From c49033facbf5dd52946eb640a2283302696cba64 Mon Sep 17 00:00:00 2001 From: dingo Date: Thu, 23 Apr 2026 15:40:49 -0400 Subject: [PATCH] Use existence checks for archspirit validation --- .../SOR.Collection/Handlers/CollectionCreateDeckHandler.cs | 6 +++--- .../Handlers/CollectionSetArchSpiritHandler.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Server/src/SOR.Collection/Handlers/CollectionCreateDeckHandler.cs b/Server/src/SOR.Collection/Handlers/CollectionCreateDeckHandler.cs index 858b0af..61b36fc 100644 --- a/Server/src/SOR.Collection/Handlers/CollectionCreateDeckHandler.cs +++ b/Server/src/SOR.Collection/Handlers/CollectionCreateDeckHandler.cs @@ -56,12 +56,12 @@ internal sealed class CollectionCreateDeckHandler : CollectionHandlerBase, IMess $"Maximum of {DeckRules.MaxDecksPerPlayer} decks reached."); // ── Validate ArchSpirit exists in catalog ────────────────────────────── - var archDef = await _catalogDb.CardDefinitions - .FirstOrDefaultAsync( + var archSpiritExists = await _catalogDb.CardDefinitions + .AnyAsync( cd => cd.Id == req.ArchSpiritCardDefinitionId && cd.CardType == CardType.ArchSpirit, cancellationToken); - if (archDef == null) + if (!archSpiritExists) return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT", "That card is not a valid ArchSpirit."); diff --git a/Server/src/SOR.Collection/Handlers/CollectionSetArchSpiritHandler.cs b/Server/src/SOR.Collection/Handlers/CollectionSetArchSpiritHandler.cs index 8aca430..b456002 100644 --- a/Server/src/SOR.Collection/Handlers/CollectionSetArchSpiritHandler.cs +++ b/Server/src/SOR.Collection/Handlers/CollectionSetArchSpiritHandler.cs @@ -51,12 +51,12 @@ internal sealed class CollectionSetArchSpiritHandler : CollectionHandlerBase, IM return ServerMessage.Error(message.Seq, "DECK_NOT_FOUND", "Deck not found."); // ── Validate ArchSpirit exists in catalog ────────────────────────────── - var archDef = await _catalogDb.CardDefinitions - .FirstOrDefaultAsync( + var archSpiritExists = await _catalogDb.CardDefinitions + .AnyAsync( cd => cd.Id == req.ArchSpiritCardDefinitionId && cd.CardType == CardType.ArchSpirit, cancellationToken); - if (archDef is null) + if (!archSpiritExists) return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT", "That card is not a valid ArchSpirit.");