Compare commits
2 commits
4b78509653
...
e909960ef9
Author | SHA1 | Date | |
---|---|---|---|
e909960ef9 | |||
4260b120e7 |
2 changed files with 7 additions and 19 deletions
|
@ -1,6 +1,5 @@
|
||||||
import { CardRarity } from "../constants/CardRarity";
|
import { CardRarity } from "../constants/CardRarity";
|
||||||
import Card from "../database/entities/card/Card";
|
import Card from "../database/entities/card/Card";
|
||||||
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> {
|
||||||
|
@ -17,18 +16,7 @@ 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 randomCard = await this.GetRandomCardByRarity(cardRarity);
|
||||||
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];
|
|
||||||
|
|
||||||
return randomCard;
|
return randomCard;
|
||||||
}
|
}
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -910,14 +910,14 @@
|
||||||
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==
|
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==
|
||||||
|
|
||||||
"@types/uuid@^9.0.0":
|
"@types/uuid@^9.0.0":
|
||||||
version "9.0.2"
|
version "9.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.2.tgz#ede1d1b1e451548d44919dc226253e32a6952c4b"
|
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.5.tgz#25a71eb73eba95ac0e559ff3dd018fc08294acf6"
|
||||||
integrity sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==
|
integrity sha512-xfHdwa1FMJ082prjSJpoEI57GZITiQz10r3vEJCHa2khEFQjKy91aWKz6+zybzssCvXUwE1LQWgWVwZ4nYUvHQ==
|
||||||
|
|
||||||
"@types/ws@^8.5.5":
|
"@types/ws@^8.5.5":
|
||||||
version "8.5.5"
|
version "8.5.6"
|
||||||
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.5.tgz#af587964aa06682702ee6dcbc7be41a80e4b28eb"
|
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.6.tgz#e9ad51f0ab79b9110c50916c9fcbddc36d373065"
|
||||||
integrity sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==
|
integrity sha512-8B5EO9jLVCy+B58PLHvLDuOD8DRVMgQzq8d55SjLCOn9kqGyqOvy27exVaTio1q1nX5zLu8/6N0n2ThSxOM6tg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue