Compare commits
2 commits
ef6d9b9a3f
...
7d29561679
Author | SHA1 | Date | |
---|---|---|---|
7d29561679 | |||
4260b120e7 |
2 changed files with 4 additions and 16 deletions
|
@ -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<Card> {
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -888,9 +888,9 @@
|
|||
"@types/node" "*"
|
||||
|
||||
"@types/node@*", "@types/node@^20.0.0":
|
||||
version "20.8.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.0.tgz#10ddf0119cf20028781c06d7115562934e53f745"
|
||||
integrity sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==
|
||||
version "20.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.3.tgz#c4ae2bb1cfab2999ed441a95c122bbbe1567a66d"
|
||||
integrity sha512-jxiZQFpb+NlH5kjW49vXxvxTjeeqlbsnTAdBTKpzEdPs9itay7MscYXz3Fo9VYFEsfQ6LJFitHad3faerLAjCw==
|
||||
|
||||
"@types/normalize-package-data@^2.4.1":
|
||||
version "2.4.2"
|
||||
|
|
Loading…
Reference in a new issue