diff --git a/src/helpers/CardDropHelper.ts b/src/helpers/CardDropHelper.ts index d5d8743..6eec120 100644 --- a/src/helpers/CardDropHelper.ts +++ b/src/helpers/CardDropHelper.ts @@ -1,6 +1,5 @@ import { CardRarity } from "../constants/CardRarity"; import Card from "../database/entities/card/Card"; -import Series from "../database/entities/card/Series"; export default class CardDropHelper { public static async GetRandomCard(): Promise { @@ -17,18 +16,7 @@ export default class CardDropHelper { else if (randomRarity < goldChance) cardRarity = CardRarity.Gold; else cardRarity = CardRarity.Legendary; - const allSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]); - const allSeriesWithCards = allSeries.filter(x => x.Cards.length > 0 && x.Cards.find(x => x.Rarity == cardRarity)); - - const randomSeriesIndex = Math.floor(Math.random() * allSeriesWithCards.length); - - const randomSeries = allSeriesWithCards[randomSeriesIndex]; - - const allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity && x.Path && x.FileName); - - const randomCardIndex = Math.floor(Math.random() * allCards.length); - - const randomCard = allCards[randomCardIndex]; + const randomCard = await this.GetRandomCardByRarity(cardRarity); return randomCard; } diff --git a/yarn.lock b/yarn.lock index eda61a0..080bd1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -910,9 +910,9 @@ integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== "@types/uuid@^9.0.0": - version "9.0.4" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.4.tgz#e884a59338da907bda8d2ed03e01c5c49d036f1c" - integrity sha512-zAuJWQflfx6dYJM62vna+Sn5aeSWhh3OB+wfUEACNcqUSc0AGc5JKl+ycL1vrH7frGTXhJchYjE1Hak8L819dA== + version "9.0.5" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.5.tgz#25a71eb73eba95ac0e559ff3dd018fc08294acf6" + integrity sha512-xfHdwa1FMJ082prjSJpoEI57GZITiQz10r3vEJCHa2khEFQjKy91aWKz6+zybzssCvXUwE1LQWgWVwZ4nYUvHQ== "@types/ws@^8.5.5": version "8.5.6"