Skip to content

Commit

Permalink
WIP on SE shop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ntalcme authored and BastLast committed Dec 12, 2024
1 parent b462941 commit d1bed01
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
7 changes: 2 additions & 5 deletions Core/src/core/smallEvents/interfaces/Shop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {GenericItem} from "../../../data/GenericItem";
import Player from "../../database/game/models/Player";
import {Maps} from "../../maps/Maps";
import {ExecuteSmallEventLike} from "../../../data/SmallEvent";
import {getItemValue, giveItemToPlayer} from "../../utils/ItemUtils";
import {getItemValue, giveItemToPlayer, toItemWithDetails} from "../../utils/ItemUtils";
import {EndCallback, ReactionCollectorInstance} from "../../utils/ReactionsCollector";
import {BlockingConstants} from "../../../../../Lib/src/constants/BlockingConstants";
import {BlockingUtils} from "../../utils/BlockingUtils";
Expand Down Expand Up @@ -34,10 +34,7 @@ export abstract class Shop<T extends SmallEventAnyShopPacket> {
this.itemPrice = Math.round(getItemValue(this.randomItem) * this.itemMultiplier);

const collector = new ReactionCollectorMerchant({
item: {
category: this.randomItem.getCategory(),
id: this.randomItem.id
},
item: toItemWithDetails(this.randomItem),
price: this.itemPrice
});

Expand Down
48 changes: 48 additions & 0 deletions Discord/src/packetHandlers/handlers/ReactionCollectorHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {shopCollector, shopInventoryExtensionCollector} from "../../commands/pla
import {ReactionCollectorBuyCategorySlotData} from "../../../../Lib/src/packets/interaction/ReactionCollectorBuyCategorySlot";
import {ReactionCollectorCartData} from "../../../../Lib/src/packets/interaction/ReactionCollectorCart";
import {cartCollector} from "../../smallEvents/cart";
import {
ReactionCollectorMerchant,
ReactionCollectorMerchantData
} from "../../../../Lib/src/packets/interaction/ReactionCollectorMerchant";
import {ReactionCollectorFightPetData} from "../../../../Lib/src/packets/interaction/ReactionCollectorFightPet";
import {fightPetCollector} from "../../smallEvents/fightPet";
import {PacketListenerCallbackClient} from "../../../../Lib/src/packets/PacketListener";
Expand Down Expand Up @@ -64,6 +68,50 @@ export default class ReactionCollectorHandler {

@packetHandler(ReactionCollectorCreationPacket)
async collectorCreation(packet: ReactionCollectorCreationPacket, context: PacketContext): Promise<void> {
switch (packet.data.type) {
case ReactionCollectorBigEventData.name:
await createBigEventCollector(packet, context);
break;
case ReactionCollectorChooseDestinationData.name:
await chooseDestinationCollector(packet, context);
break;
case ReactionCollectorGoToPVEIslandData.name:
await goToPVEIslandCollector(packet, context);
break;
case ReactionCollectorPetFreeData.name:
await createPetFreeCollector(packet, context);
break;
case ReactionCollectorGuildCreateData.name:
await createGuildCreateCollector(packet, context);
break;
case ReactionCollectorLotteryData.name:
await lotteryCollector(packet, context);
break;
case ReactionCollectorInteractOtherPlayersPoorData.name:
await interactOtherPlayersCollector(packet, context);
break;
case ReactionCollectorWitchData.name:
await witchCollector(packet, context);
break;
case ReactionCollectorItemChoiceData.name:
await itemChoiceCollector(packet, context);
break;
case ReactionCollectorItemAcceptData.name:
await itemAcceptCollector(packet, context);
break;
case ReactionCollectorShopData.name:
await shopCollector(packet, context);
break;
case ReactionCollectorBuyCategorySlotData.name:
await shopInventoryExtensionCollector(packet, context);
break;
case ReactionCollectorCartData.name:
await cartCollector(packet, context);
break;
case ReactionCollectorMerchantData.name:
await shopCollector(packet, context);
break;
default:
if (!ReactionCollectorHandler.collectorMap) {
ReactionCollectorHandler.initCollectorMap();
}
Expand Down
3 changes: 2 additions & 1 deletion Discord/src/smallEvents/shop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {RandomUtils} from "../../../Lib/src/utils/RandomUtils";
import {KeycloakUtils} from "../../../Lib/src/keycloak/KeycloakUtils";
import {keycloakConfig} from "../bot/DraftBotShard";
import {SmallEventShopPacket} from "../../../Lib/src/packets/smallEvents/SmallEventShopPacket";
import {DisplayUtils} from "../utils/DisplayUtils";

export async function shopCollector(packet: ReactionCollectorCreationPacket, context: PacketContext): Promise<void> {
const interaction = DiscordCache.getInteraction(context.discord!.interaction)!;
Expand All @@ -20,7 +21,7 @@ export async function shopCollector(packet: ReactionCollectorCreationPacket, con
"shop",
StringUtils.getRandomTranslation("smallEvents:shop.intro", interaction.userLanguage, {context: gender, name})
+ StringUtils.getRandomTranslation("smallEvents:shop.end", interaction.userLanguage, {
item: /* TODO: Renvoyer l'item avec ses stats etc */,
item: DisplayUtils.getItemDisplayWithStats(data.item,interaction.userLanguage),
price: data.price,
type: data.item.category
}),
Expand Down
6 changes: 3 additions & 3 deletions Lang/fr/smallEvents.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
},
"boatAdvice": {
"intro": [
"Vous montez sur le pont et vous discutez avec un membre de l'équipage. Il vous donne un conseil pour vous aider dans votre aventure sur l'île :\n**{{{advice}}}**.",
"Vous grimpez sur le mât pour admirer l'horizon. Un homme baisse sa longue-vue et tient à vous donner ce conseil avant votre départ pour l'île :\n**{{{advice}}}**.",
"Dans les joies d'un repas au vent frais de la mer, vous discutez avec les matelots. Votre voisin de table vous donne le conseil suivant à propos de l'île :\n**{{{advice}}}**."
"Vous montez sur le pont et vous discutez avec un membre de l'équipage. Il vous donne un conseil pour vous aider dans votre aventure sur l'île :\n**{{advice}}**.",
"Vous grimpez sur le mât pour admirer l'horizon. Un homme baisse sa longue-vue et tient à vous donner ce conseil avant votre départ pour l'île :\n**{{advice}}**.",
"Dans les joies d'un repas au vent frais de la mer, vous discutez avec les matelots. Votre voisin de table vous donne le conseil suivant à propos de l'île :\n**{{advice}}**."
],
"advices": [
"Il y a beaucoup plus d'évènements qui vous attendent sur l'île mystérieuse",
Expand Down
4 changes: 2 additions & 2 deletions Lib/src/packets/interaction/ReactionCollectorMerchant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
ReactionCollectorData,
ReactionCollectorReaction
} from "./ReactionCollectorPacket";
import {Item} from "../../interfaces/Item";
import {ItemWithDetails} from "../../interfaces/ItemWithDetails";

export class ReactionCollectorMerchantData extends ReactionCollectorData {
item!: Item;
item!: ItemWithDetails;

price!: number;
}
Expand Down

0 comments on commit d1bed01

Please sign in to comment.