Compare commits
No commits in common. "ff9437ba8154979d3e5b02097016c8bf915a8c8a" and "dd1f25917062b527826c84793c53a160966530e6" have entirely different histories.
ff9437ba81
...
dd1f259170
4 changed files with 4 additions and 74 deletions
|
@ -34,6 +34,8 @@ DB_LOGGING=
|
||||||
DB_DATA_LOCATION=./.temp/database
|
DB_DATA_LOCATION=./.temp/database
|
||||||
DB_ROOT_HOST=0.0.0.0
|
DB_ROOT_HOST=0.0.0.0
|
||||||
|
|
||||||
|
DB_CARD_FILE=:memory:
|
||||||
|
|
||||||
EXPRESS_PORT=3302
|
EXPRESS_PORT=3302
|
||||||
|
|
||||||
GDRIVESYNC_AUTO=false
|
GDRIVESYNC_AUTO=true
|
||||||
|
|
|
@ -11,8 +11,6 @@ import AppLogger from "../client/appLogger";
|
||||||
import User from "../database/entities/app/User";
|
import User from "../database/entities/app/User";
|
||||||
import CardConstants from "../constants/CardConstants";
|
import CardConstants from "../constants/CardConstants";
|
||||||
import ErrorMessages from "../constants/ErrorMessages";
|
import ErrorMessages from "../constants/ErrorMessages";
|
||||||
import { DropResult } from "../contracts/SeriesMetadata";
|
|
||||||
import EffectHelper from "../helpers/EffectHelper";
|
|
||||||
|
|
||||||
export default class Drop extends Command {
|
export default class Drop extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -49,15 +47,7 @@ export default class Drop extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let randomCard: DropResult | undefined;
|
const randomCard = CardDropHelperMetadata.GetRandomCard();
|
||||||
|
|
||||||
const hasChanceUpEffect = await EffectHelper.HasEffect(interaction.user.id, "unclaimed");
|
|
||||||
|
|
||||||
if (hasChanceUpEffect && Math.random() <= CardConstants.UnusedChanceUpChance) {
|
|
||||||
randomCard = await CardDropHelperMetadata.GetRandomCardUnclaimed(interaction.user.id);
|
|
||||||
} else {
|
|
||||||
randomCard = CardDropHelperMetadata.GetRandomCard();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!randomCard) {
|
if (!randomCard) {
|
||||||
AppLogger.LogWarn("Commands/Drop", ErrorMessages.UnableToFetchCard);
|
AppLogger.LogWarn("Commands/Drop", ErrorMessages.UnableToFetchCard);
|
||||||
|
|
|
@ -7,7 +7,4 @@ export default class CardConstants {
|
||||||
// Multidrop
|
// Multidrop
|
||||||
public static readonly MultidropCost = this.ClaimCost * 10;
|
public static readonly MultidropCost = this.ClaimCost * 10;
|
||||||
public static readonly MultidropQuantity = 11;
|
public static readonly MultidropQuantity = 11;
|
||||||
|
|
||||||
// Effects
|
|
||||||
public static readonly UnusedChanceUpChance = 1;
|
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ import { CoreClient } from "../client/client";
|
||||||
import AppLogger from "../client/appLogger";
|
import AppLogger from "../client/appLogger";
|
||||||
import CardConstants from "../constants/CardConstants";
|
import CardConstants from "../constants/CardConstants";
|
||||||
import StringTools from "./StringTools";
|
import StringTools from "./StringTools";
|
||||||
import Inventory from "../database/entities/app/Inventory";
|
|
||||||
|
|
||||||
export default class CardDropHelperMetadata {
|
export default class CardDropHelperMetadata {
|
||||||
public static GetRandomCard(): DropResult | undefined {
|
public static GetRandomCard(): DropResult | undefined {
|
||||||
|
@ -59,64 +58,6 @@ export default class CardDropHelperMetadata {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async GetRandomCardUnclaimed(userId: string): Promise<DropResult | undefined> {
|
|
||||||
const randomRarity = Math.random() * 100;
|
|
||||||
|
|
||||||
let cardRarity: CardRarity;
|
|
||||||
|
|
||||||
const bronzeChance = CardRarityChances.Bronze;
|
|
||||||
const silverChance = bronzeChance + CardRarityChances.Silver;
|
|
||||||
const goldChance = silverChance + CardRarityChances.Gold;
|
|
||||||
const mangaChance = goldChance + CardRarityChances.Manga;
|
|
||||||
|
|
||||||
if (randomRarity < bronzeChance) cardRarity = CardRarity.Bronze;
|
|
||||||
else if (randomRarity < silverChance) cardRarity = CardRarity.Silver;
|
|
||||||
else if (randomRarity < goldChance) cardRarity = CardRarity.Gold;
|
|
||||||
else if (randomRarity < mangaChance) cardRarity = CardRarity.Manga;
|
|
||||||
else cardRarity = CardRarity.Legendary;
|
|
||||||
|
|
||||||
const randomCard = await this.GetRandomCardByRarityUnclaimed(cardRarity, userId);
|
|
||||||
|
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GetRandomCardUnclaimed", `Random card: ${randomCard?.card.id} ${randomCard?.card.name}`);
|
|
||||||
|
|
||||||
return randomCard;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async GetRandomCardByRarityUnclaimed(rarity: CardRarity, userId: string): Promise<DropResult | undefined> {
|
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GetRandomCardByRarityUnclaimed", `Parameters: rarity=${rarity}, userId=${userId}`);
|
|
||||||
|
|
||||||
const claimedCards = await Inventory.FetchAllByUserId(userId);
|
|
||||||
|
|
||||||
if (!claimedCards) {
|
|
||||||
// They don't have any cards, so safe to get any random card
|
|
||||||
return this.GetRandomCardByRarity(rarity);
|
|
||||||
}
|
|
||||||
|
|
||||||
const allCards = CoreClient.Cards
|
|
||||||
.flatMap(x => x.cards)
|
|
||||||
.filter(x => x.type == rarity)
|
|
||||||
.filter(x => !claimedCards.find(y => y.CardNumber == x.id));
|
|
||||||
|
|
||||||
const randomCardIndex = Math.floor(Math.random() * allCards.length);
|
|
||||||
|
|
||||||
const card = allCards[randomCardIndex];
|
|
||||||
const series = CoreClient.Cards
|
|
||||||
.find(x => x.cards.includes(card));
|
|
||||||
|
|
||||||
if (!series) {
|
|
||||||
AppLogger.LogWarn("CardDropHelperMetadata/GetRandomCardByRarityUnclaimed", `Series not found for card ${card.id}`);
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GetRandomCardByRarityUnclaimed", `Random card: ${card.id} ${card.name}`);
|
|
||||||
|
|
||||||
return {
|
|
||||||
series: series,
|
|
||||||
card: card,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GetCardByCardNumber(cardNumber: string): DropResult | undefined {
|
public static GetCardByCardNumber(cardNumber: string): DropResult | undefined {
|
||||||
AppLogger.LogSilly("CardDropHelperMetadata/GetCardByCardNumber", `Parameters: cardNumber=${cardNumber}`);
|
AppLogger.LogSilly("CardDropHelperMetadata/GetCardByCardNumber", `Parameters: cardNumber=${cardNumber}`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue