Use existence checks for archspirit validation
This commit is contained in:
@@ -56,12 +56,12 @@ internal sealed class CollectionCreateDeckHandler : CollectionHandlerBase, IMess
|
|||||||
$"Maximum of {DeckRules.MaxDecksPerPlayer} decks reached.");
|
$"Maximum of {DeckRules.MaxDecksPerPlayer} decks reached.");
|
||||||
|
|
||||||
// ── Validate ArchSpirit exists in catalog ──────────────────────────────
|
// ── Validate ArchSpirit exists in catalog ──────────────────────────────
|
||||||
var archDef = await _catalogDb.CardDefinitions
|
var archSpiritExists = await _catalogDb.CardDefinitions
|
||||||
.FirstOrDefaultAsync(
|
.AnyAsync(
|
||||||
cd => cd.Id == req.ArchSpiritCardDefinitionId
|
cd => cd.Id == req.ArchSpiritCardDefinitionId
|
||||||
&& cd.CardType == CardType.ArchSpirit,
|
&& cd.CardType == CardType.ArchSpirit,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
if (archDef == null)
|
if (!archSpiritExists)
|
||||||
return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT",
|
return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT",
|
||||||
"That card is not a valid ArchSpirit.");
|
"That card is not a valid ArchSpirit.");
|
||||||
|
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ internal sealed class CollectionSetArchSpiritHandler : CollectionHandlerBase, IM
|
|||||||
return ServerMessage.Error(message.Seq, "DECK_NOT_FOUND", "Deck not found.");
|
return ServerMessage.Error(message.Seq, "DECK_NOT_FOUND", "Deck not found.");
|
||||||
|
|
||||||
// ── Validate ArchSpirit exists in catalog ──────────────────────────────
|
// ── Validate ArchSpirit exists in catalog ──────────────────────────────
|
||||||
var archDef = await _catalogDb.CardDefinitions
|
var archSpiritExists = await _catalogDb.CardDefinitions
|
||||||
.FirstOrDefaultAsync(
|
.AnyAsync(
|
||||||
cd => cd.Id == req.ArchSpiritCardDefinitionId
|
cd => cd.Id == req.ArchSpiritCardDefinitionId
|
||||||
&& cd.CardType == CardType.ArchSpirit,
|
&& cd.CardType == CardType.ArchSpirit,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
if (archDef is null)
|
if (!archSpiritExists)
|
||||||
return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT",
|
return ServerMessage.Error(message.Seq, "INVALID_ARCH_SPIRIT",
|
||||||
"That card is not a valid ArchSpirit.");
|
"That card is not a valid ArchSpirit.");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user