Skip to content

Commit

Permalink
WIP on SE epicItemShop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ntalcme committed Dec 18, 2024
1 parent e863376 commit 70e1aff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {createUnlockCollector} from "../../commands/player/UnlockCommand";
import {ReactionCollectorUnlockData} from "../../../../Lib/src/packets/interaction/ReactionCollectorUnlock";
import {ReactionCollectorMerchantData} from "../../../../Lib/src/packets/interaction/ReactionCollectorMerchant";
import {smallShopCollector} from "../../smallEvents/shop";
import {epicItemShopCollector} from "../../smallEvents/epicItemShop";

export default class ReactionCollectorHandler {

Expand All @@ -63,6 +64,7 @@ export default class ReactionCollectorHandler {
ReactionCollectorHandler.collectorMap.set(ReactionCollectorGobletsGameData.name, gobletsGameCollector);
ReactionCollectorHandler.collectorMap.set(ReactionCollectorUnlockData.name, createUnlockCollector);
ReactionCollectorHandler.collectorMap.set(ReactionCollectorMerchantData.name, smallShopCollector);
ReactionCollectorHandler.collectorMap.set(ReactionCollectorMerchantData.name, epicItemShopCollector);
}

@packetHandler(ReactionCollectorCreationPacket)
Expand Down
16 changes: 10 additions & 6 deletions Discord/src/packetHandlers/handlers/SmallEventsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ import {DraftBotEmbed} from "../../messages/DraftBotEmbed";
import {baseFunctionHandler} from "../../smallEvents/shop";
import {StringConstants} from "../../../../Lib/src/constants/StringConstants";
import {epicItemShopHandler} from "../../smallEvents/epicItemShop";
import {
SmallEventEpicItemShopAcceptPacket, SmallEventEpicItemShopCannotBuyPacket,
SmallEventEpicItemShopRefusePacket
} from "../../../../Lib/src/packets/smallEvents/SmallEventEpicItemShopPacket";


export function getRandomSmallEventIntro(language: Language): string {
Expand Down Expand Up @@ -849,18 +853,18 @@ export default class SmallEventsHandler {
});
}

@packetHandler(SmallEventShopRefusePacket)
async smallEventEpicItemShopRefuse(packet: SmallEventShopRefusePacket, context: PacketContext): Promise<void> {
@packetHandler(SmallEventEpicItemShopRefusePacket)
async smallEventEpicItemShopRefuse(packet: SmallEventEpicItemShopRefusePacket, context: PacketContext): Promise<void> {
await epicItemShopHandler(context, "smallEvents:epicItemShop.refused");
}

@packetHandler(SmallEventShopAcceptPacket)
async smallEventEpicItemShopAccept(packet: SmallEventShopAcceptPacket, context: PacketContext): Promise<void> {
@packetHandler(SmallEventEpicItemShopAcceptPacket)
async smallEventEpicItemShopAccept(packet: SmallEventEpicItemShopAcceptPacket, context: PacketContext): Promise<void> {
await epicItemShopHandler(context, "smallEvents:epicItemShop.purchased");
}

@packetHandler(SmallEventShopCannotBuyPacket)
async smallEventEpicItemShopCannotBuy(packet: SmallEventShopCannotBuyPacket, context: PacketContext): Promise<void> {
@packetHandler(SmallEventEpicItemShopCannotBuyPacket)
async smallEventEpicItemShopCannotBuy(packet: SmallEventEpicItemShopCannotBuyPacket, context: PacketContext): Promise<void> {
await epicItemShopHandler(context, "smallEvents:epicItemShop.notEnoughMoney");
}
}
9 changes: 1 addition & 8 deletions Discord/src/smallEvents/epicItemShop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {DraftbotSmallEventEmbed} from "../messages/DraftbotSmallEventEmbed";
import {StringUtils} from "../utils/StringUtils";
import {DiscordCollectorUtils} from "../utils/DiscordCollectorUtils";
import {ReactionCollectorMerchantData} from "../../../Lib/src/packets/interaction/ReactionCollectorMerchant";
import {RandomUtils} from "../../../Lib/src/utils/RandomUtils";
import {DisplayUtils} from "../utils/DisplayUtils";
import {Constants} from "../../../Lib/src/constants/Constants";
import i18n from "../translations/i18n";
import {StringConstants} from "../../../Lib/src/constants/StringConstants";

/**
* Send the initial embed for this small event
Expand All @@ -19,16 +17,11 @@ import {StringConstants} from "../../../Lib/src/constants/StringConstants";
export async function epicItemShopCollector(packet: ReactionCollectorCreationPacket, context: PacketContext): Promise<void> {
const interaction = DiscordCache.getInteraction(context.discord!.interaction)!;
const data = packet.data.data as ReactionCollectorMerchantData;
const gender = RandomUtils.draftbotRandom.bool() ? StringConstants.SEX.MALE : StringConstants.SEX.FEMALE;
const name = StringUtils.getRandomTranslation("smallEvents:shop.names", interaction.userLanguage, {context: gender.short});
const tip = data.tip ? StringUtils.getRandomTranslation("smallEvents:epicItemShop.reductionTip",interaction.userLanguage) : "";

const embed = new DraftbotSmallEventEmbed(
"epicItemShop",
StringUtils.getRandomTranslation("smallEvents:epicItemShop.intro", interaction.userLanguage, {
context: gender.short,
name
})
StringUtils.getRandomTranslation("smallEvents:epicItemShop.intro", interaction.userLanguage)
+ tip
+ StringUtils.getRandomTranslation("smallEvents:shop.end", interaction.userLanguage, {
item: DisplayUtils.getItemDisplayWithStats(data.item, interaction.userLanguage),
Expand Down

0 comments on commit 70e1aff

Please sign in to comment.