Update unclaimed card filter to fallback to any card if all cards are claimed
All checks were successful
Test / build (push) Successful in 44s
All checks were successful
Test / build (push) Successful in 44s
This commit is contained in:
parent
7d9c1bda62
commit
cf5b8406db
1 changed files with 4 additions and 5 deletions
|
@ -39,12 +39,11 @@ export default class GetUnclaimedCardsHelper {
|
||||||
const allCards = CoreClient.Cards
|
const allCards = CoreClient.Cards
|
||||||
.flatMap(x => x.cards)
|
.flatMap(x => x.cards)
|
||||||
.filter(x => x.type == rarity)
|
.filter(x => x.type == rarity)
|
||||||
.filter(x => !claimedCards.find(y => y.CardNumber == x.id));
|
.filter(x => !claimedCards.find(y => y.CardNumber == x.id && y.Quantity > 0));
|
||||||
|
|
||||||
if (!allCards) {
|
if (!allCards || allCards.length == 0) {
|
||||||
AppLogger.LogError("CardDropHelperMetadata/GetRandomCardByRarityUnclaimed", `No cards found to randomise from, User Id: ${userId}, rarity: ${rarity}`);
|
// There is no card left unclaimed, fallback to any card
|
||||||
|
return GetCardsHelper.GetRandomCardByRarity(rarity);
|
||||||
return undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const randomCardIndex = Math.floor(Math.random() * allCards.length);
|
const randomCardIndex = Math.floor(Math.random() * allCards.length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue