Make force rarity configurable
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ethan Lane 2023-09-05 19:34:25 +01:00
parent 1a4d4b4e23
commit ada907e2a4
7 changed files with 31 additions and 2 deletions

View file

@ -24,7 +24,7 @@ export default class CardDropHelper {
else if (randomRarity < goldChance) cardRarity = CardRarity.Gold;
else cardRarity = CardRarity.Legendary;
const allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity && x.Path && x.FileName && x.Rarity == CardRarity.Legendary);
const allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity && x.Path && x.FileName);
const randomCardIndex = Math.floor(Math.random() * allCards.length);
@ -32,4 +32,14 @@ export default class CardDropHelper {
return randomCard;
}
public static async GetRandomCardByRarity(rarity: CardRarity): Promise<Card> {
const allCards = await Card.FetchAllByRarity(rarity, [ "Series" ]);
const randomCardIndex = Math.floor(Math.random() * allCards.length);
const card = allCards[randomCardIndex];
return card;
}
}