hotfix/0.1.1 (#23)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Fix gifs not animating Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/23 Co-authored-by: Ethan Lane <ethan@vylpes.com> Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
parent
f8af969104
commit
6629ac30aa
8 changed files with 22 additions and 19 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.0 DEV
|
BOT_VER=0.1.1 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.0
|
BOT_VER=0.1.1
|
||||||
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.0 BETA
|
BOT_VER=0.1.1 BETA
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
BOT_CLIENTID=1147976642942214235
|
BOT_CLIENTID=1147976642942214235
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default class CardSetupFunction {
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
const cardName = filePart[0];
|
const cardName = filePart[0];
|
||||||
|
|
||||||
const card = new Card(cardId, cardName, CardRarity.Bronze, path.join(path.join(process.cwd(), 'cards', series.Path, 'BRONZE', file)), series);
|
const card = new Card(cardId, cardName, CardRarity.Bronze, path.join(path.join(process.cwd(), 'cards', series.Path, 'BRONZE', file)), file, series);
|
||||||
|
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ export default class CardSetupFunction {
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
const cardName = filePart[0];
|
const cardName = filePart[0];
|
||||||
|
|
||||||
const card = new Card(cardId, cardName, CardRarity.Gold, path.join(path.join(process.cwd(), 'cards', series.Path, 'GOLD', file)), series);
|
const card = new Card(cardId, cardName, CardRarity.Gold, path.join(path.join(process.cwd(), 'cards', series.Path, 'GOLD', file)), file, series);
|
||||||
|
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export default class CardSetupFunction {
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
const cardName = filePart[0];
|
const cardName = filePart[0];
|
||||||
|
|
||||||
const card = new Card(cardId, cardName, CardRarity.Legendary, path.join(path.join(process.cwd(), 'cards', series.Path, 'LEGENDARY', file)), series);
|
const card = new Card(cardId, cardName, CardRarity.Legendary, path.join(path.join(process.cwd(), 'cards', series.Path, 'LEGENDARY', file)), file, series);
|
||||||
|
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ export default class CardSetupFunction {
|
||||||
const cardId = filePart[0];
|
const cardId = filePart[0];
|
||||||
const cardName = filePart[0];
|
const cardName = filePart[0];
|
||||||
|
|
||||||
const card = new Card(cardId, cardName, CardRarity.Silver, path.join(path.join(process.cwd(), 'cards', series.Path, 'SILVER', file)), series);
|
const card = new Card(cardId, cardName, CardRarity.Silver, path.join(path.join(process.cwd(), 'cards', series.Path, 'SILVER', file)), file, series);
|
||||||
|
|
||||||
cardsToSave.push(card);
|
cardsToSave.push(card);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ export default class Reroll extends ButtonEvent {
|
||||||
|
|
||||||
const image = readFileSync(randomCard.Path);
|
const image = readFileSync(randomCard.Path);
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: `${randomCard.Id}.png` });
|
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(randomCard.Name)
|
.setTitle(randomCard.Name)
|
||||||
.setDescription(randomCard.Series.Name)
|
.setDescription(randomCard.Series.Name)
|
||||||
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
||||||
.setColor(CardRarityToColour(randomCard.Rarity))
|
.setColor(CardRarityToColour(randomCard.Rarity))
|
||||||
.setImage(`attachment://${randomCard.Id}.png`);
|
.setImage(`attachment://${randomCard.FileName}`);
|
||||||
|
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>();
|
const row = new ActionRowBuilder<ButtonBuilder>();
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,16 @@ export default class Drop extends Command {
|
||||||
|
|
||||||
const image = readFileSync(randomCard.Path);
|
const image = readFileSync(randomCard.Path);
|
||||||
|
|
||||||
const attachment = new AttachmentBuilder(image, { name: `${randomCard.Id}.png` });
|
await interaction.deferReply();
|
||||||
|
|
||||||
|
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setTitle(randomCard.Name)
|
.setTitle(randomCard.Name)
|
||||||
.setDescription(randomCard.Series.Name)
|
.setDescription(randomCard.Series.Name)
|
||||||
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
|
||||||
.setColor(CardRarityToColour(randomCard.Rarity))
|
.setColor(CardRarityToColour(randomCard.Rarity))
|
||||||
.setImage(`attachment://${randomCard.Id}.png`);
|
.setImage(`attachment://${randomCard.FileName}`);
|
||||||
|
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>();
|
const row = new ActionRowBuilder<ButtonBuilder>();
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ export default class Drop extends Command {
|
||||||
.setLabel("Reroll")
|
.setLabel("Reroll")
|
||||||
.setStyle(ButtonStyle.Secondary));
|
.setStyle(ButtonStyle.Secondary));
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.editReply({
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
files: [ attachment ],
|
files: [ attachment ],
|
||||||
components: [ row ],
|
components: [ row ],
|
||||||
|
|
|
@ -5,18 +5,19 @@ import Series from "./Series";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class Card extends CardBaseEntity {
|
export default class Card extends CardBaseEntity {
|
||||||
constructor(cardNumber: string, name: string, rarity: CardRarity, path: string, series: Series) {
|
constructor(cardNumber: string, name: string, rarity: CardRarity, path: string, fileName: string, series: Series) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.CardNumber = cardNumber;
|
this.CardNumber = cardNumber;
|
||||||
this.Name = name;
|
this.Name = name;
|
||||||
this.Rarity = rarity;
|
this.Rarity = rarity;
|
||||||
this.Path = path;
|
this.Path = path;
|
||||||
|
this.FileName = fileName;
|
||||||
this.Series = series;
|
this.Series = series;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
CardNumber: string
|
CardNumber: string;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
Name: string;
|
Name: string;
|
||||||
|
@ -25,7 +26,10 @@ export default class Card extends CardBaseEntity {
|
||||||
Rarity: CardRarity;
|
Rarity: CardRarity;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
Path: string
|
Path: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
FileName: string;
|
||||||
|
|
||||||
@ManyToOne(() => Series, x => x.Cards)
|
@ManyToOne(() => Series, x => x.Cards)
|
||||||
Series: Series;
|
Series: Series;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { CardRarity } from "../constants/CardRarity";
|
import { CardRarity } from "../constants/CardRarity";
|
||||||
import CardDataSource from "../database/dataSources/cardDataSource";
|
|
||||||
import Card from "../database/entities/card/Card";
|
import Card from "../database/entities/card/Card";
|
||||||
import Series from "../database/entities/card/Series";
|
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 seriesRepository = CardDataSource.getRepository(Series);
|
|
||||||
|
|
||||||
const allSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]);
|
const allSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]);
|
||||||
const allSeriesWithCards = allSeries.filter(x => x.Cards.length > 0);
|
const allSeriesWithCards = allSeries.filter(x => x.Cards.length > 0);
|
||||||
|
|
||||||
|
@ -27,7 +24,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 allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity);
|
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