Compare commits
3 commits
5970a4fe2d
...
74cdf818d1
Author | SHA1 | Date | |
---|---|---|---|
74cdf818d1 | |||
d5c15af9e3 | |||
0e839992e6 |
6 changed files with 11 additions and 12 deletions
2
.dev.env
2
.dev.env
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=0.1.3 DEV
|
BOT_VER=0.1.4 DEV
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=682942374040961060
|
BOT_CLIENTID=682942374040961060
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=0.1.3
|
BOT_VER=0.1.4
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=1093810443589529631
|
BOT_CLIENTID=1093810443589529631
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=0.1.3 BETA
|
BOT_VER=0.1.4 BETA
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=1147976642942214235
|
BOT_CLIENTID=1147976642942214235
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "card-drop",
|
"name": "card-drop",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"main": "./dist/bot.js",
|
"main": "./dist/bot.js",
|
||||||
"typings": "./dist",
|
"typings": "./dist",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { Events } from "./events";
|
||||||
import { Util } from "./util";
|
import { Util } from "./util";
|
||||||
import CardSetupFunction from "../Functions/CardSetupFunction";
|
import CardSetupFunction from "../Functions/CardSetupFunction";
|
||||||
import CardDataSource from "../database/dataSources/cardDataSource";
|
import CardDataSource from "../database/dataSources/cardDataSource";
|
||||||
import CardDropHelper from "../helpers/CardDropHelper";
|
|
||||||
import IButtonEventItem from "../contracts/IButtonEventItem";
|
import IButtonEventItem from "../contracts/IButtonEventItem";
|
||||||
import { ButtonEvent } from "../type/buttonEvent";
|
import { ButtonEvent } from "../type/buttonEvent";
|
||||||
import AppDataSource from "../database/dataSources/appDataSource";
|
import AppDataSource from "../database/dataSources/appDataSource";
|
||||||
|
|
|
@ -4,13 +4,6 @@ import Series from "../database/entities/card/Series";
|
||||||
|
|
||||||
export default class CardDropHelper {
|
export default class CardDropHelper {
|
||||||
public static async GetRandomCard(): Promise<Card> {
|
public static async GetRandomCard(): Promise<Card> {
|
||||||
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;
|
const randomRarity = Math.random() * 100;
|
||||||
|
|
||||||
let cardRarity: CardRarity;
|
let cardRarity: CardRarity;
|
||||||
|
@ -24,6 +17,13 @@ export default class CardDropHelper {
|
||||||
else if (randomRarity < goldChance) cardRarity = CardRarity.Gold;
|
else if (randomRarity < goldChance) cardRarity = CardRarity.Gold;
|
||||||
else cardRarity = CardRarity.Legendary;
|
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 allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity && x.Path && x.FileName);
|
||||||
|
|
||||||
const randomCardIndex = Math.floor(Math.random() * allCards.length);
|
const randomCardIndex = Math.floor(Math.random() * allCards.length);
|
||||||
|
|
Loading…
Reference in a new issue