Add ability to force a card
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
476b9ad5f9
commit
5ec79ee67c
6 changed files with 31 additions and 0 deletions
1
.dev.env
1
.dev.env
|
@ -16,6 +16,7 @@ ABOUT_FUNDING=
|
|||
ABOUT_REPO=
|
||||
|
||||
DROP_RARITY=-1
|
||||
DROP_CARD=-1
|
||||
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3301
|
||||
|
|
|
@ -16,6 +16,7 @@ ABOUT_FUNDING=
|
|||
ABOUT_REPO=
|
||||
|
||||
DROP_RARITY=-1
|
||||
DROP_CARD=-1
|
||||
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3321
|
||||
|
|
|
@ -16,6 +16,7 @@ ABOUT_FUNDING=
|
|||
ABOUT_REPO=
|
||||
|
||||
DROP_RARITY=-1
|
||||
DROP_CARD=-1
|
||||
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3311
|
||||
|
|
|
@ -5,6 +5,7 @@ import { readFileSync } from "fs";
|
|||
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
|
||||
import { v4 } from "uuid";
|
||||
import { CoreClient } from "../client/client";
|
||||
import Card from "../database/entities/card/Card";
|
||||
|
||||
export default class Reroll extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
|
@ -14,6 +15,15 @@ export default class Reroll extends ButtonEvent {
|
|||
|
||||
if (process.env.DROP_RARITY && Number(process.env.DROP_RARITY) > 0) {
|
||||
randomCard = await CardDropHelper.GetRandomCardByRarity(Number(process.env.DROP_RARITY));
|
||||
} else if (process.env.DROP_CARD && process.env.DROP_CARD != '-1') {
|
||||
let card = await Card.FetchOneByCardNumber(process.env.DROP_CARD, [ "Series" ]);
|
||||
|
||||
if (!card) {
|
||||
await interaction.reply("Card not found");
|
||||
return;
|
||||
}
|
||||
|
||||
randomCard = card;
|
||||
}
|
||||
|
||||
const image = readFileSync(randomCard.Path);
|
||||
|
|
|
@ -5,6 +5,7 @@ import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity"
|
|||
import { readFileSync } from "fs";
|
||||
import { CoreClient } from "../client/client";
|
||||
import { v4 } from "uuid";
|
||||
import Card from "../database/entities/card/Card";
|
||||
|
||||
export default class Drop extends Command {
|
||||
constructor() {
|
||||
|
@ -20,6 +21,15 @@ export default class Drop extends Command {
|
|||
|
||||
if (process.env.DROP_RARITY && Number(process.env.DROP_RARITY) > 0) {
|
||||
randomCard = await CardDropHelper.GetRandomCardByRarity(Number(process.env.DROP_RARITY));
|
||||
} else if (process.env.DROP_CARD && process.env.DROP_CARD != '-1') {
|
||||
let card = await Card.FetchOneByCardNumber(process.env.DROP_CARD, [ "Series" ]);
|
||||
|
||||
if (!card) {
|
||||
await interaction.reply("Card not found");
|
||||
return;
|
||||
}
|
||||
|
||||
randomCard = card;
|
||||
}
|
||||
|
||||
const image = readFileSync(randomCard.Path);
|
||||
|
|
|
@ -35,6 +35,14 @@ export default class Card extends CardBaseEntity {
|
|||
@ManyToOne(() => Series, x => x.Cards)
|
||||
Series: Series;
|
||||
|
||||
public static async FetchOneByCardNumber(cardNumber: string, relations?: string[]): Promise<Card | null> {
|
||||
const repository = CardDataSource.getRepository(Card);
|
||||
|
||||
const single = await repository.findOne({ where: { CardNumber: cardNumber }, relations: relations || [] });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
||||
public static async FetchAllByRarity(rarity: CardRarity, relations?: string[]): Promise<Card[]> {
|
||||
const repository = CardDataSource.getRepository(Card);
|
||||
|
||||
|
|
Loading…
Reference in a new issue