diff --git a/.dev.env b/.dev.env index 794bc22..ca791ba 100644 --- a/.dev.env +++ b/.dev.env @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.1.3 DEV +BOT_VER=0.1.4 DEV BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=682942374040961060 diff --git a/.prod.env b/.prod.env index 52afc4f..f1a644e 100644 --- a/.prod.env +++ b/.prod.env @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.1.3 +BOT_VER=0.1.4 BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=1093810443589529631 diff --git a/.stage.env b/.stage.env index 33a2db6..60a01fc 100644 --- a/.stage.env +++ b/.stage.env @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.1.3 BETA +BOT_VER=0.1.4 BETA BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=1147976642942214235 diff --git a/package.json b/package.json index 8229147..80f753a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "card-drop", - "version": "0.1.3", + "version": "0.1.4", "main": "./dist/bot.js", "typings": "./dist", "scripts": { diff --git a/src/client/client.ts b/src/client/client.ts index b517a28..66907bb 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -9,7 +9,6 @@ import { Events } from "./events"; import { Util } from "./util"; import CardSetupFunction from "../Functions/CardSetupFunction"; import CardDataSource from "../database/dataSources/cardDataSource"; -import CardDropHelper from "../helpers/CardDropHelper"; import IButtonEventItem from "../contracts/IButtonEventItem"; import { ButtonEvent } from "../type/buttonEvent"; import AppDataSource from "../database/dataSources/appDataSource"; diff --git a/src/helpers/CardDropHelper.ts b/src/helpers/CardDropHelper.ts index a7d0a02..d5d8743 100644 --- a/src/helpers/CardDropHelper.ts +++ b/src/helpers/CardDropHelper.ts @@ -4,13 +4,6 @@ import Series from "../database/entities/card/Series"; export default class CardDropHelper { public static async GetRandomCard(): Promise { - const allSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]); - const allSeriesWithCards = allSeries.filter(x => x.Cards.length > 0); - - const randomSeriesIndex = Math.floor(Math.random() * allSeriesWithCards.length); - - const randomSeries = allSeriesWithCards[randomSeriesIndex]; - const randomRarity = Math.random() * 100; let cardRarity: CardRarity; @@ -24,6 +17,13 @@ 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);