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 e5ab839..080bd1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -910,14 +910,14 @@ integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw== "@types/uuid@^9.0.0": - version "9.0.2" - resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.2.tgz#ede1d1b1e451548d44919dc226253e32a6952c4b" - integrity sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ== + 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.5" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.5.tgz#af587964aa06682702ee6dcbc7be41a80e4b28eb" - integrity sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg== + version "8.5.6" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.6.tgz#e9ad51f0ab79b9110c50916c9fcbddc36d373065" + integrity sha512-8B5EO9jLVCy+B58PLHvLDuOD8DRVMgQzq8d55SjLCOn9kqGyqOvy27exVaTio1q1nX5zLu8/6N0n2ThSxOM6tg== dependencies: "@types/node" "*"