From 535a3df0f95bf1d4d45ad3bf854d0e6a334655fb Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 3 Mar 2024 18:43:15 +0100 Subject: [PATCH 01/10] WIP guildcommand #2273 --- Discord/src/commands/guild/GuildCommand.ts | 265 ++++++++++++++++++ Discord/src/commands/player/ProfileCommand.ts | 2 +- .../packets/commands/CommandGuildPacket.ts | 13 + 3 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 Discord/src/commands/guild/GuildCommand.ts create mode 100644 Lib/src/packets/commands/CommandGuildPacket.ts diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts new file mode 100644 index 000000000..9d171b2e1 --- /dev/null +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -0,0 +1,265 @@ +import {ICommand} from "../ICommand"; +import {makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; +import {DraftbotInteraction} from "../../messages/DraftbotInteraction"; +import i18n from "../../translations/i18n"; +import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator"; +import { + CommandProfilePacketReq, + CommandProfilePacketRes +} from "../../../../Lib/src/packets/commands/CommandProfilePacket"; +import {SlashCommandBuilder} from "@discordjs/builders"; +import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; +import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; +import {ColorResolvable, EmbedField, Message, MessageReaction} from "discord.js"; +import {Constants} from "../../Constants"; +import {DiscordCache} from "../../bot/DiscordCache"; +import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; +import {ProfileConstants} from "../../constants/ProfileConstants"; +import {Language} from "../../../../Lib/src/Language"; +import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; +import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; +import {keycloakConfig} from "../../bot/DraftBotShard"; + +/** + * Display all the information about a guild + */ +async function getPacket(interaction: DraftbotInteraction, keycloakUser: KeycloakUser): Promise { + + const askedGuildName = interaction.options.get('guildName'); + + let askedPlayer: { keycloakId?: string, rank?: number } = {keycloakId: keycloakUser.id}; + const user = interaction.options.getUser("user"); + if (user) { + const keycloakId = await KeycloakUtils.getKeycloakIdFromDiscordId(keycloakConfig, user.id, user.displayName); + if (!keycloakId) { + await interaction.reply({embeds: [new DraftBotErrorEmbed(interaction.user, interaction, i18n.t("error:playerDoesntExist", {lng: interaction.userLanguage}))]}); + return null; + } + askedPlayer = {keycloakId}; + } + const rank = interaction.options.get("rank"); + if (rank) { + askedPlayer = {rank: rank.value}; + } + + return makePacket(CommandGuildPacketReq, {askedPlayer}); +} + +function generateFields(packet: CommandProfilePacketRes, language: Language): EmbedField[] { + const fields: EmbedField[] = []; + + fields.push({ + name: i18n.t("commands:profile.information.fieldName", {lng: language}), + value: i18n.t("commands:profile.information.fieldValue", { + lng: language, + health: packet.data?.health.value, + maxHealth: packet.data?.health.max, + money: packet.data?.money, + experience: packet.data?.experience.value, + experienceNeededToLevelUp: packet.data?.experience.max + }), + inline: false + }); + + if (packet.data?.stats) { + fields.push({ + name: i18n.t("commands:profile.statistics.fieldName", {lng: language}), + value: i18n.t("commands:profile.statistics.fieldValue", { + lng: language, + baseBreath: packet.data?.stats.breath.base, + breathRegen: packet.data?.stats.breath.regen, + cumulativeAttack: packet.data?.stats.attack, + cumulativeDefense: packet.data?.stats.defense, + cumulativeHealth: packet.data.stats.energy.value, + cumulativeSpeed: packet.data.stats.speed, + cumulativeMaxHealth: packet.data.stats.energy.max, + maxBreath: packet.data.stats.breath.max + }), + inline: false + }); + } + + fields.push({ + name: i18n.t("commands:profile.mission.fieldName", {lng: language}), + value: i18n.t("commands:profile.mission.fieldValue", { + lng: language, + gems: packet.data?.missions.gems, + campaign: packet.data?.missions.campaignProgression + }), + inline: false + }); + + fields.push({ + name: i18n.t("commands:profile.ranking.fieldName", {lng: language}), + value: packet.data?.rank.unranked ? i18n.t("commands:profile.ranking.fieldValueUnranked", { + lng: language, + score: packet.data.rank.score + }) : i18n.t("commands:profile.ranking.fieldValue", { + lng: language, + rank: packet.data?.rank.rank, + numberOfPlayer: packet.data?.rank.numberOfPlayers, + score: packet.data?.rank.score + }), + inline: false + }); + + if (packet.data?.effect?.healed) { + fields.push({ + name: i18n.t("commands:profile.noTimeLeft.fieldName", {lng: language}), + value: i18n.t("commands:profile.noTimeLeft.fieldValue", { + lng: language + }), + inline: false + }); + } + else if (packet.data?.effect) { + fields.push({ + name: i18n.t("commands:profile.timeLeft.fieldName", {lng: language}), + value: i18n.t("commands:profile.timeLeft.fieldValue", { + lng: language, + effect: packet.data.effect, + timeLeft: packet.data.effect.timeLeft + }), + inline: false + }); + } + + if (packet.data?.class) { + fields.push({ + name: i18n.t("commands:profile.playerClass.fieldName", {lng: language}), + value: i18n.t("commands:profile.playerClass.fieldValue", { + lng: language, + class: packet.data.class + }), + inline: false + }); + } + + if (packet.data?.fightRanking) { + fields.push({ + name: i18n.t("commands:profile.fightRanking.fieldName", {lng: language}), + value: i18n.t("commands:profile.fightRanking.fieldValue", { + lng: language, + league: packet.data.fightRanking.league, + gloryPoints: packet.data.fightRanking.glory + }), + inline: false + }); + } + + if (packet.data?.guild) { + fields.push({ + name: i18n.t("commands:profile.guild.fieldName", {lng: language}), + value: i18n.t("commands:profile.guild.fieldValue", { + lng: language, + guild: packet.data.guild + }), + inline: false + }); + } + + if (packet.data?.destination) { + fields.push({ + name: i18n.t("commands:profile.map.fieldName", {lng: language}), + value: i18n.t("commands:profile.map.fieldValue", { + lng: language, + mapEmote: "TODO EMOTE", // Todo + mapName: i18n.t(`models:map_locations.${packet.data.destination}.name`, {lng: language}) + }), + inline: false + }); + } + + if (packet.data?.pet) { + fields.push({ + name: i18n.t("commands:profile.pet.fieldName", {lng: language}), + value: i18n.t("commands:profile.pet.fieldValue", { + lng: language, + emote: "TODO EMOTE", // Todo + rarity: packet.data.pet.rarity, + nickname: packet.data.pet.nickname ?? i18n.t(`models:pets.${packet.data.pet.id}`, {lng: language}) + }), + inline: false + }); + } + + return fields; +} + +export async function handleCommandProfilePacketRes(packet: CommandProfilePacketRes, context: PacketContext): Promise { + const interaction = DiscordCache.getInteraction(context.discord!.interaction); + + if (interaction) { + if (!packet.foundPlayer) { + await interaction.reply({ + embeds: [ + new DraftBotErrorEmbed( + interaction.user, + interaction, + i18n.t("error:playerDoesntExist", {lng: interaction.userLanguage}) + ) + ] + }); + return; + } + + const keycloakUser = (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.keycloakId!))!; + + const titleEffect = packet.data?.effect?.healed ? Constants.DEFAULT_HEALED_EFFECT : packet.data?.effect; + const reply = await interaction.reply({ + embeds: [ + new DraftBotEmbed() + .setColor(packet.data!.color) + .setTitle(i18n.t("commands:profile.title", { + lng: interaction.userLanguage, + effect: titleEffect, + pseudo: keycloakUser.attributes.gameUsername, + level: packet.data?.level + })) + .addFields(generateFields(packet, interaction.userLanguage)) + ], + fetchReply: true + }) as Message; + + const collector = reply.createReactionCollector({ + filter: (reaction: MessageReaction) => reaction.me && !reaction.users.cache.last()!.bot, + time: Constants.MESSAGES.COLLECTOR_TIME, + max: ProfileConstants.BADGE_MAXIMUM_REACTION + }); + + collector.on("collect", async (reaction) => { + if (reaction.emoji.name === Constants.PROFILE.DISPLAY_ALL_BADGE_EMOTE) { + collector.stop(); // Only one is allowed to avoid spam + await sendMessageAllBadgesTooMuchBadges(keycloakUser.attributes.gameUsername, packet.data!.badges!, interaction); + } + else { + interaction.channel.send({content: i18n.t(`commands:profile.badges.${reaction.emoji.name}`)}) + .then((msg: Message | null) => { + setTimeout(() => msg?.delete(), ProfileConstants.BADGE_DESCRIPTION_TIMEOUT); + }); + } + }); + + if (packet.data?.badges.length !== 0) { + await displayBadges(packet.data!.badges, reply); + } + } +} + +export const commandInfo: ICommand = { + slashCommandBuilder: SlashCommandBuilderGenerator.generateBaseCommand("guild") + .addUserOption(option => + SlashCommandBuilderGenerator.generateOption("guild", "user", option) + .setRequired(false)) + .addStringOption(option => + SlashCommandBuilderGenerator.generateOption("guild", "guildName", option) + .setRequired(false)) + .addIntegerOption(option => + SlashCommandBuilderGenerator.generateOption("guild", "rank", option) + .setRequired(false)) as SlashCommandBuilder, + getPacket, + requirements: { + disallowEffects: [EffectsConstants.EMOJI_TEXT.BABY] + }, + mainGuildCommand: false +}; \ No newline at end of file diff --git a/Discord/src/commands/player/ProfileCommand.ts b/Discord/src/commands/player/ProfileCommand.ts index 8a87ae1cf..b0f7cbcca 100644 --- a/Discord/src/commands/player/ProfileCommand.ts +++ b/Discord/src/commands/player/ProfileCommand.ts @@ -18,7 +18,7 @@ import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; import {keycloakConfig} from "../../bot/DraftBotShard"; /** - * Pings the bot, to check if it is alive and how well is it + * Display the profile of a player */ async function getPacket(interaction: DraftbotInteraction, keycloakUser: KeycloakUser): Promise { let askedPlayer: { keycloakId?: string, rank?: number } = {keycloakId: keycloakUser.id}; diff --git a/Lib/src/packets/commands/CommandGuildPacket.ts b/Lib/src/packets/commands/CommandGuildPacket.ts new file mode 100644 index 000000000..21743cda0 --- /dev/null +++ b/Lib/src/packets/commands/CommandGuildPacket.ts @@ -0,0 +1,13 @@ +import {DraftBotPacket} from "../DraftBotPacket"; + +export class CommandGuildPacketReq extends DraftBotPacket { + askedPlayer?: { + rank?: number, + keycloakId?: string + }; + guildName?: string; +} + +export class CommandGuildPacketRes extends DraftBotPacket { + foundGuild!: boolean; +} \ No newline at end of file From 729463d10e14d55248ab212692a77d86997ab55f Mon Sep 17 00:00:00 2001 From: BastLast Date: Sat, 9 Mar 2024 16:19:53 +0100 Subject: [PATCH 02/10] WIP guild command 2 #2273 --- Core/src/commands/guild/GuildCommand.ts | 140 ++++++++++++++++++ Discord/src/commands/guild/GuildCommand.ts | 22 +-- .../packets/commands/CommandGuildPacket.ts | 35 ++++- 3 files changed, 185 insertions(+), 12 deletions(-) create mode 100644 Core/src/commands/guild/GuildCommand.ts diff --git a/Core/src/commands/guild/GuildCommand.ts b/Core/src/commands/guild/GuildCommand.ts new file mode 100644 index 000000000..2d66088ec --- /dev/null +++ b/Core/src/commands/guild/GuildCommand.ts @@ -0,0 +1,140 @@ +import {PetEntities} from "../../core/database/game/models/PetEntity"; +import PlayerMissionsInfo, {PlayerMissionsInfos} from "../../core/database/game/models/PlayerMissionsInfo"; +import {InventorySlots} from "../../core/database/game/models/InventorySlot"; +import {FightConstants} from "../../core/constants/FightConstants"; +import {packetHandler} from "../../core/packetHandlers/PacketHandler"; +import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient"; +import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; +import {Players} from "../../core/database/game/models/Player"; +import {Guild, Guilds} from "../../core/database/game/models/Guild"; +import {Constants} from "../../core/Constants"; +import {hoursToMilliseconds} from "../../../../Lib/src/utils/TimeUtils"; +import {PetDataController} from "../../data/Pet"; +import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; + +export default class GuildCommand { + @packetHandler(CommandGuildPacketReq) + async execute(client: WebsocketClient, packet: CommandGuildPacketReq, context: PacketContext, response: DraftBotPacket[]): Promise { + let guild: Guild; + if (packet.askedGuildName) { + try { + guild = await Guilds.getByName(packet.askedGuildName); + } + catch (error) { + guild = null; + } + } + else { + const player = packet.askedPlayer.keycloakId ? await Players.getByKeycloakId(packet.askedPlayer.keycloakId) : await Players.getByRank(packet.askedPlayer.rank); + guild = player.guildId ? await Guilds.getById(player.guildId) : null; + } + + if (!guild) { + response.push(makePacket(CommandGuildPacketRes, { + foundGuild: false + })); + } + else { + const rank = await Players.getRankById(player.id); + const numberOfPlayers = await Players.getNbPlayersHaveStartedTheAdventure(); + const isUnranked = rank > numberOfPlayers; + const petEntity = player.petId ? await PetEntities.getById(player.petId) : null; + const petModel = player.petId ? PetDataController.instance.getById(petEntity.id) : null; + const missionsInfo = await PlayerMissionsInfos.getOfPlayer(player.id); + const playerActiveObjects = await InventorySlots.getMainSlotsItems(player.id); + const badges = player.badges === "" || !player.badges ? [] : player.badges.split("-"); + if (new Date().valueOf() - player.topggVoteAt.valueOf() < hoursToMilliseconds(Constants.TOPGG.BADGE_DURATION)) { + badges.push(Constants.TOPGG.BADGE); + } + const destinationId = player.getDestinationId(); + + response.push(makePacket(CommandGuildPacketRes, { + foundGuild: true, + data: { + name: guild.name, + description: guild.guildDescription, + chiefId: guild.chiefId, + elderId: guild.elderId, + level: guild.level, + experience: { + value: guild.experience, + max: guild.getExperienceNeededToLevelUp() + }, + rank: { + unranked: isUnranked, + rank, + numberOfGuilds: numberOfPlayers, + score: guild.score + }, + members: guild.members.map(member => ({ + keycloakId: member.keycloakId, + rank: member.rank, + score: member.score, + islandStatus: { + isOnPveIsland: member.isOnPveIsland, + isOnBoat: member.isOnBoat, + isPveIslandAlly: member.isPveIslandAlly, + isInactive: member.isInactive, + cannotBeJoinedOnBoat: member.cannotBeJoinedOnBoat + } + })) + } + + badges, + guild: guild?.name, + level: player.level, + rank: { + rank: isUnranked ? -1 : rank, + numberOfPlayers, + score: player.score, + unranked: isUnranked + }, + class: player.class, + color: player.getProfileColor(), + pet: petEntity ? { + id: petEntity.id, + nickname: petEntity.nickname, + rarity: petModel.rarity + } : null, + destination: destinationId, + effect: player.checkEffect() ? { + effect: player.effect, + timeLeft: player.effectEndDate.valueOf() - Date.now(), + healed: new Date() >= player.effectEndDate + } : null, + fightRanking: player.level >= FightConstants.REQUIRED_LEVEL ? { + glory: player.gloryPoints, + league: player.getLeague().id + } : null, + missions: { + gems: missionsInfo.gems, + campaignProgression: getCampaignProgression(missionsInfo) + }, + stats: player.level >= Constants.CLASS.REQUIRED_LEVEL ? { + attack: player.getCumulativeAttack(playerActiveObjects), + defense: player.getCumulativeDefense(playerActiveObjects), + speed: player.getCumulativeSpeed(playerActiveObjects), + energy: { + value: player.getCumulativeFightPoint(), + max: player.getMaxCumulativeFightPoint() + }, + breath: { + base: player.getBaseBreath(), + max: player.getMaxBreath(), + regen: player.getBreathRegen() + } + } : null, + experience: { + value: player.experience, + max: player.getExperienceNeededToLevelUp() + }, + health: { + value: player.health, + max: player.getMaxHealth() + }, + money: player.money + } + })); + } + } +} \ No newline at end of file diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index 9d171b2e1..6ee877c92 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -3,10 +3,7 @@ import {makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPac import {DraftbotInteraction} from "../../messages/DraftbotInteraction"; import i18n from "../../translations/i18n"; import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator"; -import { - CommandProfilePacketReq, - CommandProfilePacketRes -} from "../../../../Lib/src/packets/commands/CommandProfilePacket"; +import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; import {SlashCommandBuilder} from "@discordjs/builders"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; @@ -23,9 +20,11 @@ import {keycloakConfig} from "../../bot/DraftBotShard"; /** * Display all the information about a guild */ -async function getPacket(interaction: DraftbotInteraction, keycloakUser: KeycloakUser): Promise { +async function getPacket(interaction: DraftbotInteraction, keycloakUser: KeycloakUser): Promise { + + const guildNameOption = interaction.options.get("guildName"); + const askedGuildName = guildNameOption ? guildNameOption.value : undefined; - const askedGuildName = interaction.options.get('guildName'); let askedPlayer: { keycloakId?: string, rank?: number } = {keycloakId: keycloakUser.id}; const user = interaction.options.getUser("user"); @@ -37,15 +36,16 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa } askedPlayer = {keycloakId}; } - const rank = interaction.options.get("rank"); - if (rank) { - askedPlayer = {rank: rank.value}; + + const rankOption = interaction.options.get("rank"); + if (rankOption) { + askedPlayer = {rank: rankOption.value}; } - return makePacket(CommandGuildPacketReq, {askedPlayer}); + return makePacket(CommandGuildPacketReq, {askedPlayer, askedGuildName}); } -function generateFields(packet: CommandProfilePacketRes, language: Language): EmbedField[] { +function generateFields(packet: CommandGuildPacketRes, language: Language): EmbedField[] { const fields: EmbedField[] = []; fields.push({ diff --git a/Lib/src/packets/commands/CommandGuildPacket.ts b/Lib/src/packets/commands/CommandGuildPacket.ts index 21743cda0..4e63a4226 100644 --- a/Lib/src/packets/commands/CommandGuildPacket.ts +++ b/Lib/src/packets/commands/CommandGuildPacket.ts @@ -5,9 +5,42 @@ export class CommandGuildPacketReq extends DraftBotPacket { rank?: number, keycloakId?: string }; - guildName?: string; + + askedGuildName?: string; +} + +export interface GuildMemberPacket { + keycloakId: string; + rank: number, + score: number + islandStatus: { + isOnPveIsland: boolean, + isOnBoat: boolean, + isPveIslandAlly: boolean, + isInactive: boolean + cannotBeJoinedOnBoat: boolean + } } export class CommandGuildPacketRes extends DraftBotPacket { foundGuild!: boolean; + + data?: { + name: string, + description?: string, + chiefId: number, + elderId: number, + level: number, + experience: { + value: number, + max: number + }, + rank: { + unranked: boolean, + rank: number, + numberOfGuilds: number, + score: number + }, + members: GuildMemberPacket[] + }; } \ No newline at end of file From aaa11a31bf6737097acfd059e039e4e344b365a6 Mon Sep 17 00:00:00 2001 From: BastLast Date: Sat, 9 Mar 2024 23:52:41 +0100 Subject: [PATCH 03/10] finished core side of GuildCommand #2273 --- Core/src/commands/guild/GuildCommand.ts | 111 ++++--------------- Core/src/core/constants/PVEConstants.ts | 43 +++---- Core/src/core/database/game/models/Player.ts | 7 ++ 3 files changed, 53 insertions(+), 108 deletions(-) diff --git a/Core/src/commands/guild/GuildCommand.ts b/Core/src/commands/guild/GuildCommand.ts index 2d66088ec..34ebc3300 100644 --- a/Core/src/commands/guild/GuildCommand.ts +++ b/Core/src/commands/guild/GuildCommand.ts @@ -1,21 +1,17 @@ -import {PetEntities} from "../../core/database/game/models/PetEntity"; -import PlayerMissionsInfo, {PlayerMissionsInfos} from "../../core/database/game/models/PlayerMissionsInfo"; -import {InventorySlots} from "../../core/database/game/models/InventorySlot"; -import {FightConstants} from "../../core/constants/FightConstants"; import {packetHandler} from "../../core/packetHandlers/PacketHandler"; import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient"; import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; import {Players} from "../../core/database/game/models/Player"; import {Guild, Guilds} from "../../core/database/game/models/Guild"; -import {Constants} from "../../core/Constants"; -import {hoursToMilliseconds} from "../../../../Lib/src/utils/TimeUtils"; -import {PetDataController} from "../../data/Pet"; import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; +import {Maps} from "../../core/maps/Maps"; +import {MapCache} from "../../core/maps/MapCache"; export default class GuildCommand { @packetHandler(CommandGuildPacketReq) async execute(client: WebsocketClient, packet: CommandGuildPacketReq, context: PacketContext, response: DraftBotPacket[]): Promise { let guild: Guild; + const player = packet.askedPlayer.keycloakId ? await Players.getByKeycloakId(packet.askedPlayer.keycloakId) : await Players.getByRank(packet.askedPlayer.rank); if (packet.askedGuildName) { try { guild = await Guilds.getByName(packet.askedGuildName); @@ -25,7 +21,6 @@ export default class GuildCommand { } } else { - const player = packet.askedPlayer.keycloakId ? await Players.getByKeycloakId(packet.askedPlayer.keycloakId) : await Players.getByRank(packet.askedPlayer.rank); guild = player.guildId ? await Guilds.getById(player.guildId) : null; } @@ -35,18 +30,11 @@ export default class GuildCommand { })); } else { - const rank = await Players.getRankById(player.id); - const numberOfPlayers = await Players.getNbPlayersHaveStartedTheAdventure(); - const isUnranked = rank > numberOfPlayers; - const petEntity = player.petId ? await PetEntities.getById(player.petId) : null; - const petModel = player.petId ? PetDataController.instance.getById(petEntity.id) : null; - const missionsInfo = await PlayerMissionsInfos.getOfPlayer(player.id); - const playerActiveObjects = await InventorySlots.getMainSlotsItems(player.id); - const badges = player.badges === "" || !player.badges ? [] : player.badges.split("-"); - if (new Date().valueOf() - player.topggVoteAt.valueOf() < hoursToMilliseconds(Constants.TOPGG.BADGE_DURATION)) { - badges.push(Constants.TOPGG.BADGE); - } - const destinationId = player.getDestinationId(); + const members = await Players.getByGuild(guild.id); + const rank = await guild.getRanking(); + const numberOfGuilds = await Guilds.getTotalRanked(); + const membersPveAlliesIds = (await Maps.getGuildMembersOnPveIsland(player)).map((player) => player.id); + const isUnranked = rank > -1; response.push(makePacket(CommandGuildPacketRes, { foundGuild: true, @@ -63,76 +51,23 @@ export default class GuildCommand { rank: { unranked: isUnranked, rank, - numberOfGuilds: numberOfPlayers, + numberOfGuilds, score: guild.score }, - members: guild.members.map(member => ({ - keycloakId: member.keycloakId, - rank: member.rank, - score: member.score, - islandStatus: { - isOnPveIsland: member.isOnPveIsland, - isOnBoat: member.isOnBoat, - isPveIslandAlly: member.isPveIslandAlly, - isInactive: member.isInactive, - cannotBeJoinedOnBoat: member.cannotBeJoinedOnBoat - } - })) - } - - badges, - guild: guild?.name, - level: player.level, - rank: { - rank: isUnranked ? -1 : rank, - numberOfPlayers, - score: player.score, - unranked: isUnranked - }, - class: player.class, - color: player.getProfileColor(), - pet: petEntity ? { - id: petEntity.id, - nickname: petEntity.nickname, - rarity: petModel.rarity - } : null, - destination: destinationId, - effect: player.checkEffect() ? { - effect: player.effect, - timeLeft: player.effectEndDate.valueOf() - Date.now(), - healed: new Date() >= player.effectEndDate - } : null, - fightRanking: player.level >= FightConstants.REQUIRED_LEVEL ? { - glory: player.gloryPoints, - league: player.getLeague().id - } : null, - missions: { - gems: missionsInfo.gems, - campaignProgression: getCampaignProgression(missionsInfo) - }, - stats: player.level >= Constants.CLASS.REQUIRED_LEVEL ? { - attack: player.getCumulativeAttack(playerActiveObjects), - defense: player.getCumulativeDefense(playerActiveObjects), - speed: player.getCumulativeSpeed(playerActiveObjects), - energy: { - value: player.getCumulativeFightPoint(), - max: player.getMaxCumulativeFightPoint() - }, - breath: { - base: player.getBaseBreath(), - max: player.getMaxBreath(), - regen: player.getBreathRegen() - } - } : null, - experience: { - value: player.experience, - max: player.getExperienceNeededToLevelUp() - }, - health: { - value: player.health, - max: player.getMaxHealth() - }, - money: player.money + members: await Promise.all( + members.map(async member => ({ + keycloakId: member.keycloakId, + rank: await Players.getRankById(member.id), + score: member.score, + islandStatus: { + isOnPveIsland: Maps.isOnPveIsland(member), + isOnBoat: MapCache.boatEntryMapLinks.includes(member.mapLinkId), + isPveIslandAlly: membersPveAlliesIds.includes(member.id), + isInactive: member.isInactive(), + cannotBeJoinedOnBoat: member.isNotActiveEnoughToBeJoinedInTheBoat() + } + })) + ) } })); } diff --git a/Core/src/core/constants/PVEConstants.ts b/Core/src/core/constants/PVEConstants.ts index 9236261fb..06737d870 100644 --- a/Core/src/core/constants/PVEConstants.ts +++ b/Core/src/core/constants/PVEConstants.ts @@ -1,25 +1,28 @@ export abstract class PVEConstants { + + static readonly TIME_AFTER_INACTIVITY_ON_BOAT_IS_NOT_ACCEPTED = 24 * 3 * 3600 * 1000; // 3 days; + static readonly TIME_BETWEEN_SMALL_EVENTS = 18 * 1000; // 18 seconds - static TRAVEL_COST = [0, 15, 25]; + static readonly TRAVEL_COST = [0, 15, 25]; - static COLLECTOR_TIME = 30000; + static readonly COLLECTOR_TIME = 30000; - static FIGHT_POINTS_SMALL_EVENT = { + static readonly FIGHT_POINTS_SMALL_EVENT = { MIN_PERCENT: 0.02, MAX_PERCENT: 0.07 }; - static MIN_LEVEL = 20; + static readonly MIN_LEVEL = 20; - static MONSTER_LEVEL_RANDOM_RANGE = 10; + static readonly MONSTER_LEVEL_RANDOM_RANGE = 10; /** * The formula is * f(x) = ax² + bx + c * with x the monster lvl */ - static STATS_FORMULA = { + static readonly STATS_FORMULA = { ATTACK: { A: 0.02825, B: 0.94359, @@ -43,7 +46,7 @@ export abstract class PVEConstants { }; // Allow commands is better than disallowed commands because if there is a new command it will not be allowed by default - static ALLOWED_COMMANDS = [ + static readonly ALLOWED_COMMANDS = [ "guild", "guildcreate", "guilddescription", @@ -93,7 +96,7 @@ export abstract class PVEConstants { * f(x) = ax + b * for the level multiplier */ - static FIGHT_REWARDS = { + static readonly FIGHT_REWARDS = { TOTAL_RATIO_RANDOM_RANGE: 0.1, GUILD_SCORE_MULTIPLIER: 10, XP: { @@ -117,27 +120,27 @@ export abstract class PVEConstants { } }; - static OUT_OF_BREATH_CHOOSE_PROBABILITY = 0.1; + static readonly OUT_OF_BREATH_CHOOSE_PROBABILITY = 0.1; - static GUILD_ATTACK_PROBABILITY = 0.25; + static readonly GUILD_ATTACK_PROBABILITY = 0.25; - static MINIMAL_ENERGY_RATIO = 0.8; + static readonly MINIMAL_ENERGY_RATIO = 0.8; - static RAGE_MIN_MULTIPLIER = 1; + static readonly RAGE_MIN_MULTIPLIER = 1; - static MINUTES_CHECKED_FOR_PLAYERS_THAT_WERE_ON_THE_ISLAND = 60; + static readonly MINUTES_CHECKED_FOR_PLAYERS_THAT_WERE_ON_THE_ISLAND = 60; - static RAGE_MAX_DAMAGE = 250; + static readonly RAGE_MAX_DAMAGE = 250; - static DAMAGE_INCREASED_DURATION = 7; + static readonly DAMAGE_INCREASED_DURATION = 7; - static MONEY_MALUS_MULTIPLIER_FOR_GUILD_PLAYERS = 1; + static readonly MONEY_MALUS_MULTIPLIER_FOR_GUILD_PLAYERS = 1; - static MONEY_MALUS_MULTIPLIER_FOR_SOLO_PLAYERS = 2; + static readonly MONEY_MALUS_MULTIPLIER_FOR_SOLO_PLAYERS = 2; - static MONEY_LOST_PER_LEVEL_ON_DEATH = 3.4; + static readonly MONEY_LOST_PER_LEVEL_ON_DEATH = 3.4; - static GUILD_POINTS_LOST_ON_DEATH = 150; + static readonly GUILD_POINTS_LOST_ON_DEATH = 150; - static RANDOM_RANGE_FOR_GUILD_POINTS_LOST_ON_DEATH = 20; + static readonly RANDOM_RANGE_FOR_GUILD_POINTS_LOST_ON_DEATH = 20; } diff --git a/Core/src/core/database/game/models/Player.ts b/Core/src/core/database/game/models/Player.ts index 9e1fad73e..836c0668b 100644 --- a/Core/src/core/database/game/models/Player.ts +++ b/Core/src/core/database/game/models/Player.ts @@ -359,6 +359,13 @@ export class Player extends Model { return this.startTravelDate.valueOf() + TopConstants.FIFTEEN_DAYS < Date.now(); } + /** + * Check if the player is not active enough to be joined in the boat + */ + public isNotActiveEnoughToBeJoinedInTheBoat(): boolean { + return this.startTravelDate.valueOf() + PVEConstants.TIME_AFTER_INACTIVITY_ON_BOAT_IS_NOT_ACCEPTED < Date.now(); + } + /** * Check if the player is in guild */ From a9f9e6628785fa8e46cd6541ab73cdb6453959d3 Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 10 Mar 2024 00:19:28 +0100 Subject: [PATCH 04/10] WIP GuildCommand #2273 --- Core/src/commands/guild/GuildCommand.ts | 1 + Discord/src/commands/guild/GuildCommand.ts | 13 ++++++++----- Lang/fr/commands.json | 2 +- Lang/fr/error.json | 3 ++- Lib/src/packets/commands/CommandGuildPacket.ts | 4 +++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Core/src/commands/guild/GuildCommand.ts b/Core/src/commands/guild/GuildCommand.ts index 34ebc3300..9ba70bcee 100644 --- a/Core/src/commands/guild/GuildCommand.ts +++ b/Core/src/commands/guild/GuildCommand.ts @@ -38,6 +38,7 @@ export default class GuildCommand { response.push(makePacket(CommandGuildPacketRes, { foundGuild: true, + askedPlayerKeycloakId: player.keycloakId, data: { name: guild.name, description: guild.guildDescription, diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index 6ee877c92..586ddc1f7 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -186,26 +186,29 @@ function generateFields(packet: CommandGuildPacketRes, language: Language): Embe return fields; } -export async function handleCommandProfilePacketRes(packet: CommandProfilePacketRes, context: PacketContext): Promise { +export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, context: PacketContext): Promise { const interaction = DiscordCache.getInteraction(context.discord!.interaction); if (interaction) { - if (!packet.foundPlayer) { + if (!packet.foundGuild) { await interaction.reply({ embeds: [ new DraftBotErrorEmbed( interaction.user, interaction, - i18n.t("error:playerDoesntExist", {lng: interaction.userLanguage}) + i18n.t("error:guildDoesntExist", {lng: interaction.userLanguage}) ) ] }); return; } - const keycloakUser = (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.keycloakId!))!; + const keycloakUser = (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.askedPlayerKeycloakId!))!; + + const guildCommandEmbed = new DraftBotEmbed() + .setThumbnail(GuildConstants.ICON); + - const titleEffect = packet.data?.effect?.healed ? Constants.DEFAULT_HEALED_EFFECT : packet.data?.effect; const reply = await interaction.reply({ embeds: [ new DraftBotEmbed() diff --git a/Lang/fr/commands.json b/Lang/fr/commands.json index 155caa991..2effef1d1 100644 --- a/Lang/fr/commands.json +++ b/Lang/fr/commands.json @@ -367,7 +367,7 @@ "encounterMonster": [ "Vous arrivez à votre destination quand soudain, vous entendez un bruit derrière vous... Un monstre vous attaque !" ], - "encounterMonsterStats": "> **{{emoji}} {{monsterName}} **| **Niveau {{level}}**\n> {{description}}\n\n⚡ {{fightPoints}} | \uD83D\uDDE1 {{attack}} | \uD83D\uDEE1 {{defense}} | \uD83D\uDE80 {{speed}}", + "encounterMonsterStats": "> **{{emoji}} {{monsterName}} **| **Niveau {{level}}**\n> {{description}}\n\n⚡ {{fightPoints}} | 🗡 {{attack}} | 🛡 {{defense}} | 🚀 {{speed}}", "monsterRewardsTitle": "{{pseudo}}, récompenses de combat", "monsterRewardsDescription": ":moneybag: Argent gagné : **{{money}}**\n:star: XP gagnée : **{{experience}}**", "monsterRewardGuildXp": "\n:star: XP de guilde gagnée: **{{guildXp}}**", diff --git a/Lang/fr/error.json b/Lang/fr/error.json index 60e72e698..315f92902 100644 --- a/Lang/fr/error.json +++ b/Lang/fr/error.json @@ -48,5 +48,6 @@ "startBossFight": "début d'un combat de boss", "reportCommand": "commande rapport", "cartChoose": "choix de monter dans la charrette ou non" - } + }, + "guildDoesntExist": "La guilde demandée n'existe pas" } \ No newline at end of file diff --git a/Lib/src/packets/commands/CommandGuildPacket.ts b/Lib/src/packets/commands/CommandGuildPacket.ts index 4e63a4226..72a62025c 100644 --- a/Lib/src/packets/commands/CommandGuildPacket.ts +++ b/Lib/src/packets/commands/CommandGuildPacket.ts @@ -1,7 +1,7 @@ import {DraftBotPacket} from "../DraftBotPacket"; export class CommandGuildPacketReq extends DraftBotPacket { - askedPlayer?: { + askedPlayer!: { rank?: number, keycloakId?: string }; @@ -25,6 +25,8 @@ export interface GuildMemberPacket { export class CommandGuildPacketRes extends DraftBotPacket { foundGuild!: boolean; + askedPlayerKeycloakId? : string; + data?: { name: string, description?: string, From 6bca777f17234f39d0cdd1a51b3600cc79553131 Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 10 Mar 2024 11:06:50 +0100 Subject: [PATCH 05/10] merged discord constants in lib #2426 --- Discord/src/bot/DiscordCache.ts | 2 +- Discord/src/bot/DraftBotShard.ts | 2 +- Discord/src/commands/CommandsManager.ts | 2 +- Discord/src/commands/admin/LanguageCommand.ts | 7 +++---- Discord/src/commands/admin/TestCommand.ts | 2 +- Discord/src/commands/guild/GuildCommand.ts | 4 ++-- Discord/src/commands/player/HelpCommand.ts | 2 +- Discord/src/commands/player/InventoryCommand.ts | 2 +- Discord/src/commands/player/ProfileCommand.ts | 4 ++-- Discord/src/commands/player/ReportCommand.ts | 2 +- Discord/src/messages/DraftBotEmbed.ts | 2 +- Discord/src/messages/DraftBotReactionMessage.ts | 2 +- {Discord/src => Lib/src/constants}/Constants.ts | 2 +- {Discord => Lib}/src/constants/HelpConstants.ts | 0 {Discord => Lib}/src/constants/PermissionsConstants.ts | 0 {Discord => Lib}/src/constants/ProfileConstants.ts | 0 16 files changed, 17 insertions(+), 18 deletions(-) rename {Discord/src => Lib/src/constants}/Constants.ts (95%) rename {Discord => Lib}/src/constants/HelpConstants.ts (100%) rename {Discord => Lib}/src/constants/PermissionsConstants.ts (100%) rename {Discord => Lib}/src/constants/ProfileConstants.ts (100%) diff --git a/Discord/src/bot/DiscordCache.ts b/Discord/src/bot/DiscordCache.ts index f7f5e2e13..2b9e329ce 100644 --- a/Discord/src/bot/DiscordCache.ts +++ b/Discord/src/bot/DiscordCache.ts @@ -1,5 +1,5 @@ import {DraftbotInteraction} from "../messages/DraftbotInteraction"; -import {Constants} from "../Constants"; +import {Constants} from "../../../Lib/src/constants/Constants"; export class DiscordCache { private static initialized = false; diff --git a/Discord/src/bot/DraftBotShard.ts b/Discord/src/bot/DraftBotShard.ts index f1a771550..927dad0c6 100644 --- a/Discord/src/bot/DraftBotShard.ts +++ b/Discord/src/bot/DraftBotShard.ts @@ -1,5 +1,5 @@ import {Client, Guild, IntentsBitField, Partials, TextChannel} from "discord.js"; -import {Constants} from "../Constants"; +import {Constants} from "../../../Lib/src/constants/Constants"; import {loadConfig} from "../config/DiscordConfig"; import i18n from "../translations/i18n"; import {BotUtils} from "../utils/BotUtils"; diff --git a/Discord/src/commands/CommandsManager.ts b/Discord/src/commands/CommandsManager.ts index 9b04df77d..160b0841e 100644 --- a/Discord/src/commands/CommandsManager.ts +++ b/Discord/src/commands/CommandsManager.ts @@ -21,7 +21,7 @@ import {KeycloakUser} from "../../../Lib/src/keycloak/KeycloakUser"; import {readdirSync} from "fs"; import i18n from "../translations/i18n"; import {replyErrorMessage} from "../utils/ErrorUtils"; -import {Constants} from "../Constants"; +import {Constants} from "../../../Lib/src/constants/Constants"; import {DraftBotEmbed} from "../messages/DraftBotEmbed"; import {escapeUsername} from "../../../Lib/src/utils/StringUtils"; import {DraftBotReactionMessageBuilder} from "../messages/DraftBotReactionMessage"; diff --git a/Discord/src/commands/admin/LanguageCommand.ts b/Discord/src/commands/admin/LanguageCommand.ts index c82c50a76..5ba152759 100644 --- a/Discord/src/commands/admin/LanguageCommand.ts +++ b/Discord/src/commands/admin/LanguageCommand.ts @@ -12,7 +12,7 @@ import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; import {keycloakConfig} from "../../bot/DraftBotShard"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {sendInteractionNotForYou} from "../../utils/ErrorUtils"; import {LANGUAGE, Language} from "../../../../Lib/src/Language"; @@ -26,8 +26,7 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa .map((languageCode) => new StringSelectMenuOptionBuilder() .setLabel(i18n.t(`commands:language.languages.${languageCode}.name`, {lng: interaction.userLanguage})) .setEmoji(i18n.t(`commands:language.languages.${languageCode}.emoji`, {lng: interaction.userLanguage})) - .setValue(languageCode) - ); + .setValue(languageCode)); const languageSelectionMenu = new StringSelectMenuBuilder() .setCustomId(selectLanguageMenuId) @@ -70,7 +69,7 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa .setDescription(i18n.t("commands:language.newLanguageSetDescription", { lng: menuInteraction.values[0] as Language }))] - }) + }); }); return null; } diff --git a/Discord/src/commands/admin/TestCommand.ts b/Discord/src/commands/admin/TestCommand.ts index f80e865c8..07b4e70e2 100644 --- a/Discord/src/commands/admin/TestCommand.ts +++ b/Discord/src/commands/admin/TestCommand.ts @@ -7,7 +7,7 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {HexColorString} from "discord.js"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; async function getPacket(interaction: DraftbotInteraction, user: KeycloakUser): Promise { diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index 586ddc1f7..da80687dc 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -8,10 +8,10 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {ColorResolvable, EmbedField, Message, MessageReaction} from "discord.js"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; -import {ProfileConstants} from "../../constants/ProfileConstants"; +import {ProfileConstants} from "../../../../Lib/src/constants/ProfileConstants"; import {Language} from "../../../../Lib/src/Language"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; diff --git a/Discord/src/commands/player/HelpCommand.ts b/Discord/src/commands/player/HelpCommand.ts index a529d2de3..1ed53ed1f 100644 --- a/Discord/src/commands/player/HelpCommand.ts +++ b/Discord/src/commands/player/HelpCommand.ts @@ -7,7 +7,7 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {BotUtils} from "../../utils/BotUtils"; import {LANGUAGE, Language} from "../../../../Lib/src/Language"; import {PetConstants} from "../../../../Lib/src/constants/PetConstants"; -import {HelpConstants} from "../../constants/HelpConstants"; +import {HelpConstants} from "../../../../Lib/src/constants/HelpConstants"; /** * Get the list of commands mention from the command data diff --git a/Discord/src/commands/player/InventoryCommand.ts b/Discord/src/commands/player/InventoryCommand.ts index 8606f20b1..7147fd509 100644 --- a/Discord/src/commands/player/InventoryCommand.ts +++ b/Discord/src/commands/player/InventoryCommand.ts @@ -7,7 +7,7 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, EmbedField} from "discord.js"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; import {Language} from "../../../../Lib/src/Language"; diff --git a/Discord/src/commands/player/ProfileCommand.ts b/Discord/src/commands/player/ProfileCommand.ts index b0f7cbcca..8b50a77df 100644 --- a/Discord/src/commands/player/ProfileCommand.ts +++ b/Discord/src/commands/player/ProfileCommand.ts @@ -8,10 +8,10 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {ColorResolvable, EmbedField, Message, MessageReaction} from "discord.js"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; -import {ProfileConstants} from "../../constants/ProfileConstants"; +import {ProfileConstants} from "../../../../Lib/src/constants/ProfileConstants"; import {Language} from "../../../../Lib/src/Language"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; diff --git a/Discord/src/commands/player/ReportCommand.ts b/Discord/src/commands/player/ReportCommand.ts index 9fd633350..a67b1c11e 100644 --- a/Discord/src/commands/player/ReportCommand.ts +++ b/Discord/src/commands/player/ReportCommand.ts @@ -25,7 +25,7 @@ import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotIcons} from "../../../../Lib/src/DraftBotIcons"; import {sendInteractionNotForYou} from "../../utils/ErrorUtils"; import {DiscordWebSocket} from "../../bot/Websocket"; -import {Constants} from "../../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; async function getPacket(interaction: DraftbotInteraction, user: KeycloakUser): Promise { await interaction.deferReply(); diff --git a/Discord/src/messages/DraftBotEmbed.ts b/Discord/src/messages/DraftBotEmbed.ts index 6df6c4093..05736b869 100644 --- a/Discord/src/messages/DraftBotEmbed.ts +++ b/Discord/src/messages/DraftBotEmbed.ts @@ -1,5 +1,5 @@ import {EmbedBuilder, HexColorString, User} from "discord.js"; -import {Constants} from "../Constants"; +import {Constants} from "../../../Lib/src/constants/Constants"; /** * Base class for bot embeds diff --git a/Discord/src/messages/DraftBotReactionMessage.ts b/Discord/src/messages/DraftBotReactionMessage.ts index 9d13e6d0c..d3646d2ae 100644 --- a/Discord/src/messages/DraftBotReactionMessage.ts +++ b/Discord/src/messages/DraftBotReactionMessage.ts @@ -1,6 +1,6 @@ import {GuildEmoji, Message, MessageReaction, ReactionCollector, User} from "discord.js"; import {CallbackLike, DraftBotReaction} from "./DraftBotReaction"; -import {Constants} from "../Constants"; +import {Constants} from "../../../Lib/src/constants/Constants"; import {DraftBotEmbed} from "./DraftBotEmbed"; import {DraftbotChannel, DraftbotInteraction} from "./DraftbotInteraction"; import {draftBotClient} from "../bot/DraftBotShard"; diff --git a/Discord/src/Constants.ts b/Lib/src/constants/Constants.ts similarity index 95% rename from Discord/src/Constants.ts rename to Lib/src/constants/Constants.ts index 539d65b8c..0b2fb1d7f 100644 --- a/Discord/src/Constants.ts +++ b/Lib/src/constants/Constants.ts @@ -1,5 +1,5 @@ export class Constants { - static readonly VERSION = import("../package.json").then(json => json.version); + static readonly VERSION = import("../../../Discord/package.json").then(json => json.version); static readonly MAX_TIME_BOT_RESPONSE = 30000; diff --git a/Discord/src/constants/HelpConstants.ts b/Lib/src/constants/HelpConstants.ts similarity index 100% rename from Discord/src/constants/HelpConstants.ts rename to Lib/src/constants/HelpConstants.ts diff --git a/Discord/src/constants/PermissionsConstants.ts b/Lib/src/constants/PermissionsConstants.ts similarity index 100% rename from Discord/src/constants/PermissionsConstants.ts rename to Lib/src/constants/PermissionsConstants.ts diff --git a/Discord/src/constants/ProfileConstants.ts b/Lib/src/constants/ProfileConstants.ts similarity index 100% rename from Discord/src/constants/ProfileConstants.ts rename to Lib/src/constants/ProfileConstants.ts From dbb284000d8466322b82e9b4272447063b3b3678 Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 10 Mar 2024 11:14:29 +0100 Subject: [PATCH 06/10] merged core constants in lib #2426 --- Core/src/core/Constants.ts | 272 ------------------ Core/src/core/bot/DraftBot.ts | 2 +- Core/src/core/constants/PetConstants.ts | 53 ---- .../core/database/game/models/PetEntity.ts | 2 +- .../core/smallEvents/fightPet/usePlayerPet.ts | 2 +- .../src}/constants/BlockingConstants.ts | 0 .../src}/constants/BotConstants.ts | 0 .../src}/constants/ClassInfoConstants.ts | 0 Lib/src/constants/Constants.ts | 246 +++++++++++++++- .../src}/constants/DailyConstants.ts | 0 .../src}/constants/EntityConstants.ts | 0 .../src}/constants/FightConstants.ts | 0 .../src}/constants/GuildConstants.ts | 0 .../src}/constants/GuildCreateConstants.ts | 0 .../src}/constants/GuildDailyConstants.ts | 0 .../src}/constants/InventoryConstants.ts | 0 .../src}/constants/LeagueInfoConstants.ts | 0 .../src}/constants/LogsConstants.ts | 0 .../src}/constants/MapConstants.ts | 0 .../src}/constants/PVEConstants.ts | 0 .../src}/constants/PetEntityConstants.ts | 0 .../src}/constants/PetFreeConstants.ts | 0 .../src}/constants/PetSellConstants.ts | 0 .../src}/constants/PetTradeConstants.ts | 0 .../src}/constants/PlayerConstants.ts | 0 .../src}/constants/PlayersConstants.ts | 0 .../src}/constants/ReportConstants.ts | 0 .../src}/constants/RespawnConstants.ts | 0 .../src}/constants/SmallEventConstants.ts | 0 .../src}/constants/SpaceConstants.ts | 0 .../constants/TimeoutFunctionsConstants.ts | 0 .../src}/constants/UnlockConstants.ts | 0 32 files changed, 238 insertions(+), 339 deletions(-) delete mode 100644 Core/src/core/Constants.ts delete mode 100644 Core/src/core/constants/PetConstants.ts rename {Core/src/core => Lib/src}/constants/BlockingConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/BotConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/ClassInfoConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/DailyConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/EntityConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/FightConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/GuildConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/GuildCreateConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/GuildDailyConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/InventoryConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/LeagueInfoConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/LogsConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/MapConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PVEConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PetEntityConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PetFreeConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PetSellConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PetTradeConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PlayerConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/PlayersConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/ReportConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/RespawnConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/SmallEventConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/SpaceConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/TimeoutFunctionsConstants.ts (100%) rename {Core/src/core => Lib/src}/constants/UnlockConstants.ts (100%) diff --git a/Core/src/core/Constants.ts b/Core/src/core/Constants.ts deleted file mode 100644 index 26e24b338..000000000 --- a/Core/src/core/Constants.ts +++ /dev/null @@ -1,272 +0,0 @@ -export type ConstantRange = { MIN: number, MAX: number }; - -export abstract class Constants { - static readonly REACTIONS = { - VALIDATE_REACTION: "✅", - REFUSE_REACTION: "❌", - WAIT_A_BIT_REACTION: "⏳", - START_FIGHT_REACTION: "⚔️", - NOT_REPLIED_REACTION: "🔚", - SHOPPING_CART: "🛒", - WARNING: "⚠️", - NUMBERS: [ - "0️⃣", - "1️⃣", - "2️⃣", - "3️⃣", - "4️⃣", - "5️⃣", - "6️⃣", - "7️⃣", - "8️⃣", - "9️⃣", - "🔟" - ], - FRENCH_FLAG: "🇫🇷", - ENGLISH_FLAG: "🇬🇧", - INVENTORY_RESERVE: "🔃", - MONEY_ICON: "💰", - TRASH: "🗑️", - INVENTORY_EXTENSION: "📦", - ITEM_CATEGORIES: [ - "⚔️", - "🛡️", - "⚗️", - "🧸" - ] - }; - - static readonly MESSAGES = { - COLLECTOR_TIME: 120000, - COLORS: { - DEFAULT: "default", - ERROR: "#D92D43", - SUCCESSFUL: "#5EAD45" - }, - PROGRESS_BAR_SIZE: 20, - MAX_SPAM_COUNT: 3, - DEFAULT_REACTION_LIMIT: 1 - }; - - static readonly TOPGG = { - BADGE: "🗳️", - BADGE_DURATION: 12, - ROLE_DURATION: 24 - }; - - static readonly XP = { - BASE_VALUE: 325, - COEFFICIENT: 1.041, - MINUS: 188 - }; - - static readonly ITEM_NATURE = { - NO_EFFECT: 0, - HEALTH: 1, - SPEED: 2, - ATTACK: 3, - DEFENSE: 4, - TIME_SPEEDUP: 5, - MONEY: 6 - }; - - static readonly REPORT = { - HOURS_USED_TO_CALCULATE_FIRST_REPORT_REWARD: 1, // Used to get the amount of point a user will get in the first report, 1 hour = 60 points ( + some bonus ) - TIME_BETWEEN_BIG_EVENTS: 2 * 60 * 60 * 1000, // 2 hours - BONUS_POINT_TIME_DIVIDER: 6, - POINTS_BY_SMALL_EVENT: 50, - PATH_SQUARE_COUNT: 16, - TIME_BETWEEN_MINI_EVENTS: 9.75 * 60 * 1000, // 9 minutes and 45 seconds - AUTO_CHOOSE_DESTINATION_CHANCE: 0.15 // 15% - }; - - // This constant represent the different types of values on which the players can be ranked - static readonly RANK_TYPES = { - LEVEL: "level", - SCORE: "score", - WEEKLY_SCORE: "weeklyScore", - LAST_SEASON_GLORY: "gloryPointsLastSeason" - }; - - static readonly CLASS = { - REQUIRED_LEVEL: 4, - PRICE: 5000, - GROUP1LEVEL: 16, - GROUP2LEVEL: 32, - GROUP3LEVEL: 48, - GROUP4LEVEL: 80, - TIME_BEFORE_CHANGE_CLASS: [ - 2 * 7 * 24 * 60 * 60, // 2 weeks - 2 * 7 * 24 * 60 * 60, // 2 weeks - 4 * 7 * 24 * 60 * 60, // 4 weeks - 4 * 7 * 24 * 60 * 60, // 4 weeks - 4 * 7 * 24 * 60 * 60 // 4 weeks - ] - }; - - static readonly CLASSES = { - RECRUIT: 0, - FIGHTER: 1, - SOLDIER: 2, - INFANTRYMAN: 3, - GLOVED: 4, - HELMETED: 5, - ENMESHED: 6, - TANK: 7, - ROCK_THROWER: 8, - SLINGER: 9, - ARCHER: 10, - GUNNER: 11, - ESQUIRE: 12, - HORSE_RIDER: 13, - PIKEMAN: 14, - KNIGHT: 15, - PALADIN: 16, - VETERAN: 17, - POWERFUL_INFANTRYMAN: 18, - IMPENETRABLE_TANK: 19, - FORMIDABLE_GUNNER: 20, - VALIANT_KNIGHT: 21, - LUMINOUS_PALADIN: 22, - EXPERIENCED_VETERAN: 23, - MYSTIC_MAGE: 24 - }; - - static readonly LOGS = { - LOG_COUNT_LINE_LIMIT: 50000 - }; - - static readonly MISSION_SHOP = { - RANGE_MISSION_MONEY: 1350, - BASE_RATIO: 6500, - SEED_RANGE: 1000 - }; - - static readonly BEGINNING = { - START_MAP_LINK: 83, - LAST_MAP_LINK: 77 - }; - - static readonly MISSIONS = { - SLOT_3_LEVEL: 55, - SLOT_2_LEVEL: 25, - SLOTS_LEVEL_PROBABILITIES: [ - { - LEVEL: 0, - EASY: 1, - MEDIUM: 0, - HARD: 0 - }, - { - LEVEL: 10, - EASY: 0.75, - MEDIUM: 0.25, - HARD: 0 - }, - { - LEVEL: 20, - EASY: 0.4, - MEDIUM: 0.6, - HARD: 0 - }, - { - LEVEL: 40, - EASY: 0.25, - MEDIUM: 0.65, - HARD: 0.1 - }, - { - LEVEL: 50, - EASY: 0.2, - MEDIUM: 0.55, - HARD: 0.25 - }, - { - LEVEL: 60, - EASY: 0.1, - MEDIUM: 0.4, - HARD: 0.5 - } - ], - DAILY_MISSION_MONEY_MULTIPLIER: 0.5, - DAILY_MISSION_POINTS_MULTIPLIER: 3.5 - }; - - static readonly BADGES = { - POWERFUL_GUILD: "💎", - VERY_POWERFUL_GUILD: "🪩", - STAFF_MEMBER: "⚙️", - QUEST_MASTER: "💍", - RICH_PERSON: "🤑", - PET_TAMER: "💞", - LIST_FOR_GIVE_BADGE_COMMAND: [ - "🏅", - "⚙️", - "✨", - "❤️", - "🍀", - "💸", - "🐞", - "🎰", - "🥇", - "🤑", - "🌟", - "🖋️", - "🌍", - "🎗️", - "🎄", - "😂", - "💎", - "⚔️", - "🗳️", - "💞", - "💍", - "🪩", - "🕊️" - ] - }; - - static readonly PET_FOOD = { - COMMON_FOOD: "commonFood", - CARNIVOROUS_FOOD: "carnivorousFood", - HERBIVOROUS_FOOD: "herbivorousFood", - ULTIMATE_FOOD: "ultimateFood" - }; - - static readonly PET_FOOD_GUILD_SHOP = { - TYPE: [ - "commonFood", - "herbivorousFood", - "carnivorousFood", - "ultimateFood" - ], - EMOTE: [ - "\uD83C\uDF6C", - "\uD83E\uDD6C", - "\uD83E\uDD69", - "\uD83C\uDF72" - ], - PRICE: [ - 20, - 250, - 250, - 600 - ], - EFFECT: [ - 1, - 3, - 3, - 5 - ] - }; - - static readonly MINIMAL_PLAYER_SCORE = 100; - - - static readonly MAX_DAILY_POTION_BUYOUTS: number = 5; - - static EXCLUDED_TRANSLATION_MODULES = [ - "classes.", - "advices" - ]; -} \ No newline at end of file diff --git a/Core/src/core/bot/DraftBot.ts b/Core/src/core/bot/DraftBot.ts index 31dc8b50e..1f4dc2acd 100644 --- a/Core/src/core/bot/DraftBot.ts +++ b/Core/src/core/bot/DraftBot.ts @@ -4,7 +4,7 @@ import {GameDatabase} from "../database/game/GameDatabase"; import {LogsDatabase} from "../database/logs/LogsDatabase"; import {draftBotInstance} from "../../index"; import {Settings} from "../database/game/models/Setting"; -import {PetConstants} from "../constants/PetConstants"; +import {PetConstants} from "../../../../Lib/src/constants/PetConstants"; import {Op} from "sequelize"; import PetEntity from "../database/game/models/PetEntity"; import {RandomUtils} from "../utils/RandomUtils"; diff --git a/Core/src/core/constants/PetConstants.ts b/Core/src/core/constants/PetConstants.ts deleted file mode 100644 index 35c74cc83..000000000 --- a/Core/src/core/constants/PetConstants.ts +++ /dev/null @@ -1,53 +0,0 @@ -export abstract class PetConstants { - static readonly IS_FOOD = 1; - - static readonly NICKNAME_LENGTH_RANGE = { - MIN: 3, - MAX: 16 - }; - - static readonly SEX = { - MALE: "m", - FEMALE: "f" - }; - - static readonly PET_INTERACTIONS = { - WIN_MONEY: "money", - WIN_HEALTH: "gainLife", - WIN_LOVE: "gainLove", - WIN_ENERGY: "gainEnergy", - WIN_FOOD: "food", - NOTHING: "nothing", - WIN_TIME: "gainTime", - WIN_POINTS: "points", - WIN_BADGE: "badge", - LOSE_HEALTH: "loseLife", - LOSE_MONEY: "loseMoney", - LOSE_TIME: "loseTime", - PET_FLEE: "petFlee", - LOSE_LOVE: "loseLove" - }; - - static readonly BREED_COOLDOWN = 60 * 60 * 1000; // 1 hour - - static readonly MAX_LOVE_POINTS = 100; - - static readonly BASE_LOVE = 10; - - static readonly GUILD_LEVEL_USED_FOR_NO_GUILD_LOOT = 20; - - static readonly LOVE_LEVELS = [5, 20, 50]; - - static readonly LOVE_LEVEL = { - FEISTY: 1, - WILD: 2, - FEARFUL: 3, - TAMED: 4, - TRAINED: 5 - }; - - static readonly SELL_PRICE = { - MIN: 100, - MAX: 50000 - }; -} \ No newline at end of file diff --git a/Core/src/core/database/game/models/PetEntity.ts b/Core/src/core/database/game/models/PetEntity.ts index 36d9f8400..4669135ff 100644 --- a/Core/src/core/database/game/models/PetEntity.ts +++ b/Core/src/core/database/game/models/PetEntity.ts @@ -3,7 +3,7 @@ import {RandomUtils} from "../../../utils/RandomUtils"; import {MissionsController} from "../../../missions/MissionsController"; import {PET_ENTITY_GIVE_RETURN, PetEntityConstants} from "../../../constants/PetEntityConstants"; import {Player, PlayerEditValueParameters} from "./Player"; -import {PetConstants} from "../../../constants/PetConstants"; +import {PetConstants} from "../../../../../../Lib/src/constants/PetConstants"; import {Guild, Guilds} from "./Guild"; import {GuildPets} from "./GuildPet"; import {Pet, PetDataController} from "../../../../data/Pet"; diff --git a/Core/src/core/smallEvents/fightPet/usePlayerPet.ts b/Core/src/core/smallEvents/fightPet/usePlayerPet.ts index 51641cfc7..a63b7d21e 100644 --- a/Core/src/core/smallEvents/fightPet/usePlayerPet.ts +++ b/Core/src/core/smallEvents/fightPet/usePlayerPet.ts @@ -1,6 +1,6 @@ import {PetEntities} from "../../database/game/models/PetEntity"; import {FightPetActionFunc} from "../../../data/FightPetAction"; -import {PetConstants} from "../../constants/PetConstants"; +import {PetConstants} from "../../../../../Lib/src/constants/PetConstants"; import {SmallEventConstants} from "../../constants/SmallEventConstants"; import {PetEntityConstants} from "../../constants/PetEntityConstants"; import {RandomUtils} from "../../utils/RandomUtils"; diff --git a/Core/src/core/constants/BlockingConstants.ts b/Lib/src/constants/BlockingConstants.ts similarity index 100% rename from Core/src/core/constants/BlockingConstants.ts rename to Lib/src/constants/BlockingConstants.ts diff --git a/Core/src/core/constants/BotConstants.ts b/Lib/src/constants/BotConstants.ts similarity index 100% rename from Core/src/core/constants/BotConstants.ts rename to Lib/src/constants/BotConstants.ts diff --git a/Core/src/core/constants/ClassInfoConstants.ts b/Lib/src/constants/ClassInfoConstants.ts similarity index 100% rename from Core/src/core/constants/ClassInfoConstants.ts rename to Lib/src/constants/ClassInfoConstants.ts diff --git a/Lib/src/constants/Constants.ts b/Lib/src/constants/Constants.ts index 0b2fb1d7f..4e1785f3a 100644 --- a/Lib/src/constants/Constants.ts +++ b/Lib/src/constants/Constants.ts @@ -1,4 +1,239 @@ export class Constants { + + static readonly MESSAGES = { + COLLECTOR_TIME: 120000, + COLORS: { + DEFAULT: "default", + ERROR: "#D92D43", + SUCCESSFUL: "#5EAD45" + }, + PROGRESS_BAR_SIZE: 20, + MAX_SPAM_COUNT: 3, + DEFAULT_REACTION_LIMIT: 1 + }; + + static readonly TOPGG = { + BADGE: "🗳️", + BADGE_DURATION: 12, + ROLE_DURATION: 24 + }; + + static readonly XP = { + BASE_VALUE: 325, + COEFFICIENT: 1.041, + MINUS: 188 + }; + + static readonly ITEM_NATURE = { + NO_EFFECT: 0, + HEALTH: 1, + SPEED: 2, + ATTACK: 3, + DEFENSE: 4, + TIME_SPEEDUP: 5, + MONEY: 6 + }; + + static readonly REPORT = { + HOURS_USED_TO_CALCULATE_FIRST_REPORT_REWARD: 1, // Used to get the amount of point a user will get in the first report, 1 hour = 60 points ( + some bonus ) + TIME_BETWEEN_BIG_EVENTS: 2 * 60 * 60 * 1000, // 2 hours + BONUS_POINT_TIME_DIVIDER: 6, + POINTS_BY_SMALL_EVENT: 50, + PATH_SQUARE_COUNT: 16, + TIME_BETWEEN_MINI_EVENTS: 9.75 * 60 * 1000, // 9 minutes and 45 seconds + AUTO_CHOOSE_DESTINATION_CHANCE: 0.15 // 15% + }; + + // This constant represent the different types of values on which the players can be ranked + static readonly RANK_TYPES = { + LEVEL: "level", + SCORE: "score", + WEEKLY_SCORE: "weeklyScore", + LAST_SEASON_GLORY: "gloryPointsLastSeason" + }; + + static readonly CLASS = { + REQUIRED_LEVEL: 4, + PRICE: 5000, + GROUP1LEVEL: 16, + GROUP2LEVEL: 32, + GROUP3LEVEL: 48, + GROUP4LEVEL: 80, + TIME_BEFORE_CHANGE_CLASS: [ + 2 * 7 * 24 * 60 * 60, // 2 weeks + 2 * 7 * 24 * 60 * 60, // 2 weeks + 4 * 7 * 24 * 60 * 60, // 4 weeks + 4 * 7 * 24 * 60 * 60, // 4 weeks + 4 * 7 * 24 * 60 * 60 // 4 weeks + ] + }; + + static readonly CLASSES = { + RECRUIT: 0, + FIGHTER: 1, + SOLDIER: 2, + INFANTRYMAN: 3, + GLOVED: 4, + HELMETED: 5, + ENMESHED: 6, + TANK: 7, + ROCK_THROWER: 8, + SLINGER: 9, + ARCHER: 10, + GUNNER: 11, + ESQUIRE: 12, + HORSE_RIDER: 13, + PIKEMAN: 14, + KNIGHT: 15, + PALADIN: 16, + VETERAN: 17, + POWERFUL_INFANTRYMAN: 18, + IMPENETRABLE_TANK: 19, + FORMIDABLE_GUNNER: 20, + VALIANT_KNIGHT: 21, + LUMINOUS_PALADIN: 22, + EXPERIENCED_VETERAN: 23, + MYSTIC_MAGE: 24 + }; + + static readonly LOGS = { + LOG_COUNT_LINE_LIMIT: 50000 + }; + + static readonly MISSION_SHOP = { + RANGE_MISSION_MONEY: 1350, + BASE_RATIO: 6500, + SEED_RANGE: 1000 + }; + + static readonly BEGINNING = { + START_MAP_LINK: 83, + LAST_MAP_LINK: 77 + }; + + static readonly MISSIONS = { + SLOT_3_LEVEL: 55, + SLOT_2_LEVEL: 25, + SLOTS_LEVEL_PROBABILITIES: [ + { + LEVEL: 0, + EASY: 1, + MEDIUM: 0, + HARD: 0 + }, + { + LEVEL: 10, + EASY: 0.75, + MEDIUM: 0.25, + HARD: 0 + }, + { + LEVEL: 20, + EASY: 0.4, + MEDIUM: 0.6, + HARD: 0 + }, + { + LEVEL: 40, + EASY: 0.25, + MEDIUM: 0.65, + HARD: 0.1 + }, + { + LEVEL: 50, + EASY: 0.2, + MEDIUM: 0.55, + HARD: 0.25 + }, + { + LEVEL: 60, + EASY: 0.1, + MEDIUM: 0.4, + HARD: 0.5 + } + ], + DAILY_MISSION_MONEY_MULTIPLIER: 0.5, + DAILY_MISSION_POINTS_MULTIPLIER: 3.5 + }; + + static readonly BADGES = { + POWERFUL_GUILD: "💎", + VERY_POWERFUL_GUILD: "🪩", + STAFF_MEMBER: "⚙️", + QUEST_MASTER: "💍", + RICH_PERSON: "🤑", + PET_TAMER: "💞", + LIST_FOR_GIVE_BADGE_COMMAND: [ + "🏅", + "⚙️", + "✨", + "❤️", + "🍀", + "💸", + "🐞", + "🎰", + "🥇", + "🤑", + "🌟", + "🖋️", + "🌍", + "🎗️", + "🎄", + "😂", + "💎", + "⚔️", + "🗳️", + "💞", + "💍", + "🪩", + "🕊️" + ] + }; + + static readonly PET_FOOD = { + COMMON_FOOD: "commonFood", + CARNIVOROUS_FOOD: "carnivorousFood", + HERBIVOROUS_FOOD: "herbivorousFood", + ULTIMATE_FOOD: "ultimateFood" + }; + + static readonly PET_FOOD_GUILD_SHOP = { + TYPE: [ + "commonFood", + "herbivorousFood", + "carnivorousFood", + "ultimateFood" + ], + EMOTE: [ + "\uD83C\uDF6C", + "\uD83E\uDD6C", + "\uD83E\uDD69", + "\uD83C\uDF72" + ], + PRICE: [ + 20, + 250, + 250, + 600 + ], + EFFECT: [ + 1, + 3, + 3, + 5 + ] + }; + + static readonly MINIMAL_PLAYER_SCORE = 100; + + + static readonly MAX_DAILY_POTION_BUYOUTS: number = 5; + + static EXCLUDED_TRANSLATION_MODULES = [ + "classes.", + "advices" + ]; + static readonly VERSION = import("../../../Discord/package.json").then(json => json.version); static readonly MAX_TIME_BOT_RESPONSE = 30000; @@ -52,17 +287,6 @@ export class Constants { ] }; - static readonly MESSAGES = { - COLLECTOR_TIME: 120000, - COLORS: { - DEFAULT: "default", - ERROR: "#D92D43", - SUCCESSFUL: "#5EAD45" - }, - PROGRESS_BAR_SIZE: 20, - MAX_SPAM_COUNT: 3 - }; - static readonly CACHE_TIME = { INTERACTIONS: 900000 }; diff --git a/Core/src/core/constants/DailyConstants.ts b/Lib/src/constants/DailyConstants.ts similarity index 100% rename from Core/src/core/constants/DailyConstants.ts rename to Lib/src/constants/DailyConstants.ts diff --git a/Core/src/core/constants/EntityConstants.ts b/Lib/src/constants/EntityConstants.ts similarity index 100% rename from Core/src/core/constants/EntityConstants.ts rename to Lib/src/constants/EntityConstants.ts diff --git a/Core/src/core/constants/FightConstants.ts b/Lib/src/constants/FightConstants.ts similarity index 100% rename from Core/src/core/constants/FightConstants.ts rename to Lib/src/constants/FightConstants.ts diff --git a/Core/src/core/constants/GuildConstants.ts b/Lib/src/constants/GuildConstants.ts similarity index 100% rename from Core/src/core/constants/GuildConstants.ts rename to Lib/src/constants/GuildConstants.ts diff --git a/Core/src/core/constants/GuildCreateConstants.ts b/Lib/src/constants/GuildCreateConstants.ts similarity index 100% rename from Core/src/core/constants/GuildCreateConstants.ts rename to Lib/src/constants/GuildCreateConstants.ts diff --git a/Core/src/core/constants/GuildDailyConstants.ts b/Lib/src/constants/GuildDailyConstants.ts similarity index 100% rename from Core/src/core/constants/GuildDailyConstants.ts rename to Lib/src/constants/GuildDailyConstants.ts diff --git a/Core/src/core/constants/InventoryConstants.ts b/Lib/src/constants/InventoryConstants.ts similarity index 100% rename from Core/src/core/constants/InventoryConstants.ts rename to Lib/src/constants/InventoryConstants.ts diff --git a/Core/src/core/constants/LeagueInfoConstants.ts b/Lib/src/constants/LeagueInfoConstants.ts similarity index 100% rename from Core/src/core/constants/LeagueInfoConstants.ts rename to Lib/src/constants/LeagueInfoConstants.ts diff --git a/Core/src/core/constants/LogsConstants.ts b/Lib/src/constants/LogsConstants.ts similarity index 100% rename from Core/src/core/constants/LogsConstants.ts rename to Lib/src/constants/LogsConstants.ts diff --git a/Core/src/core/constants/MapConstants.ts b/Lib/src/constants/MapConstants.ts similarity index 100% rename from Core/src/core/constants/MapConstants.ts rename to Lib/src/constants/MapConstants.ts diff --git a/Core/src/core/constants/PVEConstants.ts b/Lib/src/constants/PVEConstants.ts similarity index 100% rename from Core/src/core/constants/PVEConstants.ts rename to Lib/src/constants/PVEConstants.ts diff --git a/Core/src/core/constants/PetEntityConstants.ts b/Lib/src/constants/PetEntityConstants.ts similarity index 100% rename from Core/src/core/constants/PetEntityConstants.ts rename to Lib/src/constants/PetEntityConstants.ts diff --git a/Core/src/core/constants/PetFreeConstants.ts b/Lib/src/constants/PetFreeConstants.ts similarity index 100% rename from Core/src/core/constants/PetFreeConstants.ts rename to Lib/src/constants/PetFreeConstants.ts diff --git a/Core/src/core/constants/PetSellConstants.ts b/Lib/src/constants/PetSellConstants.ts similarity index 100% rename from Core/src/core/constants/PetSellConstants.ts rename to Lib/src/constants/PetSellConstants.ts diff --git a/Core/src/core/constants/PetTradeConstants.ts b/Lib/src/constants/PetTradeConstants.ts similarity index 100% rename from Core/src/core/constants/PetTradeConstants.ts rename to Lib/src/constants/PetTradeConstants.ts diff --git a/Core/src/core/constants/PlayerConstants.ts b/Lib/src/constants/PlayerConstants.ts similarity index 100% rename from Core/src/core/constants/PlayerConstants.ts rename to Lib/src/constants/PlayerConstants.ts diff --git a/Core/src/core/constants/PlayersConstants.ts b/Lib/src/constants/PlayersConstants.ts similarity index 100% rename from Core/src/core/constants/PlayersConstants.ts rename to Lib/src/constants/PlayersConstants.ts diff --git a/Core/src/core/constants/ReportConstants.ts b/Lib/src/constants/ReportConstants.ts similarity index 100% rename from Core/src/core/constants/ReportConstants.ts rename to Lib/src/constants/ReportConstants.ts diff --git a/Core/src/core/constants/RespawnConstants.ts b/Lib/src/constants/RespawnConstants.ts similarity index 100% rename from Core/src/core/constants/RespawnConstants.ts rename to Lib/src/constants/RespawnConstants.ts diff --git a/Core/src/core/constants/SmallEventConstants.ts b/Lib/src/constants/SmallEventConstants.ts similarity index 100% rename from Core/src/core/constants/SmallEventConstants.ts rename to Lib/src/constants/SmallEventConstants.ts diff --git a/Core/src/core/constants/SpaceConstants.ts b/Lib/src/constants/SpaceConstants.ts similarity index 100% rename from Core/src/core/constants/SpaceConstants.ts rename to Lib/src/constants/SpaceConstants.ts diff --git a/Core/src/core/constants/TimeoutFunctionsConstants.ts b/Lib/src/constants/TimeoutFunctionsConstants.ts similarity index 100% rename from Core/src/core/constants/TimeoutFunctionsConstants.ts rename to Lib/src/constants/TimeoutFunctionsConstants.ts diff --git a/Core/src/core/constants/UnlockConstants.ts b/Lib/src/constants/UnlockConstants.ts similarity index 100% rename from Core/src/core/constants/UnlockConstants.ts rename to Lib/src/constants/UnlockConstants.ts From 39c694038521bc3e8c405a0a62bdad6a6e2db6c1 Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 10 Mar 2024 13:06:43 +0100 Subject: [PATCH 07/10] WIP guildCommand #2273 --- Core/src/commands/guild/GuildCommand.ts | 3 + Discord/src/bot/DraftBotShard.ts | 2 +- Discord/src/commands/guild/GuildCommand.ts | 70 ++++++++++++------- Lang/fr/commands.json | 13 ++++ Lib/src/constants/BotConstants.ts | 9 --- Lib/src/constants/ColorConstants.ts | 12 ++++ Lib/src/constants/Constants.ts | 7 -- Lib/src/constants/MapConstants.ts | 7 ++ .../packets/commands/CommandGuildPacket.ts | 2 + 9 files changed, 84 insertions(+), 41 deletions(-) delete mode 100644 Lib/src/constants/BotConstants.ts create mode 100644 Lib/src/constants/ColorConstants.ts diff --git a/Core/src/commands/guild/GuildCommand.ts b/Core/src/commands/guild/GuildCommand.ts index 9ba70bcee..d13a8e8a5 100644 --- a/Core/src/commands/guild/GuildCommand.ts +++ b/Core/src/commands/guild/GuildCommand.ts @@ -6,6 +6,7 @@ import {Guild, Guilds} from "../../core/database/game/models/Guild"; import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; import {Maps} from "../../core/maps/Maps"; import {MapCache} from "../../core/maps/MapCache"; +import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; export default class GuildCommand { @packetHandler(CommandGuildPacketReq) @@ -57,6 +58,8 @@ export default class GuildCommand { }, members: await Promise.all( members.map(async member => ({ + id: member.id, + gameUsername: (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.keycloakId!)).attributes.gameUsername, keycloakId: member.keycloakId, rank: await Players.getRankById(member.id), score: member.score, diff --git a/Discord/src/bot/DraftBotShard.ts b/Discord/src/bot/DraftBotShard.ts index 927dad0c6..6f2c8a772 100644 --- a/Discord/src/bot/DraftBotShard.ts +++ b/Discord/src/bot/DraftBotShard.ts @@ -39,7 +39,7 @@ process.on("message", async (message: { type: string, data: { shardId: number } const guild = draftBotClient?.guilds.cache.get(discordConfig.MAIN_SERVER_ID); if (guild?.shard) { (await guild.channels.fetch(discordConfig.CONSOLE_CHANNEL_ID) as TextChannel) - .send(`:robot: **DraftBot** - v${await Constants.VERSION} - Shard ${shardId}`) + .send(`:robot: **DraftBot** - v${process.env.npm_package_version} - Shard ${shardId}`) .catch(console.error); } }); diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index da80687dc..f050406e8 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -11,7 +11,8 @@ import {ColorResolvable, EmbedField, Message, MessageReaction} from "discord.js" import {Constants} from "../../../../Lib/src/constants/Constants"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; -import {ProfileConstants} from "../../../../Lib/src/constants/ProfileConstants"; +import {GuildConstants} from "../../../../Lib/src/constants/GuildConstants"; +import {ColorConstants} from "../../../../Lib/src/constants/ColorConstants"; import {Language} from "../../../../Lib/src/Language"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; @@ -208,6 +209,50 @@ export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, const guildCommandEmbed = new DraftBotEmbed() .setThumbnail(GuildConstants.ICON); + if (packet.data!.level >= GuildConstants.GOLDEN_GUILD_LEVEL) { + guildCommandEmbed.setColor(ColorConstants.GOLD); + } + + guildCommandEmbed.setTitle(i18n.t("commands:guild.embedTitle", { + lng: interaction.userLanguage, + guildName: packet.data?.name, + level: packet.data?.level + })); + + if (packet.data!.description) { + guildCommandEmbed.setDescription( + i18n.t("commands:guild.description", { + lng: interaction.userLanguage, + description: packet.data?.description + }) + ); + } + + let membersInfos = ""; + for (const member of packet.data!.members) { + membersInfos += i18n.t("commands:guild.memberInfos", { + lng: interaction.userLanguage, + isChief: member.id === packet.data!.chiefId, + isElder: member.id === packet.data!.elderId, + pseudo: member.gameUsername, + ranking: member.rank, + score: member.score, + isOnPveIsland: member.islandStatus.isOnPveIsland, + isOnBoat: member.islandStatus.isOnBoat, + isPveIslandAlly: member.islandStatus.isPveIslandAlly, + isInactive: member.islandStatus.isInactive, + isNotBotJoinable: member.islandStatus.cannotBeJoinedOnBoat + }); + } + + guildCommandEmbed.addFields({ + name: guildModule.format("members", { + memberCount: members.length, + maxGuildMembers: GuildConstants.MAX_GUILD_MEMBERS + }), + value: membersInfos + }); + const reply = await interaction.reply({ embeds: [ @@ -223,29 +268,6 @@ export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, ], fetchReply: true }) as Message; - - const collector = reply.createReactionCollector({ - filter: (reaction: MessageReaction) => reaction.me && !reaction.users.cache.last()!.bot, - time: Constants.MESSAGES.COLLECTOR_TIME, - max: ProfileConstants.BADGE_MAXIMUM_REACTION - }); - - collector.on("collect", async (reaction) => { - if (reaction.emoji.name === Constants.PROFILE.DISPLAY_ALL_BADGE_EMOTE) { - collector.stop(); // Only one is allowed to avoid spam - await sendMessageAllBadgesTooMuchBadges(keycloakUser.attributes.gameUsername, packet.data!.badges!, interaction); - } - else { - interaction.channel.send({content: i18n.t(`commands:profile.badges.${reaction.emoji.name}`)}) - .then((msg: Message | null) => { - setTimeout(() => msg?.delete(), ProfileConstants.BADGE_DESCRIPTION_TIMEOUT); - }); - } - }); - - if (packet.data?.badges.length !== 0) { - await displayBadges(packet.data!.badges, reply); - } } } diff --git a/Lang/fr/commands.json b/Lang/fr/commands.json index 2effef1d1..9bfaba862 100644 --- a/Lang/fr/commands.json +++ b/Lang/fr/commands.json @@ -3,6 +3,19 @@ "description": "Les badges sont des distinctions difficiles à obtenir qui ont été créées pour récompenser les personnes ayant le plus soutenu le développement du bot. La liste des badges est disponible sur le guide du bot.\n(via ce lien : https://guide.draftbot.com/notions-avancees/badges)", "title": ":military_medal: Informations détaillées :" }, + "guild": { + "embedTitle": "Guilde {guildName} | Niveau {level}", + "description": ":scroll: `{description}`", + "memberInfos": ":{isChief?crown:{isElder?military_medal:black_circle}}: - **{pseudo}** ({ranking} :trophy: | {score} :medal:{isOnPveIsland? | :{isOnBoat? | :{isPveIslandAlly? | :}}}{isOnPveIsland?🏝️:}{isOnBoat?⛴️:}{isPveIslandAlly?🤝:}{isNotBotJoinable?👻:})\n", + "members": ":person_pouting: {memberCount}/{maxGuildMembers} membres", + "infoTitle": "Informations", + "islandInfo": ":island: Nombre d'alliés sur l'île mystérieuse : {membersOnPveIsland}\n", + "info": ":star: {experience} | :mirror_ball: {guildPoints} | :trophy: {ranking}", + "xpNeeded": "{xp} / {xpToLevelUp}", + "xpMax": "Max", + "ranking": "{rank} / {rankTotal}", + "notRanked": "Non classée" + }, "idea": { "description": "Vous pouvez proposer des suggestions et voter pour vos idées préférées via ce lien:\nhttps://feedback.draftbot.com/", "title": ":bulb: Idées" diff --git a/Lib/src/constants/BotConstants.ts b/Lib/src/constants/BotConstants.ts deleted file mode 100644 index 70332b9d4..000000000 --- a/Lib/src/constants/BotConstants.ts +++ /dev/null @@ -1,9 +0,0 @@ -export abstract class BotConstants { - static readonly VERSION = import("../../../package.json").then(json => json.version); - - static readonly MAP_URL = "https://draftbot.com/public/ressources/map.jpg"; // Unused, but useful - - static readonly MAP_URL_WITH_CURSOR = "https://draftbot.com/public/ressources/mapsCursed/{mapLink}map.jpg"; - - static readonly FORCED_MAPS_URL = "https://draftbot.com/public/ressources/maps/{name}.jpg"; -} \ No newline at end of file diff --git a/Lib/src/constants/ColorConstants.ts b/Lib/src/constants/ColorConstants.ts new file mode 100644 index 000000000..382baf4de --- /dev/null +++ b/Lib/src/constants/ColorConstants.ts @@ -0,0 +1,12 @@ +export type HexColorString = `#${string}`; + +export class ColorConstants { + static readonly DEFAULT = "default"; + + static readonly ERROR: HexColorString = "#D92D43"; + + static readonly SUCCESSFUL: HexColorString = "#5EAD45"; + + static readonly GOLD: HexColorString = "#FFAC33"; + +} \ No newline at end of file diff --git a/Lib/src/constants/Constants.ts b/Lib/src/constants/Constants.ts index 4e1785f3a..c1691f3bb 100644 --- a/Lib/src/constants/Constants.ts +++ b/Lib/src/constants/Constants.ts @@ -2,11 +2,6 @@ export class Constants { static readonly MESSAGES = { COLLECTOR_TIME: 120000, - COLORS: { - DEFAULT: "default", - ERROR: "#D92D43", - SUCCESSFUL: "#5EAD45" - }, PROGRESS_BAR_SIZE: 20, MAX_SPAM_COUNT: 3, DEFAULT_REACTION_LIMIT: 1 @@ -234,8 +229,6 @@ export class Constants { "advices" ]; - static readonly VERSION = import("../../../Discord/package.json").then(json => json.version); - static readonly MAX_TIME_BOT_RESPONSE = 30000; static readonly DM = { diff --git a/Lib/src/constants/MapConstants.ts b/Lib/src/constants/MapConstants.ts index 9a6cc213e..99fd73287 100644 --- a/Lib/src/constants/MapConstants.ts +++ b/Lib/src/constants/MapConstants.ts @@ -1,4 +1,11 @@ export abstract class MapConstants { + + static readonly MAP_URL = "https://draftbot.com/public/ressources/map.jpg"; // Unused, but useful + + static readonly MAP_URL_WITH_CURSOR = "https://draftbot.com/public/ressources/mapsCursed/{mapLink}map.jpg"; + + static readonly FORCED_MAPS_URL = "https://draftbot.com/public/ressources/maps/{name}.jpg"; + static readonly WATER_MAP_LINKS = [ 1, 2, 17, 20, 21, 22, 23, 24, 32, 33, 34, 36, diff --git a/Lib/src/packets/commands/CommandGuildPacket.ts b/Lib/src/packets/commands/CommandGuildPacket.ts index 72a62025c..884cf2406 100644 --- a/Lib/src/packets/commands/CommandGuildPacket.ts +++ b/Lib/src/packets/commands/CommandGuildPacket.ts @@ -10,6 +10,8 @@ export class CommandGuildPacketReq extends DraftBotPacket { } export interface GuildMemberPacket { + id: number; + gameUsername: string; keycloakId: string; rank: number, score: number From 11a5d658e6165f84e4b3fbd87c7cb4d813413ccd Mon Sep 17 00:00:00 2001 From: BastLast Date: Sun, 10 Mar 2024 14:59:33 +0100 Subject: [PATCH 08/10] WIP guildCommand #2273 --- Core/src/commands/guild/GuildCommand.ts | 2 - Discord/src/commands/guild/GuildCommand.ts | 144 +----------------- Lang/fr/commands.json | 16 +- .../packets/commands/CommandGuildPacket.ts | 1 - 4 files changed, 10 insertions(+), 153 deletions(-) diff --git a/Core/src/commands/guild/GuildCommand.ts b/Core/src/commands/guild/GuildCommand.ts index d13a8e8a5..169dfc8c1 100644 --- a/Core/src/commands/guild/GuildCommand.ts +++ b/Core/src/commands/guild/GuildCommand.ts @@ -6,7 +6,6 @@ import {Guild, Guilds} from "../../core/database/game/models/Guild"; import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; import {Maps} from "../../core/maps/Maps"; import {MapCache} from "../../core/maps/MapCache"; -import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; export default class GuildCommand { @packetHandler(CommandGuildPacketReq) @@ -59,7 +58,6 @@ export default class GuildCommand { members: await Promise.all( members.map(async member => ({ id: member.id, - gameUsername: (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.keycloakId!)).attributes.gameUsername, keycloakId: member.keycloakId, rank: await Players.getRankById(member.id), score: member.score, diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index f050406e8..a395a5903 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -46,147 +46,6 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa return makePacket(CommandGuildPacketReq, {askedPlayer, askedGuildName}); } -function generateFields(packet: CommandGuildPacketRes, language: Language): EmbedField[] { - const fields: EmbedField[] = []; - - fields.push({ - name: i18n.t("commands:profile.information.fieldName", {lng: language}), - value: i18n.t("commands:profile.information.fieldValue", { - lng: language, - health: packet.data?.health.value, - maxHealth: packet.data?.health.max, - money: packet.data?.money, - experience: packet.data?.experience.value, - experienceNeededToLevelUp: packet.data?.experience.max - }), - inline: false - }); - - if (packet.data?.stats) { - fields.push({ - name: i18n.t("commands:profile.statistics.fieldName", {lng: language}), - value: i18n.t("commands:profile.statistics.fieldValue", { - lng: language, - baseBreath: packet.data?.stats.breath.base, - breathRegen: packet.data?.stats.breath.regen, - cumulativeAttack: packet.data?.stats.attack, - cumulativeDefense: packet.data?.stats.defense, - cumulativeHealth: packet.data.stats.energy.value, - cumulativeSpeed: packet.data.stats.speed, - cumulativeMaxHealth: packet.data.stats.energy.max, - maxBreath: packet.data.stats.breath.max - }), - inline: false - }); - } - - fields.push({ - name: i18n.t("commands:profile.mission.fieldName", {lng: language}), - value: i18n.t("commands:profile.mission.fieldValue", { - lng: language, - gems: packet.data?.missions.gems, - campaign: packet.data?.missions.campaignProgression - }), - inline: false - }); - - fields.push({ - name: i18n.t("commands:profile.ranking.fieldName", {lng: language}), - value: packet.data?.rank.unranked ? i18n.t("commands:profile.ranking.fieldValueUnranked", { - lng: language, - score: packet.data.rank.score - }) : i18n.t("commands:profile.ranking.fieldValue", { - lng: language, - rank: packet.data?.rank.rank, - numberOfPlayer: packet.data?.rank.numberOfPlayers, - score: packet.data?.rank.score - }), - inline: false - }); - - if (packet.data?.effect?.healed) { - fields.push({ - name: i18n.t("commands:profile.noTimeLeft.fieldName", {lng: language}), - value: i18n.t("commands:profile.noTimeLeft.fieldValue", { - lng: language - }), - inline: false - }); - } - else if (packet.data?.effect) { - fields.push({ - name: i18n.t("commands:profile.timeLeft.fieldName", {lng: language}), - value: i18n.t("commands:profile.timeLeft.fieldValue", { - lng: language, - effect: packet.data.effect, - timeLeft: packet.data.effect.timeLeft - }), - inline: false - }); - } - - if (packet.data?.class) { - fields.push({ - name: i18n.t("commands:profile.playerClass.fieldName", {lng: language}), - value: i18n.t("commands:profile.playerClass.fieldValue", { - lng: language, - class: packet.data.class - }), - inline: false - }); - } - - if (packet.data?.fightRanking) { - fields.push({ - name: i18n.t("commands:profile.fightRanking.fieldName", {lng: language}), - value: i18n.t("commands:profile.fightRanking.fieldValue", { - lng: language, - league: packet.data.fightRanking.league, - gloryPoints: packet.data.fightRanking.glory - }), - inline: false - }); - } - - if (packet.data?.guild) { - fields.push({ - name: i18n.t("commands:profile.guild.fieldName", {lng: language}), - value: i18n.t("commands:profile.guild.fieldValue", { - lng: language, - guild: packet.data.guild - }), - inline: false - }); - } - - if (packet.data?.destination) { - fields.push({ - name: i18n.t("commands:profile.map.fieldName", {lng: language}), - value: i18n.t("commands:profile.map.fieldValue", { - lng: language, - mapEmote: "TODO EMOTE", // Todo - mapName: i18n.t(`models:map_locations.${packet.data.destination}.name`, {lng: language}) - }), - inline: false - }); - } - - if (packet.data?.pet) { - fields.push({ - name: i18n.t("commands:profile.pet.fieldName", {lng: language}), - value: i18n.t("commands:profile.pet.fieldValue", { - lng: language, - emote: "TODO EMOTE", // Todo - rarity: packet.data.pet.rarity, - nickname: packet.data.pet.nickname ?? i18n.t(`models:pets.${packet.data.pet.id}`, {lng: language}) - }), - inline: false - }); - } - - return fields; -} - export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, context: PacketContext): Promise { const interaction = DiscordCache.getInteraction(context.discord!.interaction); @@ -232,9 +91,10 @@ export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, for (const member of packet.data!.members) { membersInfos += i18n.t("commands:guild.memberInfos", { lng: interaction.userLanguage, + icon: isChief: member.id === packet.data!.chiefId, isElder: member.id === packet.data!.elderId, - pseudo: member.gameUsername, + pseudo: (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, member.keycloakId))?.attributes.gameUsername, ranking: member.rank, score: member.score, isOnPveIsland: member.islandStatus.isOnPveIsland, diff --git a/Lang/fr/commands.json b/Lang/fr/commands.json index 9bfaba862..2138ba714 100644 --- a/Lang/fr/commands.json +++ b/Lang/fr/commands.json @@ -4,16 +4,16 @@ "title": ":military_medal: Informations détaillées :" }, "guild": { - "embedTitle": "Guilde {guildName} | Niveau {level}", - "description": ":scroll: `{description}`", - "memberInfos": ":{isChief?crown:{isElder?military_medal:black_circle}}: - **{pseudo}** ({ranking} :trophy: | {score} :medal:{isOnPveIsland? | :{isOnBoat? | :{isPveIslandAlly? | :}}}{isOnPveIsland?🏝️:}{isOnBoat?⛴️:}{isPveIslandAlly?🤝:}{isNotBotJoinable?👻:})\n", - "members": ":person_pouting: {memberCount}/{maxGuildMembers} membres", + "embedTitle": "Guilde {{guildName}} | Niveau {{level}}", + "description": ":scroll: `{{description}}`", + "memberInfos": "{{icon}} - **{{pseudo}}** ({{ranking}} {{trophy}} | {{score}} {{medal}}{{islandEmoji}}{{boatEmoji}}{{allyEmoji}}{{ghostEmoji}})\n", + "members": ":person_pouting: {{memberCount}}/{{maxGuildMembers}} membres", "infoTitle": "Informations", - "islandInfo": ":island: Nombre d'alliés sur l'île mystérieuse : {membersOnPveIsland}\n", - "info": ":star: {experience} | :mirror_ball: {guildPoints} | :trophy: {ranking}", - "xpNeeded": "{xp} / {xpToLevelUp}", + "islandInfo": ":island: Nombre d'alliés sur l'île mystérieuse : {{membersOnPveIsland}\n", + "info": ":star: {{experience}} | :mirror_ball: {{guildPoints}} | :trophy: {{ranking}}", + "xpNeeded": "{{xp} / {{xpToLevelUp}}", "xpMax": "Max", - "ranking": "{rank} / {rankTotal}", + "ranking": "{{rank} / {{rankTotal}}", "notRanked": "Non classée" }, "idea": { diff --git a/Lib/src/packets/commands/CommandGuildPacket.ts b/Lib/src/packets/commands/CommandGuildPacket.ts index 884cf2406..2b8bb301a 100644 --- a/Lib/src/packets/commands/CommandGuildPacket.ts +++ b/Lib/src/packets/commands/CommandGuildPacket.ts @@ -11,7 +11,6 @@ export class CommandGuildPacketReq extends DraftBotPacket { export interface GuildMemberPacket { id: number; - gameUsername: string; keycloakId: string; rank: number, score: number From 3735fa6e6f1eea8ec71ee2b0eaf791a02b4bb066 Mon Sep 17 00:00:00 2001 From: BastLast Date: Mon, 11 Mar 2024 01:18:18 +0100 Subject: [PATCH 09/10] end guildCommand #2273 --- Core/src/core/database/game/models/Guild.ts | 8 +- Discord/src/commands/guild/GuildCommand.ts | 76 ++++++++++++------- Discord/src/messages/DraftBotEmbed.ts | 4 +- .../handlers/CommandHandlers.ts | 7 ++ Lang/fr/commands.json | 12 ++- 5 files changed, 71 insertions(+), 36 deletions(-) diff --git a/Core/src/core/database/game/models/Guild.ts b/Core/src/core/database/game/models/Guild.ts index 69f9fd53e..bc262809d 100644 --- a/Core/src/core/database/game/models/Guild.ts +++ b/Core/src/core/database/game/models/Guild.ts @@ -1,11 +1,7 @@ import {DataTypes, Model, Op, QueryTypes, Sequelize} from "sequelize"; import {MissionsController} from "../../../missions/MissionsController"; -import {Constants} from "../../../Constants"; import {getFoodIndexOf} from "../../../utils/FoodUtils"; import Player, {Players} from "./Player"; -import {NumberChangeReason} from "../../../constants/LogsConstants"; -import {PetEntityConstants} from "../../../constants/PetEntityConstants"; -import {GuildConstants} from "../../../constants/GuildConstants"; import {GuildPet, GuildPets} from "./GuildPet"; import PetEntity from "./PetEntity"; import {draftBotInstance} from "../../../../index"; @@ -13,6 +9,10 @@ import {DraftBotPacket} from "../../../../../../Lib/src/packets/DraftBotPacket"; import {GuildLevelUpPacket} from "../../../../../../Lib/src/packets/notifications/GuildLevelUpPacket"; import moment = require("moment"); import {TopConstants} from "../../../../../../Lib/src/constants/TopConstants"; +import { Constants } from "../../../../../../Lib/src/Constants/Constants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; +import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants"; +import {PetEntityConstants} from "../../../../../../Lib/src/constants/PetEntityConstants"; export class Guild extends Model { declare readonly id: number; diff --git a/Discord/src/commands/guild/GuildCommand.ts b/Discord/src/commands/guild/GuildCommand.ts index a395a5903..c74ecfe43 100644 --- a/Discord/src/commands/guild/GuildCommand.ts +++ b/Discord/src/commands/guild/GuildCommand.ts @@ -3,17 +3,18 @@ import {makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPac import {DraftbotInteraction} from "../../messages/DraftbotInteraction"; import i18n from "../../translations/i18n"; import {SlashCommandBuilderGenerator} from "../SlashCommandBuilderGenerator"; -import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; +import { + CommandGuildPacketReq, + CommandGuildPacketRes, + GuildMemberPacket +} from "../../../../Lib/src/packets/commands/CommandGuildPacket"; import {SlashCommandBuilder} from "@discordjs/builders"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; -import {ColorResolvable, EmbedField, Message, MessageReaction} from "discord.js"; -import {Constants} from "../../../../Lib/src/constants/Constants"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotErrorEmbed} from "../../messages/DraftBotErrorEmbed"; import {GuildConstants} from "../../../../Lib/src/constants/GuildConstants"; import {ColorConstants} from "../../../../Lib/src/constants/ColorConstants"; -import {Language} from "../../../../Lib/src/Language"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils"; import {keycloakConfig} from "../../bot/DraftBotShard"; @@ -46,6 +47,40 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa return makePacket(CommandGuildPacketReq, {askedPlayer, askedGuildName}); } +/** + * Get the icon depending on what type of member the player is (chief, elder, member) + * @param member + * @param packet + */ +function getMemberTypeIcon(member: GuildMemberPacket, packet: CommandGuildPacketRes): string { + return member.id === packet.data!.chiefId ? + i18n.t("commands:guild.emojis.chief") : + member.id === packet.data!.elderId ? + i18n.t("commands:guild.emojis.elder") : + i18n.t("commands:guild.emojis.member"); +} + +/** + * Return the icons corresponding to the island status of the member + * @param member + */ +function getIslandStatusIcon(member: GuildMemberPacket): string { + return member.islandStatus.isOnPveIsland || member.islandStatus.isOnBoat || member.islandStatus.isPveIslandAlly || member.islandStatus.cannotBeJoinedOnBoat ? + i18n.t("commands:guild.separator") + + (member.islandStatus.isOnPveIsland ? + i18n.t("commands:guild.emojis.pveIsland") : + "") + + (member.islandStatus.isOnBoat ? + i18n.t("commands:guild.emojis.boat") : + "") + + (member.islandStatus.isPveIslandAlly ? + i18n.t("commands:guild.emojis.pveIslandAlly") : + "") + + (member.islandStatus.cannotBeJoinedOnBoat ? + i18n.t("commands:guild.emojis.cannotBeJoinedOnBoat") : + "") : ""; +} + export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, context: PacketContext): Promise { const interaction = DiscordCache.getInteraction(context.discord!.interaction); @@ -63,8 +98,6 @@ export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, return; } - const keycloakUser = (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, packet.askedPlayerKeycloakId!))!; - const guildCommandEmbed = new DraftBotEmbed() .setThumbnail(GuildConstants.ICON); @@ -91,43 +124,28 @@ export async function handleCommandGuildPacketRes(packet: CommandGuildPacketRes, for (const member of packet.data!.members) { membersInfos += i18n.t("commands:guild.memberInfos", { lng: interaction.userLanguage, - icon: - isChief: member.id === packet.data!.chiefId, - isElder: member.id === packet.data!.elderId, + icon: getMemberTypeIcon(member, packet), pseudo: (await KeycloakUtils.getUserByKeycloakId(keycloakConfig, member.keycloakId))?.attributes.gameUsername, ranking: member.rank, score: member.score, - isOnPveIsland: member.islandStatus.isOnPveIsland, - isOnBoat: member.islandStatus.isOnBoat, - isPveIslandAlly: member.islandStatus.isPveIslandAlly, - isInactive: member.islandStatus.isInactive, - isNotBotJoinable: member.islandStatus.cannotBeJoinedOnBoat + islandStatusIcon: getIslandStatusIcon(member) }); } guildCommandEmbed.addFields({ - name: guildModule.format("members", { - memberCount: members.length, + name: i18n.t("commands:guild.members", { + lng: interaction.userLanguage, + memberCount: packet.data!.members.length, maxGuildMembers: GuildConstants.MAX_GUILD_MEMBERS }), value: membersInfos }); - const reply = await interaction.reply({ - embeds: [ - new DraftBotEmbed() - .setColor(packet.data!.color) - .setTitle(i18n.t("commands:profile.title", { - lng: interaction.userLanguage, - effect: titleEffect, - pseudo: keycloakUser.attributes.gameUsername, - level: packet.data?.level - })) - .addFields(generateFields(packet, interaction.userLanguage)) - ], + await interaction.reply({ + embeds: [guildCommandEmbed], fetchReply: true - }) as Message; + }); } } diff --git a/Discord/src/messages/DraftBotEmbed.ts b/Discord/src/messages/DraftBotEmbed.ts index 05736b869..390594bf7 100644 --- a/Discord/src/messages/DraftBotEmbed.ts +++ b/Discord/src/messages/DraftBotEmbed.ts @@ -1,5 +1,5 @@ import {EmbedBuilder, HexColorString, User} from "discord.js"; -import {Constants} from "../../../Lib/src/constants/Constants"; +import { ColorConstants } from "../../../Lib/src/constants/ColorConstants"; /** * Base class for bot embeds @@ -30,7 +30,7 @@ export class DraftBotEmbed extends EmbedBuilder { *Set the color of the embed to the error color */ setErrorColor(): this { - this.setColor(Constants.MESSAGES.COLORS.ERROR); + this.setColor( ColorConstants.ERROR); return this; } } \ No newline at end of file diff --git a/Discord/src/packetHandlers/handlers/CommandHandlers.ts b/Discord/src/packetHandlers/handlers/CommandHandlers.ts index 74fc5b387..a49e5b2b7 100644 --- a/Discord/src/packetHandlers/handlers/CommandHandlers.ts +++ b/Discord/src/packetHandlers/handlers/CommandHandlers.ts @@ -15,6 +15,8 @@ import {CommandTestPacketRes} from "../../../../Lib/src/packets/commands/Command import {CommandRarityPacketRes} from "../../../../Lib/src/packets/commands/CommandRarityPacket"; import {handleCommandRarityPacketRes} from "../../commands/player/RarityCommand"; import {handleCommandTestPacketRes} from "../../commands/admin/TestCommand"; +import {handleCommandGuildPacketRes} from "../../commands/guild/GuildCommand"; +import { CommandGuildPacketRes } from "../../../../Lib/src/packets/commands/CommandGuildPacket"; export default class CommandHandlers { @packetHandler(CommandPingPacketRes) @@ -36,6 +38,11 @@ export default class CommandHandlers { await handleCommandProfilePacketRes(packet, context); } + @packetHandler(CommandGuildPacketRes) + async guildRes(socket: WebSocket, packet: CommandGuildPacketRes, context: PacketContext): Promise { + await handleCommandGuildPacketRes(packet, context); + } + @packetHandler(CommandInventoryPacketRes) async inventoryRes(socket: WebSocket, packet: CommandInventoryPacketRes, context: PacketContext): Promise { await handleCommandInventoryPacketRes(packet, context); diff --git a/Lang/fr/commands.json b/Lang/fr/commands.json index 2138ba714..021266388 100644 --- a/Lang/fr/commands.json +++ b/Lang/fr/commands.json @@ -6,7 +6,17 @@ "guild": { "embedTitle": "Guilde {{guildName}} | Niveau {{level}}", "description": ":scroll: `{{description}}`", - "memberInfos": "{{icon}} - **{{pseudo}}** ({{ranking}} {{trophy}} | {{score}} {{medal}}{{islandEmoji}}{{boatEmoji}}{{allyEmoji}}{{ghostEmoji}})\n", + "emojis": { + "chief": "👑", + "elder": "🎖️", + "member": "⚫", + "isOnPveIsland": "🏝️", + "isOnBoat": "⛴️", + "countAsAnAlly": "🤝", + "cannotBeJoinedOnBoat": "👻" + }, + "separator": " | ", + "memberInfos": "{{icon}} - **{{pseudo}}** ({{ranking}} :trophy: | {{score}} :medal:{{islandStatusIcon}})\n", "members": ":person_pouting: {{memberCount}}/{{maxGuildMembers}} membres", "infoTitle": "Informations", "islandInfo": ":island: Nombre d'alliés sur l'île mystérieuse : {{membersOnPveIsland}\n", From c46b8fba268d8182194bd4acb358faf9481bf08f Mon Sep 17 00:00:00 2001 From: BastLast Date: Mon, 11 Mar 2024 01:49:15 +0100 Subject: [PATCH 10/10] end of work on constants #2426 --- .../Fight/GloryPointsTestCommand.ts | 2 +- .../Guild/ForceJoinGuildTestCommand.ts | 2 +- .../Guild/GuildLevelTestCommand.ts | 2 +- .../Guild/GuildRewardTestCommand.ts | 2 +- .../Guild/GuildScoreTestCommand.ts | 2 +- .../testCommands/Guild/GuildXpTestCommand.ts | 2 +- .../testCommands/Guild/SetFoodTestCommand.ts | 2 +- .../testCommands/Map/TravelTestCommand.ts | 2 +- .../Missions/AddGemsTestCommand.ts | 2 +- .../Pet/PetLovePointsTestCommand.ts | 2 +- .../Player/AddMoneyTestCommand.ts | 2 +- .../Player/ExperienceTestCommand.ts | 2 +- .../Player/PlayerHealthTestCommand.ts | 2 +- .../Player/PlayerMoneyTestCommand.ts | 2 +- .../Player/PlayerScoreTestCommand.ts | 2 +- .../Player/PlayerSuicideTestCommand.ts | 2 +- .../Player/SkipTutorialTestCommand.ts | 2 +- .../Time/AdvanceTravelTestCommand.ts | 2 +- .../Time/BlockPlayerTestCommand.ts | 2 +- .../Time/JailPlayerTestCommand.ts | 2 +- .../Time/PlayerEffectTestCommand.ts | 2 +- .../Time/RemovePlayerEffectTestCommand.ts | 2 +- Core/src/commands/player/ProfileCommand.ts | 4 ++-- Core/src/commands/player/ReportCommand.ts | 12 +++++----- Core/src/core/bot/DraftBot.ts | 2 +- .../game/migrations/003-remove-entity.ts | 2 +- .../game/migrations/008-gloryandleague.ts | 2 +- Core/src/core/database/game/models/Guild.ts | 2 +- .../src/core/database/game/models/GuildPet.ts | 14 ++++++++++- .../core/database/game/models/PetEntity.ts | 2 +- Core/src/core/database/game/models/Player.ts | 24 +++++++++---------- .../game/models/PlayerMissionsInfo.ts | 2 +- Core/src/core/database/logs/LogsDatabase.ts | 6 ++--- .../core/database/logs/LogsReadRequests.ts | 6 ++--- Core/src/core/fights/FightController.ts | 4 ++-- .../fights/actions/FightActionController.ts | 2 +- .../actions/interfaces/alterations/cursed.ts | 2 +- .../interfaces/players/counterAttack.ts | 2 +- .../interfaces/players/divineAttack.ts | 2 +- .../interfaces/players/rageExplosion.ts | 4 ++-- Core/src/core/fights/fighter/Fighter.ts | 2 +- .../src/core/fights/fighter/MonsterFighter.ts | 2 +- Core/src/core/fights/fighter/PlayerFighter.ts | 6 ++--- Core/src/core/maps/MapCache.ts | 2 +- Core/src/core/maps/Maps.ts | 2 +- Core/src/core/maps/TravelTime.ts | 6 ++--- Core/src/core/missions/MissionsController.ts | 4 ++-- Core/src/core/smallEvents/advanceTime.ts | 2 +- Core/src/core/smallEvents/bigBad.ts | 4 ++-- .../core/smallEvents/bonusGuildPVEIsland.ts | 4 ++-- Core/src/core/smallEvents/fightPet.ts | 8 +++---- .../core/smallEvents/fightPet/attackLeft.ts | 2 +- .../core/smallEvents/fightPet/attackRight.ts | 2 +- .../core/smallEvents/fightPet/doNothing.ts | 2 +- Core/src/core/smallEvents/fightPet/fistHit.ts | 2 +- .../core/smallEvents/fightPet/focusEnergy.ts | 2 +- .../core/smallEvents/fightPet/intimidate.ts | 2 +- .../core/smallEvents/fightPet/lastEffort.ts | 2 +- Core/src/core/smallEvents/fightPet/prayGod.ts | 2 +- Core/src/core/smallEvents/fightPet/protect.ts | 2 +- Core/src/core/smallEvents/fightPet/runAway.ts | 2 +- .../core/smallEvents/fightPet/usePlayerPet.ts | 4 ++-- Core/src/core/smallEvents/gobletsGame.ts | 8 +++---- Core/src/core/smallEvents/interfaces/Shop.ts | 6 ++--- Core/src/core/smallEvents/shop.ts | 2 +- Core/src/core/smallEvents/winEnergy.ts | 4 ++-- Core/src/core/smallEvents/winFightPoints.ts | 2 +- Core/src/core/smallEvents/winGuildXP.ts | 4 ++-- Core/src/core/smallEvents/winHealth.ts | 4 ++-- Core/src/core/smallEvents/winPersonalXP.ts | 4 ++-- Core/src/core/smallEvents/witch.ts | 8 +++---- Core/src/core/utils/FoodUtils.ts | 2 +- Core/src/core/utils/ItemUtils.ts | 4 ++-- Core/src/core/utils/RandomUtils.ts | 2 +- Core/src/core/utils/ReactionsCollector.ts | 2 +- Core/src/data/League.ts | 2 +- Core/src/data/MainItem.ts | 2 +- Core/src/data/Monster.ts | 2 +- Core/src/data/Pet.ts | 2 +- Core/src/data/WitchAction.ts | 4 ++-- Core/src/data/events/PossibilityOutcome.ts | 4 ++-- Discord/src/commands/admin/TestCommand.ts | 4 ++-- Lang/en/discordBuilder.json | 18 ++++++++++++++ Lang/fr/discordBuilder.json | 18 ++++++++++++++ Lib/src/Constants.ts | 8 ------- Lib/src/constants/ClassInfoConstants.ts | 2 +- Lib/src/constants/Constants.ts | 7 ++++-- Lib/src/constants/LogsConstants.ts | 13 ---------- Lib/src/constants/PlayersConstants.ts | 4 ++-- Lib/src/constants/SmallEventConstants.ts | 4 ++-- Lib/src/instances/Logger.ts | 4 ++-- Lib/src/utils/StringUtils.ts | 2 +- 92 files changed, 193 insertions(+), 163 deletions(-) delete mode 100644 Lib/src/Constants.ts diff --git a/Core/src/commands/admin/testCommands/Fight/GloryPointsTestCommand.ts b/Core/src/commands/admin/testCommands/Fight/GloryPointsTestCommand.ts index f7fd8539e..95074e420 100644 --- a/Core/src/commands/admin/testCommands/Fight/GloryPointsTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Fight/GloryPointsTestCommand.ts @@ -1,5 +1,5 @@ import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; export const commandInfo: ITestCommand = { name: "glorypoints", diff --git a/Core/src/commands/admin/testCommands/Guild/ForceJoinGuildTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/ForceJoinGuildTestCommand.ts index f82f24dbe..78e80b0ed 100644 --- a/Core/src/commands/admin/testCommands/Guild/ForceJoinGuildTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/ForceJoinGuildTestCommand.ts @@ -1,7 +1,7 @@ import Guild from "../../../../core/database/game/models/Guild"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {Players} from "../../../../core/database/game/models/Player"; -import {GuildConstants} from "../../../../core/constants/GuildConstants"; +import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants"; export const commandInfo: ITestCommand = { name: "forcejoinguild", diff --git a/Core/src/commands/admin/testCommands/Guild/GuildLevelTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/GuildLevelTestCommand.ts index 381955d04..b08c5154c 100644 --- a/Core/src/commands/admin/testCommands/Guild/GuildLevelTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/GuildLevelTestCommand.ts @@ -1,6 +1,6 @@ import Guild from "../../../../core/database/game/models/Guild"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; -import {GuildConstants} from "../../../../core/constants/GuildConstants"; +import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants"; export const commandInfo: ITestCommand = { name: "guildlevel", diff --git a/Core/src/commands/admin/testCommands/Guild/GuildRewardTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/GuildRewardTestCommand.ts index bd6842bff..0f67012a2 100644 --- a/Core/src/commands/admin/testCommands/Guild/GuildRewardTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/GuildRewardTestCommand.ts @@ -1,5 +1,5 @@ import Guild from "../../../../core/database/game/models/Guild"; -import {GuildDailyConstants} from "../../../../core/constants/GuildDailyConstants"; +import {GuildDailyConstants} from "../../../../../../Lib/src/constants/GuildDailyConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; let stringDesc = "Force un gd avec une sortie donnée. Liste des sorties possibles : "; diff --git a/Core/src/commands/admin/testCommands/Guild/GuildScoreTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/GuildScoreTestCommand.ts index 15550d91c..603d76795 100644 --- a/Core/src/commands/admin/testCommands/Guild/GuildScoreTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/GuildScoreTestCommand.ts @@ -1,6 +1,6 @@ import Guild from "../../../../core/database/game/models/Guild"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {draftBotInstance} from "../../../../index"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Guild/GuildXpTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/GuildXpTestCommand.ts index ed90b963b..31a1e93fa 100644 --- a/Core/src/commands/admin/testCommands/Guild/GuildXpTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/GuildXpTestCommand.ts @@ -1,5 +1,5 @@ import Guild from "../../../../core/database/game/models/Guild"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Guild/SetFoodTestCommand.ts b/Core/src/commands/admin/testCommands/Guild/SetFoodTestCommand.ts index 45309a860..fca21ac01 100644 --- a/Core/src/commands/admin/testCommands/Guild/SetFoodTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Guild/SetFoodTestCommand.ts @@ -1,6 +1,6 @@ import Guild from "../../../../core/database/game/models/Guild"; import {getFoodIndexOf} from "../../../../core/utils/FoodUtils"; -import {Constants} from "../../../../core/Constants"; +import {Constants} from "../../../../../../Lib/src/constants/Constants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Map/TravelTestCommand.ts b/Core/src/commands/admin/testCommands/Map/TravelTestCommand.ts index a0310a4d2..a9f125677 100644 --- a/Core/src/commands/admin/testCommands/Map/TravelTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Map/TravelTestCommand.ts @@ -1,7 +1,7 @@ import {Maps} from "../../../../core/maps/Maps"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {TravelTime} from "../../../../core/maps/TravelTime"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {MapLinkDataController} from "../../../../data/MapLink"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Missions/AddGemsTestCommand.ts b/Core/src/commands/admin/testCommands/Missions/AddGemsTestCommand.ts index 1039d3562..dff7ae0cf 100644 --- a/Core/src/commands/admin/testCommands/Missions/AddGemsTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Missions/AddGemsTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {PlayerMissionsInfos} from "../../../../core/database/game/models/PlayerMissionsInfo"; diff --git a/Core/src/commands/admin/testCommands/Pet/PetLovePointsTestCommand.ts b/Core/src/commands/admin/testCommands/Pet/PetLovePointsTestCommand.ts index fa4ca24a8..b8cbec0e3 100644 --- a/Core/src/commands/admin/testCommands/Pet/PetLovePointsTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Pet/PetLovePointsTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {PetEntities} from "../../../../core/database/game/models/PetEntity"; diff --git a/Core/src/commands/admin/testCommands/Player/AddMoneyTestCommand.ts b/Core/src/commands/admin/testCommands/Player/AddMoneyTestCommand.ts index e214b6bf3..91642ee28 100644 --- a/Core/src/commands/admin/testCommands/Player/AddMoneyTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/AddMoneyTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Player/ExperienceTestCommand.ts b/Core/src/commands/admin/testCommands/Player/ExperienceTestCommand.ts index 8b44c5791..738959698 100644 --- a/Core/src/commands/admin/testCommands/Player/ExperienceTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/ExperienceTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Player/PlayerHealthTestCommand.ts b/Core/src/commands/admin/testCommands/Player/PlayerHealthTestCommand.ts index a1bb7b89b..8ea25daa0 100644 --- a/Core/src/commands/admin/testCommands/Player/PlayerHealthTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/PlayerHealthTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Player/PlayerMoneyTestCommand.ts b/Core/src/commands/admin/testCommands/Player/PlayerMoneyTestCommand.ts index 3cdcaffca..6299596fb 100644 --- a/Core/src/commands/admin/testCommands/Player/PlayerMoneyTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/PlayerMoneyTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Player/PlayerScoreTestCommand.ts b/Core/src/commands/admin/testCommands/Player/PlayerScoreTestCommand.ts index 029cf4ac8..da1f10717 100644 --- a/Core/src/commands/admin/testCommands/Player/PlayerScoreTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/PlayerScoreTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; export const commandInfo: ITestCommand = { diff --git a/Core/src/commands/admin/testCommands/Player/PlayerSuicideTestCommand.ts b/Core/src/commands/admin/testCommands/Player/PlayerSuicideTestCommand.ts index 4dd655da1..ee6fa95aa 100644 --- a/Core/src/commands/admin/testCommands/Player/PlayerSuicideTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/PlayerSuicideTestCommand.ts @@ -1,5 +1,5 @@ import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; export const commandInfo: ITestCommand = { name: "playerkill", diff --git a/Core/src/commands/admin/testCommands/Player/SkipTutorialTestCommand.ts b/Core/src/commands/admin/testCommands/Player/SkipTutorialTestCommand.ts index de3fb7054..fcf16ab7c 100644 --- a/Core/src/commands/admin/testCommands/Player/SkipTutorialTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Player/SkipTutorialTestCommand.ts @@ -1,5 +1,5 @@ import {Maps} from "../../../../core/maps/Maps"; -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest"; import {TravelTime} from "../../../../core/maps/TravelTime"; import {MapLinkDataController} from "../../../../data/MapLink"; diff --git a/Core/src/commands/admin/testCommands/Time/AdvanceTravelTestCommand.ts b/Core/src/commands/admin/testCommands/Time/AdvanceTravelTestCommand.ts index 43761383f..07e6fbbcd 100644 --- a/Core/src/commands/admin/testCommands/Time/AdvanceTravelTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Time/AdvanceTravelTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {TravelTime} from "../../../../core/maps/TravelTime"; diff --git a/Core/src/commands/admin/testCommands/Time/BlockPlayerTestCommand.ts b/Core/src/commands/admin/testCommands/Time/BlockPlayerTestCommand.ts index dc1d530b4..4cd2b6dd1 100644 --- a/Core/src/commands/admin/testCommands/Time/BlockPlayerTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Time/BlockPlayerTestCommand.ts @@ -1,7 +1,7 @@ import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import Player from "../../../../core/database/game/models/Player"; import {BlockingUtils} from "../../../../core/utils/BlockingUtils"; -import {BlockingConstants} from "../../../../core/constants/BlockingConstants"; +import {BlockingConstants} from "../../../../../../Lib/src/constants/BlockingConstants"; export const commandInfo: ITestCommand = { name: "blockplayer", diff --git a/Core/src/commands/admin/testCommands/Time/JailPlayerTestCommand.ts b/Core/src/commands/admin/testCommands/Time/JailPlayerTestCommand.ts index 64aaab467..60756c275 100644 --- a/Core/src/commands/admin/testCommands/Time/JailPlayerTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Time/JailPlayerTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {EffectsConstants} from "../../../../../../Lib/src/constants/EffectsConstants"; import {TravelTime} from "../../../../core/maps/TravelTime"; diff --git a/Core/src/commands/admin/testCommands/Time/PlayerEffectTestCommand.ts b/Core/src/commands/admin/testCommands/Time/PlayerEffectTestCommand.ts index cdb8882ab..cefe592ae 100644 --- a/Core/src/commands/admin/testCommands/Time/PlayerEffectTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Time/PlayerEffectTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest"; import {EffectsConstants} from "../../../../../../Lib/src/constants/EffectsConstants"; import {TravelTime} from "../../../../core/maps/TravelTime"; diff --git a/Core/src/commands/admin/testCommands/Time/RemovePlayerEffectTestCommand.ts b/Core/src/commands/admin/testCommands/Time/RemovePlayerEffectTestCommand.ts index 60e2dc346..4f3236b5a 100644 --- a/Core/src/commands/admin/testCommands/Time/RemovePlayerEffectTestCommand.ts +++ b/Core/src/commands/admin/testCommands/Time/RemovePlayerEffectTestCommand.ts @@ -1,4 +1,4 @@ -import {NumberChangeReason} from "../../../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest"; import {TravelTime} from "../../../../core/maps/TravelTime"; diff --git a/Core/src/commands/player/ProfileCommand.ts b/Core/src/commands/player/ProfileCommand.ts index 5c69f347f..2664737c6 100644 --- a/Core/src/commands/player/ProfileCommand.ts +++ b/Core/src/commands/player/ProfileCommand.ts @@ -1,7 +1,7 @@ import {PetEntities} from "../../core/database/game/models/PetEntity"; import PlayerMissionsInfo, {PlayerMissionsInfos} from "../../core/database/game/models/PlayerMissionsInfo"; import {InventorySlots} from "../../core/database/game/models/InventorySlot"; -import {FightConstants} from "../../core/constants/FightConstants"; +import {FightConstants} from "../../../../Lib/src/constants/FightConstants"; import {packetHandler} from "../../core/packetHandlers/PacketHandler"; import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient"; import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; @@ -9,7 +9,7 @@ import {CommandProfilePacketReq, CommandProfilePacketRes} from "../../../../Lib/ import {Campaign} from "../../core/missions/Campaign"; import {Players} from "../../core/database/game/models/Player"; import {Guilds} from "../../core/database/game/models/Guild"; -import {Constants} from "../../core/Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {hoursToMilliseconds} from "../../../../Lib/src/utils/TimeUtils"; import {PetDataController} from "../../data/Pet"; diff --git a/Core/src/commands/player/ReportCommand.ts b/Core/src/commands/player/ReportCommand.ts index 72b80c5bf..696b3b984 100644 --- a/Core/src/commands/player/ReportCommand.ts +++ b/Core/src/commands/player/ReportCommand.ts @@ -14,18 +14,18 @@ import {Player, Players} from "../../core/database/game/models/Player"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {Maps} from "../../core/maps/Maps"; import {MapLink, MapLinkDataController} from "../../data/MapLink"; -import {Constants} from "../../core/Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {getTimeFromXHoursAgo, millisecondsToMinutes, millisecondsToSeconds} from "../../../../Lib/src/utils/TimeUtils"; import {BlockingUtils} from "../../core/utils/BlockingUtils"; -import {BlockingConstants} from "../../core/constants/BlockingConstants"; +import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants"; import {MissionsController} from "../../core/missions/MissionsController"; import {FightController} from "../../core/fights/FightController"; -import {PVEConstants} from "../../core/constants/PVEConstants"; +import {PVEConstants} from "../../../../Lib/src/constants/PVEConstants"; import {MonsterDataController} from "../../data/Monster"; import {PlayerFighter} from "../../core/fights/fighter/PlayerFighter"; -import {NumberChangeReason} from "../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {Guilds} from "../../core/database/game/models/Guild"; -import {GuildConstants} from "../../core/constants/GuildConstants"; +import {GuildConstants} from "../../../../Lib/src/constants/GuildConstants"; import {draftBotInstance} from "../../index"; import {MonsterFighter} from "../../core/fights/fighter/MonsterFighter"; import {EndCallback, ReactionCollectorInstance} from "../../core/utils/ReactionsCollector"; @@ -44,7 +44,7 @@ import { import {MapCache} from "../../core/maps/MapCache"; import {TravelTime} from "../../core/maps/TravelTime"; import {SmallEventDataController, SmallEventFuncs} from "../../data/SmallEvent"; -import {ReportConstants} from "../../core/constants/ReportConstants"; +import {ReportConstants} from "../../../../Lib/src/constants/ReportConstants"; import {BigEvent, BigEventDataController} from "../../data/BigEvent"; import { ReactionCollectorBigEvent, diff --git a/Core/src/core/bot/DraftBot.ts b/Core/src/core/bot/DraftBot.ts index 1f4dc2acd..932142e94 100644 --- a/Core/src/core/bot/DraftBot.ts +++ b/Core/src/core/bot/DraftBot.ts @@ -10,7 +10,7 @@ import PetEntity from "../database/game/models/PetEntity"; import {RandomUtils} from "../utils/RandomUtils"; import {PotionDataController} from "../../data/Potion"; import {getNextDay2AM} from "../../../../Lib/src/utils/TimeUtils"; -import {TIMEOUT_FUNCTIONS} from "../constants/TimeoutFunctionsConstants"; +import {TIMEOUT_FUNCTIONS} from "../../../../Lib/src/constants/TimeoutFunctionsConstants"; import {MapCache} from "../maps/MapCache"; import {registerAllPacketHandlers} from "../packetHandlers/PacketHandler"; diff --git a/Core/src/core/database/game/migrations/003-remove-entity.ts b/Core/src/core/database/game/migrations/003-remove-entity.ts index 7e571dfd2..261e8aba8 100644 --- a/Core/src/core/database/game/migrations/003-remove-entity.ts +++ b/Core/src/core/database/game/migrations/003-remove-entity.ts @@ -1,5 +1,5 @@ import {DataTypes, QueryInterface} from "sequelize"; -import {EntityConstants} from "../../../constants/EntityConstants"; +import {EntityConstants} from "../../../../../../Lib/src/constants/EntityConstants"; import {entitiesAttributes001} from "./001-initial-database"; export async function up({context}: { context: QueryInterface }): Promise { diff --git a/Core/src/core/database/game/migrations/008-gloryandleague.ts b/Core/src/core/database/game/migrations/008-gloryandleague.ts index 0f0e5d562..49b38af11 100644 --- a/Core/src/core/database/game/migrations/008-gloryandleague.ts +++ b/Core/src/core/database/game/migrations/008-gloryandleague.ts @@ -1,5 +1,5 @@ import {DataTypes, QueryInterface} from "sequelize"; -import {FightConstants} from "../../../constants/FightConstants"; +import {FightConstants} from "../../../../../../Lib/src/constants/FightConstants"; export const leaguesAttributes008 = { id: { diff --git a/Core/src/core/database/game/models/Guild.ts b/Core/src/core/database/game/models/Guild.ts index bc262809d..22ecd7387 100644 --- a/Core/src/core/database/game/models/Guild.ts +++ b/Core/src/core/database/game/models/Guild.ts @@ -9,7 +9,7 @@ import {DraftBotPacket} from "../../../../../../Lib/src/packets/DraftBotPacket"; import {GuildLevelUpPacket} from "../../../../../../Lib/src/packets/notifications/GuildLevelUpPacket"; import moment = require("moment"); import {TopConstants} from "../../../../../../Lib/src/constants/TopConstants"; -import { Constants } from "../../../../../../Lib/src/Constants/Constants"; +import { Constants } from "../../../../../../Lib/src/constants/Constants"; import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants"; import {PetEntityConstants} from "../../../../../../Lib/src/constants/PetEntityConstants"; diff --git a/Core/src/core/database/game/models/GuildPet.ts b/Core/src/core/database/game/models/GuildPet.ts index 910f7fd69..28915e5bb 100644 --- a/Core/src/core/database/game/models/GuildPet.ts +++ b/Core/src/core/database/game/models/GuildPet.ts @@ -1,4 +1,4 @@ -import {DataTypes, Model, Sequelize} from "sequelize"; +import {CreateOptions, DataTypes, Model, Sequelize} from "sequelize"; import PetEntity from "./PetEntity"; import Guild from "./Guild"; import {draftBotInstance} from "../../../../index"; @@ -16,6 +16,18 @@ export class GuildPet extends Model { declare createdAt: Date; } +// Todo: this needs to be moved +export type ModelType = { create: (values?: unknown, options?: CreateOptions) => Promise> }; + +// Todo: moved the type below here from the constants; maybe somewhere else would be better ? +export type GuildLikeType = { + id: number, + name: string, + creationDate: Date, + chiefId: number, + guildPets: GuildPet[] +} + /** * This class is used to information about pets that are in a shelter */ diff --git a/Core/src/core/database/game/models/PetEntity.ts b/Core/src/core/database/game/models/PetEntity.ts index 4669135ff..7933bbbdb 100644 --- a/Core/src/core/database/game/models/PetEntity.ts +++ b/Core/src/core/database/game/models/PetEntity.ts @@ -1,7 +1,7 @@ import {DataTypes, Model, QueryTypes, Sequelize} from "sequelize"; import {RandomUtils} from "../../../utils/RandomUtils"; import {MissionsController} from "../../../missions/MissionsController"; -import {PET_ENTITY_GIVE_RETURN, PetEntityConstants} from "../../../constants/PetEntityConstants"; +import {PET_ENTITY_GIVE_RETURN, PetEntityConstants} from "../../../../../../Lib/src/constants/PetEntityConstants"; import {Player, PlayerEditValueParameters} from "./Player"; import {PetConstants} from "../../../../../../Lib/src/constants/PetConstants"; import {Guild, Guilds} from "./Guild"; diff --git a/Core/src/core/database/game/models/Player.ts b/Core/src/core/database/game/models/Player.ts index 836c0668b..fa9b28c5e 100644 --- a/Core/src/core/database/game/models/Player.ts +++ b/Core/src/core/database/game/models/Player.ts @@ -3,27 +3,15 @@ import InventorySlot, {InventorySlots} from "./InventorySlot"; import PetEntity from "./PetEntity"; import MissionSlot from "./MissionSlot"; import {InventoryInfos} from "./InventoryInfo"; -import {Constants} from "../../../Constants"; import {MissionsController} from "../../../missions/MissionsController"; import {PlayerActiveObjects} from "./PlayerActiveObjects"; -import {NumberChangeReason} from "../../../constants/LogsConstants"; import {EffectsConstants} from "../../../../../../Lib/src/constants/EffectsConstants"; -import {PlayersConstants} from "../../../constants/PlayersConstants"; -import {InventoryConstants} from "../../../constants/InventoryConstants"; import {getOneDayAgo, millisecondsToSeconds, minutesToHours} from "../../../../../../Lib/src/utils/TimeUtils"; import {TravelTime} from "../../../maps/TravelTime"; -import {EntityConstants} from "../../../constants/EntityConstants"; -import {BlockingConstants} from "../../../constants/BlockingConstants"; -import {GuildConstants} from "../../../constants/GuildConstants"; -import {FightConstants} from "../../../constants/FightConstants"; import {ItemCategory} from "../../../../../../Lib/src/constants/ItemConstants"; import {Maps} from "../../../maps/Maps"; -import {PVEConstants} from "../../../constants/PVEConstants"; -import {MapConstants} from "../../../constants/MapConstants"; import {RandomUtils} from "../../../utils/RandomUtils"; -import {LeagueInfoConstants} from "../../../constants/LeagueInfoConstants"; import {LogsReadRequests} from "../../logs/LogsReadRequests"; -import {ClassInfoConstants} from "../../../constants/ClassInfoConstants"; import {PlayerSmallEvents} from "./PlayerSmallEvent"; import {Guilds} from "./Guild"; import {DraftBotPacket} from "../../../../../../Lib/src/packets/DraftBotPacket"; @@ -39,6 +27,18 @@ import {BlockingUtils} from "../../../utils/BlockingUtils"; import {League, LeagueDataController} from "../../../../data/League"; import moment = require("moment"); import {TopConstants} from "../../../../../../Lib/src/constants/TopConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; +import {InventoryConstants} from "../../../../../../Lib/src/constants/InventoryConstants"; +import { Constants } from "../../../../../../Lib/src/constants/Constants"; +import {FightConstants} from "../../../../../../Lib/src/constants/FightConstants"; +import {LeagueInfoConstants} from "../../../../../../Lib/src/constants/LeagueInfoConstants"; +import {PVEConstants} from "../../../../../../Lib/src/constants/PVEConstants"; +import {PlayersConstants} from "../../../../../../Lib/src/constants/PlayersConstants"; +import {EntityConstants} from "../../../../../../Lib/src/constants/EntityConstants"; +import {ClassInfoConstants} from "../../../../../../Lib/src/constants/ClassInfoConstants"; +import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants"; +import {MapConstants} from "../../../../../../Lib/src/constants/MapConstants"; +import {BlockingConstants} from "../../../../../../Lib/src/constants/BlockingConstants"; export type PlayerEditValueParameters = { player: Player, diff --git a/Core/src/core/database/game/models/PlayerMissionsInfo.ts b/Core/src/core/database/game/models/PlayerMissionsInfo.ts index 6f662e92d..656f89693 100644 --- a/Core/src/core/database/game/models/PlayerMissionsInfo.ts +++ b/Core/src/core/database/game/models/PlayerMissionsInfo.ts @@ -1,6 +1,6 @@ import {DataTypes, Model, Sequelize} from "sequelize"; import {datesAreOnSameDay} from "../../../../../../Lib/src/utils/TimeUtils"; -import {NumberChangeReason} from "../../../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants"; import {draftBotInstance} from "../../../../index"; import {Campaign} from "../../../missions/Campaign"; import moment = require("moment"); diff --git a/Core/src/core/database/logs/LogsDatabase.ts b/Core/src/core/database/logs/LogsDatabase.ts index 5240de39f..d4bc7efdb 100644 --- a/Core/src/core/database/logs/LogsDatabase.ts +++ b/Core/src/core/database/logs/LogsDatabase.ts @@ -52,7 +52,7 @@ import {LogsMissionShopBuyouts} from "./models/LogsMissionShopBuyouts"; import {getFoodIndexOf} from "../../utils/FoodUtils"; import {LogsDailyTimeouts} from "./models/LogsDailyTimeouts"; import {LogsTopWeekEnd} from "./models/LogsTopWeekEnd"; -import {GuildDailyConstants} from "../../constants/GuildDailyConstants"; +import {GuildDailyConstants} from "../../../../../Lib/src/constants/GuildDailyConstants"; import {LogsGuildsDailies} from "./models/LogsGuildsDailies"; import {LogsPetsTransfers} from "./models/LogsPetsTransfers"; import {LogsGuildsLeaves} from "./models/LogsGuildsLeaves"; @@ -60,7 +60,7 @@ import {LogsGuildsDestroys} from "./models/LogsGuildsDestroys"; import {LogsGuildsEldersRemoves} from "./models/LogsGuildsEldersRemoves"; import {LogsGuildsChiefsChanges} from "./models/LogsGuildsChiefsChanges"; import {LogsPetsFrees} from "./models/LogsPetsFrees"; -import {GuildPets} from "../game/models/GuildPet"; +import {GuildLikeType, GuildPets, ModelType} from "../game/models/GuildPet"; import {LogsFightsResults} from "./models/LogsFightsResults"; import {LogsFightsActionsUsed} from "./models/LogsFightsActionsUsed"; import {LogsFightsActions} from "./models/LogsFightsActions"; @@ -78,7 +78,7 @@ import {LogsGuildsNewPets} from "./models/LogsGuildsNewPets"; import {LogsPlayersNewPets} from "./models/LogsPlayersNewPets"; import {EffectsConstants} from "../../../../../Lib/src/constants/EffectsConstants"; import {LogsPlayersDailies} from "./models/LogsPlayersDailies"; -import {GuildLikeType, ModelType, NumberChangeReason, ShopItemType} from "../../constants/LogsConstants"; +import {NumberChangeReason, ShopItemType} from "../../../../../Lib/src/constants/LogsConstants"; import {getDateLogs} from "../../../../../Lib/src/utils/TimeUtils"; import {LogsPlayersGloryPoints} from "./models/LogsPlayersGloryPoints"; import {LogsPlayers15BestSeason} from "./models/LogsPlayers15BestSeason"; diff --git a/Core/src/core/database/logs/LogsReadRequests.ts b/Core/src/core/database/logs/LogsReadRequests.ts index 4394866f3..0f9166a49 100644 --- a/Core/src/core/database/logs/LogsReadRequests.ts +++ b/Core/src/core/database/logs/LogsReadRequests.ts @@ -1,7 +1,7 @@ import {LogsDailyPotions} from "./models/LogsDailyPotions"; import {LogsClassicalShopBuyouts} from "./models/LogsClassicalShopBuyouts"; import {HasOne, Op} from "sequelize"; -import {ShopItemType} from "../../constants/LogsConstants"; +import {ShopItemType} from "../../../../../Lib/src/constants/LogsConstants"; import {LogsDatabase} from "./LogsDatabase"; import {LogsPlayersPossibilities} from "./models/LogsPlayersPossibilities"; import {LogsPossibilities} from "./models/LogsPossibilities"; @@ -9,14 +9,14 @@ import {LogsPlayers} from "./models/LogsPlayers"; import {LogsPlayersTravels} from "./models/LogsPlayersTravels"; import {getNextSaturdayMidnight, getNextSundayMidnight, minutesToMilliseconds} from "../../../../../Lib/src/utils/TimeUtils"; import {LogsMapLinks} from "./models/LogsMapLinks"; -import {MapConstants} from "../../constants/MapConstants"; +import {MapConstants} from "../../../../../Lib/src/constants/MapConstants"; import {LogsFightsResults} from "./models/LogsFightsResults"; import {LogsSeasonEnd} from "./models/LogsSeasonEnd"; import {LogsPlayerLeagueReward} from "./models/LogsPlayerLeagueReward"; import {LogsPlayersClassChanges} from "./models/LogsPlayersClassChanges"; import Player from "../game/models/Player"; import {MapCache} from "../../maps/MapCache"; -import {PVEConstants} from "../../constants/PVEConstants"; +import {PVEConstants} from "../../../../../Lib/src/constants/PVEConstants"; import {LogsGuildsJoins} from "./models/LogsGuildJoins"; import {LogsGuilds} from "./models/LogsGuilds"; import {MapLocationDataController} from "../../../data/MapLocation"; diff --git a/Core/src/core/fights/FightController.ts b/Core/src/core/fights/FightController.ts index 6327ad6c2..16c87130c 100644 --- a/Core/src/core/fights/FightController.ts +++ b/Core/src/core/fights/FightController.ts @@ -2,13 +2,13 @@ import {Fighter} from "./fighter/Fighter"; import {FightState} from "./FightState"; import {FightView} from "./FightView"; import {RandomUtils} from "../utils/RandomUtils"; -import {FightConstants} from "../constants/FightConstants"; +import {FightConstants} from "../../../../Lib/src/constants/FightConstants"; import {FighterStatus} from "./FighterStatus"; import {FightWeather, FightWeatherEnum} from "./FightWeather"; import {FightOvertimeBehavior} from "./FightOvertimeBehavior"; import {MonsterFighter} from "./fighter/MonsterFighter"; import {PlayerFighter} from "./fighter/PlayerFighter"; -import {PVEConstants} from "../constants/PVEConstants"; +import {PVEConstants} from "../../../../Lib/src/constants/PVEConstants"; import {PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; import {FightStatModifierOperation} from "../../../../Lib/src/interfaces/FightStatModifierOperation"; import {FightAlterationResult, FightAlterationState} from "../../../../Lib/src/interfaces/FightAlterationResult"; diff --git a/Core/src/core/fights/actions/FightActionController.ts b/Core/src/core/fights/actions/FightActionController.ts index d9640001d..fa5da61b9 100644 --- a/Core/src/core/fights/actions/FightActionController.ts +++ b/Core/src/core/fights/actions/FightActionController.ts @@ -1,4 +1,4 @@ -import {FightConstants} from "../../constants/FightConstants"; +import {FightConstants} from "../../../../../Lib/src/constants/FightConstants"; import {RandomUtils} from "../../utils/RandomUtils"; import {Fighter} from "../fighter/Fighter"; import {FightActionStatus} from "../../../../../Lib/src/interfaces/FightActionStatus"; diff --git a/Core/src/core/fights/actions/interfaces/alterations/cursed.ts b/Core/src/core/fights/actions/interfaces/alterations/cursed.ts index 53628dc4b..37c27e05c 100644 --- a/Core/src/core/fights/actions/interfaces/alterations/cursed.ts +++ b/Core/src/core/fights/actions/interfaces/alterations/cursed.ts @@ -1,7 +1,7 @@ import {Fighter} from "../../../fighter/Fighter"; import {attackInfo, FightActionController, statsInfo} from "../../FightActionController"; import {MathUtils} from "../../../../utils/MathUtils"; -import {FightConstants} from "../../../../constants/FightConstants"; +import {FightConstants} from "../../../../../../../Lib/src/constants/FightConstants"; import {FightAlterationFunc} from "../../../../../data/FightAlteration"; import {defaultFightAlterationResult, defaultHealFightAlterationResult} from "../../../FightController"; diff --git a/Core/src/core/fights/actions/interfaces/players/counterAttack.ts b/Core/src/core/fights/actions/interfaces/players/counterAttack.ts index 9bb1418b0..c5ec83b9d 100644 --- a/Core/src/core/fights/actions/interfaces/players/counterAttack.ts +++ b/Core/src/core/fights/actions/interfaces/players/counterAttack.ts @@ -1,4 +1,4 @@ -import {FightConstants} from "../../../../constants/FightConstants"; +import {FightConstants} from "../../../../../../../Lib/src/constants/FightConstants"; import {FightActionDataController, FightActionFunc} from "../../../../../data/FightAction"; import {defaultFailFightActionResult, defaultFightActionResult} from "../../../../../../../Lib/src/interfaces/FightActionResult"; diff --git a/Core/src/core/fights/actions/interfaces/players/divineAttack.ts b/Core/src/core/fights/actions/interfaces/players/divineAttack.ts index 082cad2af..ac6d0f539 100644 --- a/Core/src/core/fights/actions/interfaces/players/divineAttack.ts +++ b/Core/src/core/fights/actions/interfaces/players/divineAttack.ts @@ -1,6 +1,6 @@ import {Fighter} from "../../../fighter/Fighter"; import {attackInfo, FightActionController, statsInfo} from "../../FightActionController"; -import {FightConstants} from "../../../../constants/FightConstants"; +import {FightConstants} from "../../../../../../../Lib/src/constants/FightConstants"; import {FightAlterations} from "../../FightAlterations"; import {FightActionFunc} from "../../../../../data/FightAction"; import {simpleDamageFightAction} from "../../templates/SimpleDamageFightActionTemplate"; diff --git a/Core/src/core/fights/actions/interfaces/players/rageExplosion.ts b/Core/src/core/fights/actions/interfaces/players/rageExplosion.ts index 02b475d12..9a113682c 100644 --- a/Core/src/core/fights/actions/interfaces/players/rageExplosion.ts +++ b/Core/src/core/fights/actions/interfaces/players/rageExplosion.ts @@ -1,8 +1,8 @@ import {Fighter} from "../../../fighter/Fighter"; import {attackInfo, FightActionController, statsInfo} from "../../FightActionController"; import {PlayerFighter} from "../../../fighter/PlayerFighter"; -import {NumberChangeReason} from "../../../../constants/LogsConstants"; -import {PVEConstants} from "../../../../constants/PVEConstants"; +import {NumberChangeReason} from "../../../../../../../Lib/src/constants/LogsConstants"; +import {PVEConstants} from "../../../../../../../Lib/src/constants/PVEConstants"; import {FightActionFunc} from "../../../../../data/FightAction"; import {FightActionStatus} from "../../../../../../../Lib/src/interfaces/FightActionStatus"; diff --git a/Core/src/core/fights/fighter/Fighter.ts b/Core/src/core/fights/fighter/Fighter.ts index 6c8841cf4..781febf24 100644 --- a/Core/src/core/fights/fighter/Fighter.ts +++ b/Core/src/core/fights/fighter/Fighter.ts @@ -1,7 +1,7 @@ import {FighterStatus} from "../FighterStatus"; import {FightView} from "../FightView"; import {RandomUtils} from "../../utils/RandomUtils"; -import {PVEConstants} from "../../constants/PVEConstants"; +import {PVEConstants} from "../../../../../Lib/src/constants/PVEConstants"; import {FightStatModifierOperation} from "../../../../../Lib/src/interfaces/FightStatModifierOperation"; import {FightAlteration} from "../../../data/FightAlteration"; import {FightAction} from "../../../data/FightAction"; diff --git a/Core/src/core/fights/fighter/MonsterFighter.ts b/Core/src/core/fights/fighter/MonsterFighter.ts index 9b6cd4d99..71637b908 100644 --- a/Core/src/core/fights/fighter/MonsterFighter.ts +++ b/Core/src/core/fights/fighter/MonsterFighter.ts @@ -1,7 +1,7 @@ import {Fighter} from "./Fighter"; import {FightView} from "../FightView"; import {RandomUtils} from "../../utils/RandomUtils"; -import {PVEConstants} from "../../constants/PVEConstants"; +import {PVEConstants} from "../../../../../Lib/src/constants/PVEConstants"; import {FighterStatus} from "../FighterStatus"; import {Monster} from "../../../data/Monster"; import {FightAction, FightActionDataController} from "../../../data/FightAction"; diff --git a/Core/src/core/fights/fighter/PlayerFighter.ts b/Core/src/core/fights/fighter/PlayerFighter.ts index 8bd7be3ff..484c75a9d 100644 --- a/Core/src/core/fights/fighter/PlayerFighter.ts +++ b/Core/src/core/fights/fighter/PlayerFighter.ts @@ -4,16 +4,16 @@ import {InventorySlots} from "../../database/game/models/InventorySlot"; import {PlayerActiveObjects} from "../../database/game/models/PlayerActiveObjects"; import {checkDrinkPotionMissions} from "../../utils/ItemUtils"; import {BlockingUtils} from "../../utils/BlockingUtils"; -import {BlockingConstants} from "../../constants/BlockingConstants"; +import {BlockingConstants} from "../../../../../Lib/src/constants/BlockingConstants"; import {FightView} from "../FightView"; import {MissionsController} from "../../missions/MissionsController"; import {MissionSlots} from "../../database/game/models/MissionSlot"; import {getDayNumber} from "../../../../../Lib/src/utils/TimeUtils"; -import {NumberChangeReason} from "../../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../../Lib/src/constants/LogsConstants"; import {FighterStatus} from "../FighterStatus"; import {Maps} from "../../maps/Maps"; import {RandomUtils} from "../../utils/RandomUtils"; -import {PVEConstants} from "../../constants/PVEConstants"; +import {PVEConstants} from "../../../../../Lib/src/constants/PVEConstants"; import {Class} from "../../../data/Class"; import {FightAction, FightActionDataController} from "../../../data/FightAction"; import {DraftBotPacket} from "../../../../../Lib/src/packets/DraftBotPacket"; diff --git a/Core/src/core/maps/MapCache.ts b/Core/src/core/maps/MapCache.ts index 1e28423bc..89fad5d48 100644 --- a/Core/src/core/maps/MapCache.ts +++ b/Core/src/core/maps/MapCache.ts @@ -1,4 +1,4 @@ -import {MapConstants} from "../constants/MapConstants"; +import {MapConstants} from "../../../../Lib/src/constants/MapConstants"; import {RandomUtils} from "../utils/RandomUtils"; import {LogsMapLinks} from "../database/logs/models/LogsMapLinks"; import {Op, Sequelize} from "sequelize"; diff --git a/Core/src/core/maps/Maps.ts b/Core/src/core/maps/Maps.ts index bf793fb03..edfb5813f 100644 --- a/Core/src/core/maps/Maps.ts +++ b/Core/src/core/maps/Maps.ts @@ -1,6 +1,6 @@ import Player from "../database/game/models/Player"; import {TravelTime} from "./TravelTime"; -import {MapConstants} from "../constants/MapConstants"; +import {MapConstants} from "../../../../Lib/src/constants/MapConstants"; import {MapCache} from "./MapCache"; import {Op} from "sequelize"; import {LogsReadRequests} from "../database/logs/LogsReadRequests"; diff --git a/Core/src/core/maps/TravelTime.ts b/Core/src/core/maps/TravelTime.ts index 0ca23b78c..e77e8ee6a 100644 --- a/Core/src/core/maps/TravelTime.ts +++ b/Core/src/core/maps/TravelTime.ts @@ -1,11 +1,11 @@ import Player from "../database/game/models/Player"; import {millisecondsToMinutes, minutesToMilliseconds} from "../../../../Lib/src/utils/TimeUtils"; import {PlayerSmallEvents} from "../database/game/models/PlayerSmallEvent"; -import {Constants} from "../Constants"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {Maps} from "./Maps"; -import {PVEConstants} from "../constants/PVEConstants"; +import {PVEConstants} from "../../../../Lib/src/constants/PVEConstants"; import {MapLinkDataController} from "../../data/MapLink"; import {draftBotInstance} from "../../index"; import {TravelEndPushPacket} from "../../../../Lib/src/packets/push/TravelEndPushPacket"; diff --git a/Core/src/core/missions/MissionsController.ts b/Core/src/core/missions/MissionsController.ts index 52b4ddefc..08150d8d7 100644 --- a/Core/src/core/missions/MissionsController.ts +++ b/Core/src/core/missions/MissionsController.ts @@ -5,9 +5,9 @@ import {DailyMissions} from "../database/game/models/DailyMission"; import {hoursToMilliseconds} from "../../../../Lib/src/utils/TimeUtils"; import {MissionDifficulty} from "./MissionDifficulty"; import {Campaign} from "./Campaign"; -import {Constants} from "../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {RandomUtils} from "../utils/RandomUtils"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import PlayerMissionsInfo, {PlayerMissionsInfos} from "../database/game/models/PlayerMissionsInfo"; import {DraftBotPacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {MissionsExpiredPacket} from "../../../../Lib/src/packets/notifications/MissionsExpiredPacket"; diff --git a/Core/src/core/smallEvents/advanceTime.ts b/Core/src/core/smallEvents/advanceTime.ts index e8b35703d..15a3f02d4 100644 --- a/Core/src/core/smallEvents/advanceTime.ts +++ b/Core/src/core/smallEvents/advanceTime.ts @@ -2,7 +2,7 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {RandomUtils} from "../utils/RandomUtils"; import {TravelTime} from "../maps/TravelTime"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {SmallEventAdvanceTimePacket} from "../../../../Lib/src/packets/smallEvents/SmallEventAdvanceTimePacket"; import {Maps} from "../maps/Maps"; diff --git a/Core/src/core/smallEvents/bigBad.ts b/Core/src/core/smallEvents/bigBad.ts index 417471012..1f04a760b 100644 --- a/Core/src/core/smallEvents/bigBad.ts +++ b/Core/src/core/smallEvents/bigBad.ts @@ -1,7 +1,7 @@ import {SmallEventDataController, SmallEventFuncs} from "../../data/SmallEvent"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {RandomUtils} from "../utils/RandomUtils"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {TravelTime} from "../maps/TravelTime"; import {MissionsController} from "../missions/MissionsController"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; diff --git a/Core/src/core/smallEvents/bonusGuildPVEIsland.ts b/Core/src/core/smallEvents/bonusGuildPVEIsland.ts index 20be2fbde..9f1861e64 100644 --- a/Core/src/core/smallEvents/bonusGuildPVEIsland.ts +++ b/Core/src/core/smallEvents/bonusGuildPVEIsland.ts @@ -1,11 +1,11 @@ import {SmallEventDataController, SmallEventFuncs} from "../../data/SmallEvent"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {SmallEventBonusGuildPVEIslandPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventBonusGuildPVEIslandPacket"; import {DraftBotPacket, makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {Maps} from "../maps/Maps"; import Player from "../database/game/models/Player"; import {RandomUtils} from "../utils/RandomUtils"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {Guilds} from "../database/game/models/Guild"; type Malus = { diff --git a/Core/src/core/smallEvents/fightPet.ts b/Core/src/core/smallEvents/fightPet.ts index 6635e5490..7909fe152 100644 --- a/Core/src/core/smallEvents/fightPet.ts +++ b/Core/src/core/smallEvents/fightPet.ts @@ -1,14 +1,14 @@ import Player from "../database/game/models/Player"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; -import {ClassInfoConstants} from "../constants/ClassInfoConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; +import {ClassInfoConstants} from "../../../../Lib/src/constants/ClassInfoConstants"; import {FightPetAction, FightPetActionDataController} from "../../data/FightPetAction"; import {Maps} from "../maps/Maps"; import {SmallEventFuncs} from "../../data/SmallEvent"; import {PetDataController} from "../../data/Pet"; import {BlockingUtils} from "../utils/BlockingUtils"; import {makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; -import {BlockingConstants} from "../constants/BlockingConstants"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {RandomUtils} from "../utils/RandomUtils"; import {EndCallback, ReactionCollectorInstance} from "../utils/ReactionsCollector"; import {ReactionCollectorFightPet, ReactionCollectorFightPetReaction} from "../../../../Lib/src/packets/interaction/ReactionCollectorFightPet"; diff --git a/Core/src/core/smallEvents/fightPet/attackLeft.ts b/Core/src/core/smallEvents/fightPet/attackLeft.ts index a07e5eed8..fafdb549a 100644 --- a/Core/src/core/smallEvents/fightPet/attackLeft.ts +++ b/Core/src/core/smallEvents/fightPet/attackLeft.ts @@ -1,6 +1,6 @@ import Player from "../../database/game/models/Player"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; import {FightPetActionFunc} from "../../../data/FightPetAction"; export const fightPetAction: FightPetActionFunc = (player: Player): boolean => RandomUtils.draftbotRandom.bool( diff --git a/Core/src/core/smallEvents/fightPet/attackRight.ts b/Core/src/core/smallEvents/fightPet/attackRight.ts index a07e5eed8..fafdb549a 100644 --- a/Core/src/core/smallEvents/fightPet/attackRight.ts +++ b/Core/src/core/smallEvents/fightPet/attackRight.ts @@ -1,6 +1,6 @@ import Player from "../../database/game/models/Player"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; import {FightPetActionFunc} from "../../../data/FightPetAction"; export const fightPetAction: FightPetActionFunc = (player: Player): boolean => RandomUtils.draftbotRandom.bool( diff --git a/Core/src/core/smallEvents/fightPet/doNothing.ts b/Core/src/core/smallEvents/fightPet/doNothing.ts index 26d028886..eacbcb109 100644 --- a/Core/src/core/smallEvents/fightPet/doNothing.ts +++ b/Core/src/core/smallEvents/fightPet/doNothing.ts @@ -1,4 +1,4 @@ -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; import {RandomUtils} from "../../utils/RandomUtils"; import {FightPetActionFunc} from "../../../data/FightPetAction"; diff --git a/Core/src/core/smallEvents/fightPet/fistHit.ts b/Core/src/core/smallEvents/fightPet/fistHit.ts index c5bf1d22c..4436f325c 100644 --- a/Core/src/core/smallEvents/fightPet/fistHit.ts +++ b/Core/src/core/smallEvents/fightPet/fistHit.ts @@ -1,7 +1,7 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; import {InventorySlots} from "../../database/game/models/InventorySlot"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; export const fightPetAction: FightPetActionFunc = async (player, pet) => RandomUtils.draftbotRandom.bool( Math.max( diff --git a/Core/src/core/smallEvents/fightPet/focusEnergy.ts b/Core/src/core/smallEvents/fightPet/focusEnergy.ts index a80e5228b..a913f85f3 100644 --- a/Core/src/core/smallEvents/fightPet/focusEnergy.ts +++ b/Core/src/core/smallEvents/fightPet/focusEnergy.ts @@ -1,6 +1,6 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; export const fightPetAction: FightPetActionFunc = (player, pet) => // Chances of success is the ratio of remaining energy on total energy minus the rarity of the pet diff --git a/Core/src/core/smallEvents/fightPet/intimidate.ts b/Core/src/core/smallEvents/fightPet/intimidate.ts index 343a844a7..b3c10e59c 100644 --- a/Core/src/core/smallEvents/fightPet/intimidate.ts +++ b/Core/src/core/smallEvents/fightPet/intimidate.ts @@ -1,5 +1,5 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; import {RandomUtils} from "../../utils/RandomUtils"; export const fightPetAction: FightPetActionFunc = (player, pet) => diff --git a/Core/src/core/smallEvents/fightPet/lastEffort.ts b/Core/src/core/smallEvents/fightPet/lastEffort.ts index 76299b361..91cf2f6fe 100644 --- a/Core/src/core/smallEvents/fightPet/lastEffort.ts +++ b/Core/src/core/smallEvents/fightPet/lastEffort.ts @@ -1,6 +1,6 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; export const fightPetAction: FightPetActionFunc = (player, pet) => // Chances of success is the ratio of remaining energy on total energy minus the rarity of the pet diff --git a/Core/src/core/smallEvents/fightPet/prayGod.ts b/Core/src/core/smallEvents/fightPet/prayGod.ts index c944d666f..cabc25946 100644 --- a/Core/src/core/smallEvents/fightPet/prayGod.ts +++ b/Core/src/core/smallEvents/fightPet/prayGod.ts @@ -1,5 +1,5 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; import {InventorySlots} from "../../database/game/models/InventorySlot"; import {ItemConstants} from "../../../../../Lib/src/constants/ItemConstants"; import {RandomUtils} from "../../utils/RandomUtils"; diff --git a/Core/src/core/smallEvents/fightPet/protect.ts b/Core/src/core/smallEvents/fightPet/protect.ts index d0fc0b7e4..9997278f8 100644 --- a/Core/src/core/smallEvents/fightPet/protect.ts +++ b/Core/src/core/smallEvents/fightPet/protect.ts @@ -1,7 +1,7 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; import {InventorySlots} from "../../database/game/models/InventorySlot"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; export const fightPetAction: FightPetActionFunc = async (player, pet) => RandomUtils.draftbotRandom.bool( Math.max( diff --git a/Core/src/core/smallEvents/fightPet/runAway.ts b/Core/src/core/smallEvents/fightPet/runAway.ts index 1647617e5..d33d7c83d 100644 --- a/Core/src/core/smallEvents/fightPet/runAway.ts +++ b/Core/src/core/smallEvents/fightPet/runAway.ts @@ -1,7 +1,7 @@ import {FightPetActionFunc} from "../../../data/FightPetAction"; import {InventorySlots} from "../../database/game/models/InventorySlot"; import {RandomUtils} from "../../utils/RandomUtils"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; export const fightPetAction: FightPetActionFunc = async (player, pet) => RandomUtils.draftbotRandom.bool( Math.max( diff --git a/Core/src/core/smallEvents/fightPet/usePlayerPet.ts b/Core/src/core/smallEvents/fightPet/usePlayerPet.ts index a63b7d21e..13fe36d21 100644 --- a/Core/src/core/smallEvents/fightPet/usePlayerPet.ts +++ b/Core/src/core/smallEvents/fightPet/usePlayerPet.ts @@ -1,8 +1,8 @@ import {PetEntities} from "../../database/game/models/PetEntity"; import {FightPetActionFunc} from "../../../data/FightPetAction"; import {PetConstants} from "../../../../../Lib/src/constants/PetConstants"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; -import {PetEntityConstants} from "../../constants/PetEntityConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; +import {PetEntityConstants} from "../../../../../Lib/src/constants/PetEntityConstants"; import {RandomUtils} from "../../utils/RandomUtils"; import {PetDataController} from "../../../data/Pet"; diff --git a/Core/src/core/smallEvents/gobletsGame.ts b/Core/src/core/smallEvents/gobletsGame.ts index cf7615098..885dbe664 100644 --- a/Core/src/core/smallEvents/gobletsGame.ts +++ b/Core/src/core/smallEvents/gobletsGame.ts @@ -1,13 +1,13 @@ import {SmallEventDataController, SmallEventFuncs} from "../../data/SmallEvent"; -import {MapConstants} from "../constants/MapConstants"; +import {MapConstants} from "../../../../Lib/src/constants/MapConstants"; import {Maps} from "../maps/Maps"; -import {BlockingConstants} from "../constants/BlockingConstants"; +import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants"; import Player from "../database/game/models/Player"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {RandomUtils} from "../utils/RandomUtils"; import {BlockingUtils} from "../utils/BlockingUtils"; import {DraftBotPacket, makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {TravelTime} from "../maps/TravelTime"; import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; import {SmallEventGobletsGamePacket} from "../../../../Lib/src/packets/smallEvents/SmallEventGobletsGamePacket"; diff --git a/Core/src/core/smallEvents/interfaces/Shop.ts b/Core/src/core/smallEvents/interfaces/Shop.ts index 29922bed9..34c7c611c 100644 --- a/Core/src/core/smallEvents/interfaces/Shop.ts +++ b/Core/src/core/smallEvents/interfaces/Shop.ts @@ -4,12 +4,12 @@ import {Maps} from "../../maps/Maps"; import {ExecuteSmallEventLike} from "../../../data/SmallEvent"; import {getItemValue, giveItemToPlayer} from "../../utils/ItemUtils"; import {EndCallback, ReactionCollectorInstance} from "../../utils/ReactionsCollector"; -import {BlockingConstants} from "../../constants/BlockingConstants"; +import {BlockingConstants} from "../../../../../Lib/src/constants/BlockingConstants"; import {BlockingUtils} from "../../utils/BlockingUtils"; import {SmallEventAnyShopPacket} from "../../../../../Lib/src/packets/smallEvents/SmallEventAnyShopPacket"; import {InventorySlots} from "../../database/game/models/InventorySlot"; -import {SmallEventConstants} from "../../constants/SmallEventConstants"; -import {NumberChangeReason} from "../../constants/LogsConstants"; +import {SmallEventConstants} from "../../../../../Lib/src/constants/SmallEventConstants"; +import {NumberChangeReason} from "../../../../../Lib/src/constants/LogsConstants"; import {DraftBotPacket} from "../../../../../Lib/src/packets/DraftBotPacket"; import {ReactionCollectorMerchant, ReactionCollectorMerchantAcceptReaction} from "../../../../../Lib/src/packets/interaction/ReactionCollectorMerchant"; diff --git a/Core/src/core/smallEvents/shop.ts b/Core/src/core/smallEvents/shop.ts index e48ca39b0..a7da12af1 100644 --- a/Core/src/core/smallEvents/shop.ts +++ b/Core/src/core/smallEvents/shop.ts @@ -2,7 +2,7 @@ import {Shop} from "./interfaces/Shop"; import {SmallEventShopPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventShopPacket"; import {GenericItem} from "../../data/GenericItem"; import {RandomUtils} from "../utils/RandomUtils"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {generateRandomItem} from "../utils/ItemUtils"; import {ItemRarity} from "../../../../Lib/src/constants/ItemConstants"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; diff --git a/Core/src/core/smallEvents/winEnergy.ts b/Core/src/core/smallEvents/winEnergy.ts index 88916b909..420e1b311 100644 --- a/Core/src/core/smallEvents/winEnergy.ts +++ b/Core/src/core/smallEvents/winEnergy.ts @@ -1,7 +1,7 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; -import {MapConstants} from "../constants/MapConstants"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {MapConstants} from "../../../../Lib/src/constants/MapConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {SmallEventWinEnergyPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWinEnergyPacket"; export const smallEventFuncs: SmallEventFuncs = { diff --git a/Core/src/core/smallEvents/winFightPoints.ts b/Core/src/core/smallEvents/winFightPoints.ts index 0a717320c..142eb83dd 100644 --- a/Core/src/core/smallEvents/winFightPoints.ts +++ b/Core/src/core/smallEvents/winFightPoints.ts @@ -1,7 +1,7 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {RandomUtils} from "../utils/RandomUtils"; -import {PVEConstants} from "../constants/PVEConstants"; +import {PVEConstants} from "../../../../Lib/src/constants/PVEConstants"; import {SmallEventWinFightPointsPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWinFightPointsPacket"; import {Maps} from "../maps/Maps"; diff --git a/Core/src/core/smallEvents/winGuildXP.ts b/Core/src/core/smallEvents/winGuildXP.ts index 5a6afbee7..b13e01b7c 100644 --- a/Core/src/core/smallEvents/winGuildXP.ts +++ b/Core/src/core/smallEvents/winGuildXP.ts @@ -1,9 +1,9 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {RandomUtils} from "../utils/RandomUtils"; import {Guilds} from "../database/game/models/Guild"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {SmallEventWinGuildXPPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWinGuildXPPacket"; import {Maps} from "../maps/Maps"; diff --git a/Core/src/core/smallEvents/winHealth.ts b/Core/src/core/smallEvents/winHealth.ts index 8be91131a..f9efa8954 100644 --- a/Core/src/core/smallEvents/winHealth.ts +++ b/Core/src/core/smallEvents/winHealth.ts @@ -1,8 +1,8 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {RandomUtils} from "../utils/RandomUtils"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {SmallEventWinHealthPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWinHealthPacket"; import {Maps} from "../maps/Maps"; diff --git a/Core/src/core/smallEvents/winPersonalXP.ts b/Core/src/core/smallEvents/winPersonalXP.ts index ed8ee816b..08d591781 100644 --- a/Core/src/core/smallEvents/winPersonalXP.ts +++ b/Core/src/core/smallEvents/winPersonalXP.ts @@ -1,10 +1,10 @@ import {SmallEventFuncs} from "../../data/SmallEvent"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {makePacket} from "../../../../Lib/src/packets/DraftBotPacket"; import {RandomUtils} from "../utils/RandomUtils"; -import {NumberChangeReason} from "../constants/LogsConstants"; import {SmallEventWinPersonalXPPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWinPersonalXPPacket"; import {Maps} from "../maps/Maps"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; export const smallEventFuncs: SmallEventFuncs = { canBeExecuted: Maps.isOnContinent, diff --git a/Core/src/core/smallEvents/witch.ts b/Core/src/core/smallEvents/witch.ts index 44ba33fa2..c89c7967f 100644 --- a/Core/src/core/smallEvents/witch.ts +++ b/Core/src/core/smallEvents/witch.ts @@ -3,10 +3,10 @@ import {Maps} from "../maps/Maps"; import {EndCallback, ReactionCollectorInstance} from "../utils/ReactionsCollector"; import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket"; import {WitchAction, WitchActionDataController, WitchActionOutcomeType} from "../../data/WitchAction"; -import {Constants} from "../Constants"; -import {SmallEventConstants} from "../constants/SmallEventConstants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; +import {SmallEventConstants} from "../../../../Lib/src/constants/SmallEventConstants"; import {BlockingUtils} from "../utils/BlockingUtils"; -import {BlockingConstants} from "../constants/BlockingConstants"; +import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants"; import {RandomUtils} from "../utils/RandomUtils"; import {SmallEventWitchResultPacket} from "../../../../Lib/src/packets/smallEvents/SmallEventWitchPacket"; import {generateRandomItem, giveItemToPlayer} from "../utils/ItemUtils"; @@ -14,8 +14,8 @@ import {ItemCategory, ItemNature, ItemRarity} from "../../../../Lib/src/constant import Player from "../database/game/models/Player"; import {GenericItem} from "../../data/GenericItem"; import {InventorySlots} from "../database/game/models/InventorySlot"; -import {NumberChangeReason} from "../constants/LogsConstants"; import {ReactionCollectorWitch, ReactionCollectorWitchReaction} from "../../../../Lib/src/packets/interaction/ReactionCollectorWitch"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; type WitchEventSelection = { diff --git a/Core/src/core/utils/FoodUtils.ts b/Core/src/core/utils/FoodUtils.ts index 7b8b2ee8e..72bdd4d82 100644 --- a/Core/src/core/utils/FoodUtils.ts +++ b/Core/src/core/utils/FoodUtils.ts @@ -1,4 +1,4 @@ -import {Constants} from "../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; /** * Get the corresponding index in the constants of a given pet food diff --git a/Core/src/core/utils/ItemUtils.ts b/Core/src/core/utils/ItemUtils.ts index 90958a790..92b945a27 100644 --- a/Core/src/core/utils/ItemUtils.ts +++ b/Core/src/core/utils/ItemUtils.ts @@ -1,8 +1,8 @@ import InventorySlot, {InventorySlots} from "../database/game/models/InventorySlot"; import {MissionsController} from "../missions/MissionsController"; import {RandomUtils} from "./RandomUtils"; -import {BlockingConstants} from "../constants/BlockingConstants"; -import {NumberChangeReason} from "../constants/LogsConstants"; +import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import Player, {Players} from "../database/game/models/Player"; import {InventoryInfos} from "../database/game/models/InventoryInfo"; import {ItemCategory, ItemConstants, ItemNature, ItemRarity} from "../../../../Lib/src/constants/ItemConstants"; diff --git a/Core/src/core/utils/RandomUtils.ts b/Core/src/core/utils/RandomUtils.ts index 244d04125..d60df197e 100644 --- a/Core/src/core/utils/RandomUtils.ts +++ b/Core/src/core/utils/RandomUtils.ts @@ -1,5 +1,5 @@ import {Random} from "random-js"; -import {ConstantRange} from "../Constants"; +import {ConstantRange} from "../../../../Lib/src/constants/Constants"; /** * Functions concerning pseudo-randomness diff --git a/Core/src/core/utils/ReactionsCollector.ts b/Core/src/core/utils/ReactionsCollector.ts index 5bdf70777..e01dd07b3 100644 --- a/Core/src/core/utils/ReactionsCollector.ts +++ b/Core/src/core/utils/ReactionsCollector.ts @@ -10,7 +10,7 @@ import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/pac import {BlockingUtils} from "./BlockingUtils"; import {sendPacketsToContext} from "../../../../Lib/src/packets/PacketUtils"; import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient"; -import {Constants} from "../Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; type CollectCallback = (collector: ReactionCollectorInstance, reaction: ReactionCollectorReaction, keycloakId: string, response: DraftBotPacket[]) => void | Promise; diff --git a/Core/src/data/League.ts b/Core/src/data/League.ts index 681db225a..9d98af5ea 100644 --- a/Core/src/data/League.ts +++ b/Core/src/data/League.ts @@ -1,6 +1,6 @@ import {DataControllerNumber} from "./DataController"; import {Data} from "./Data"; -import {LeagueInfoConstants} from "../core/constants/LeagueInfoConstants"; +import {LeagueInfoConstants} from "../../../Lib/src/constants/LeagueInfoConstants"; import {GenericItem} from "./GenericItem"; import {generateRandomItem} from "../core/utils/ItemUtils"; diff --git a/Core/src/data/MainItem.ts b/Core/src/data/MainItem.ts index a4ef93afb..6a890b74c 100644 --- a/Core/src/data/MainItem.ts +++ b/Core/src/data/MainItem.ts @@ -1,7 +1,7 @@ import {GenericItem} from "./GenericItem"; -import {InventoryConstants} from "../core/constants/InventoryConstants"; import {MainItemDisplayPacket} from "../../../Lib/src/packets/commands/CommandInventoryPacket"; import {MaxStatsValues} from "../../../Lib/src/types/MaxStatsValues"; +import {InventoryConstants} from "../../../Lib/src/constants/InventoryConstants"; export abstract class MainItem extends GenericItem { diff --git a/Core/src/data/Monster.ts b/Core/src/data/Monster.ts index db37441fa..01f9edda0 100644 --- a/Core/src/data/Monster.ts +++ b/Core/src/data/Monster.ts @@ -1,7 +1,7 @@ import {DataControllerString} from "./DataController"; import {Data} from "./Data"; import {RandomUtils} from "../core/utils/RandomUtils"; -import {PVEConstants} from "../core/constants/PVEConstants"; +import {PVEConstants} from "../../../Lib/src/constants/PVEConstants"; export class Monster extends Data { public readonly emoji: string; diff --git a/Core/src/data/Pet.ts b/Core/src/data/Pet.ts index cc6ebf83d..8975b93f2 100644 --- a/Core/src/data/Pet.ts +++ b/Core/src/data/Pet.ts @@ -1,6 +1,6 @@ import {DataControllerNumber} from "./DataController"; import {Data} from "./Data"; -import {PetEntityConstants} from "../core/constants/PetEntityConstants"; +import {PetEntityConstants} from "../../../Lib/src/constants/PetEntityConstants"; import {RandomUtils} from "../core/utils/RandomUtils"; export class Pet extends Data { diff --git a/Core/src/data/WitchAction.ts b/Core/src/data/WitchAction.ts index 884c7aba5..0efb71e9e 100644 --- a/Core/src/data/WitchAction.ts +++ b/Core/src/data/WitchAction.ts @@ -3,11 +3,11 @@ import {Data} from "./Data"; import {readdirSync} from "fs"; import {RandomUtils} from "../core/utils/RandomUtils"; import Player from "../core/database/game/models/Player"; -import {SmallEventConstants} from "../core/constants/SmallEventConstants"; +import {SmallEventConstants} from "../../../Lib/src/constants/SmallEventConstants"; import {ItemNature, ItemRarity} from "../../../Lib/src/constants/ItemConstants"; import {DraftBotPacket} from "../../../Lib/src/packets/DraftBotPacket"; import {TravelTime} from "../core/maps/TravelTime"; -import {NumberChangeReason} from "../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../Lib/src/constants/LogsConstants"; import {EffectsConstants} from "../../../Lib/src/constants/EffectsConstants"; diff --git a/Core/src/data/events/PossibilityOutcome.ts b/Core/src/data/events/PossibilityOutcome.ts index c62d0c975..bdcdeba4e 100644 --- a/Core/src/data/events/PossibilityOutcome.ts +++ b/Core/src/data/events/PossibilityOutcome.ts @@ -1,8 +1,8 @@ import Player from "../../core/database/game/models/Player"; -import {NumberChangeReason} from "../../core/constants/LogsConstants"; +import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants"; import {generateRandomItem, giveItemToPlayer} from "../../core/utils/ItemUtils"; import {RandomUtils} from "../../core/utils/RandomUtils"; -import {Constants} from "../../core/Constants"; +import {Constants} from "../../../../Lib/src/constants/Constants"; import {PlayerSmallEvents} from "../../core/database/game/models/PlayerSmallEvent"; import {Maps} from "../../core/maps/Maps"; import {PlayerMissionsInfos} from "../../core/database/game/models/PlayerMissionsInfo"; diff --git a/Discord/src/commands/admin/TestCommand.ts b/Discord/src/commands/admin/TestCommand.ts index 07b4e70e2..4abc510eb 100644 --- a/Discord/src/commands/admin/TestCommand.ts +++ b/Discord/src/commands/admin/TestCommand.ts @@ -7,8 +7,8 @@ import {SlashCommandBuilder} from "@discordjs/builders"; import {DiscordCache} from "../../bot/DiscordCache"; import {DraftBotEmbed} from "../../messages/DraftBotEmbed"; import {HexColorString} from "discord.js"; -import {Constants} from "../../../../Lib/src/constants/Constants"; import {KeycloakUser} from "../../../../Lib/src/keycloak/KeycloakUser"; +import { ColorConstants } from "../../../../Lib/src/constants/ColorConstants"; async function getPacket(interaction: DraftbotInteraction, user: KeycloakUser): Promise { const commandName = interaction.options.get("command"); @@ -38,7 +38,7 @@ export async function handleCommandTestPacketRes(packet: CommandTestPacketRes, c iconURL: interaction.user.displayAvatarURL() }) .setDescription(packet.result) - .setColor( Constants.MESSAGES.COLORS.SUCCESSFUL); + .setColor( ColorConstants.SUCCESSFUL); await interaction.editReply({embeds: [embedTestSuccessful]}); } diff --git a/Lang/en/discordBuilder.json b/Lang/en/discordBuilder.json index 63fe67efb..5c3019770 100644 --- a/Lang/en/discordBuilder.json +++ b/Lang/en/discordBuilder.json @@ -29,6 +29,24 @@ "description": "Displays the ping of the bot and allow the player to check if the bot is online.", "name": "ping" }, + "guild": { + "description": "Displays information about a guild.", + "name": "guild", + "options": { + "rank": { + "description": "The rank of the player whose guild you want to display.", + "name": "rank" + }, + "user": { + "description": "The user whose guild should be displayed.", + "name": "user" + }, + "guildName": { + "description": "The name of the guild that should be displayed.", + "name": "guild" + } + } + }, "profile": { "description": "Displays the profile of a player.", "name": "profile", diff --git a/Lang/fr/discordBuilder.json b/Lang/fr/discordBuilder.json index 646a0a4dc..e2ccd0e48 100644 --- a/Lang/fr/discordBuilder.json +++ b/Lang/fr/discordBuilder.json @@ -29,6 +29,24 @@ "description": "Affiche la latence du bot et permet au joueur de vérifier si le bot est en ligne.", "name": "ping" }, + "guild": { + "description": "Affiche des informations sur une guilde.", + "name": "guilde", + "options": { + "rank": { + "description": "Le classement du joueur dont la guilde doit être affichée.", + "name": "classement" + }, + "user": { + "description": "L'utilisateur dont la guilde doit être affichée.", + "name": "utilisateur" + }, + "guildName": { + "description": "Le nom de la guilde dont les informations doivent être affichées.", + "name": "guilde" + } + } + }, "profile": { "description": "Afficher le profil d'un joueur.", "name": "profil", diff --git a/Lib/src/Constants.ts b/Lib/src/Constants.ts deleted file mode 100644 index d54d010fb..000000000 --- a/Lib/src/Constants.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const Constants = { - LOGS: { - MAX_LOGS_COUNT: 50000, - BASE_PATH: "./logs" - } -}; - -export type ConstantRange = { MIN: number, MAX: number }; diff --git a/Lib/src/constants/ClassInfoConstants.ts b/Lib/src/constants/ClassInfoConstants.ts index 11e9046bc..eb9b8ab96 100644 --- a/Lib/src/constants/ClassInfoConstants.ts +++ b/Lib/src/constants/ClassInfoConstants.ts @@ -1,4 +1,4 @@ -import {Constants} from "../Constants"; +import {Constants} from "./Constants"; export abstract class ClassInfoConstants { static readonly LIST_EMOTE = "\uD83D\uDD16"; diff --git a/Lib/src/constants/Constants.ts b/Lib/src/constants/Constants.ts index c1691f3bb..6ec2342ae 100644 --- a/Lib/src/constants/Constants.ts +++ b/Lib/src/constants/Constants.ts @@ -92,7 +92,8 @@ export class Constants { }; static readonly LOGS = { - LOG_COUNT_LINE_LIMIT: 50000 + LOG_COUNT_LINE_LIMIT: 50000, + BASE_PATH: "./logs" }; static readonly MISSION_SHOP = { @@ -290,4 +291,6 @@ export class Constants { }; static readonly DEFAULT_HEALED_EFFECT = ":hospital:"; -} \ No newline at end of file +} + +export type ConstantRange = { MIN: number, MAX: number }; \ No newline at end of file diff --git a/Lib/src/constants/LogsConstants.ts b/Lib/src/constants/LogsConstants.ts index b2370b5fd..f9a4038ab 100644 --- a/Lib/src/constants/LogsConstants.ts +++ b/Lib/src/constants/LogsConstants.ts @@ -1,6 +1,3 @@ -import {CreateOptions, Model} from "sequelize"; -import GuildPet from "../database/game/models/GuildPet"; - export enum NumberChangeReason { // Default value. Used to detect missing parameters in functions NULL, @@ -71,13 +68,3 @@ export enum ShopItemType { GUILD_XP, ENERGY_HEAL } - -export type ModelType = { create: (values?: unknown, options?: CreateOptions) => Promise> }; - -export type GuildLikeType = { - id: number, - name: string, - creationDate: Date, - chiefId: number, - guildPets: GuildPet[] -} diff --git a/Lib/src/constants/PlayersConstants.ts b/Lib/src/constants/PlayersConstants.ts index b761ecc89..447dfaf01 100644 --- a/Lib/src/constants/PlayersConstants.ts +++ b/Lib/src/constants/PlayersConstants.ts @@ -1,5 +1,5 @@ -import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants"; -import {NotificationsConstants} from "../../../../Lib/src/constants/NotificationsConstants"; +import {EffectsConstants} from "./EffectsConstants"; +import {NotificationsConstants} from "./NotificationsConstants"; export abstract class PlayersConstants { static readonly PLAYER_DEFAULT_VALUES = { diff --git a/Lib/src/constants/SmallEventConstants.ts b/Lib/src/constants/SmallEventConstants.ts index c369e8229..ea9aa4d38 100644 --- a/Lib/src/constants/SmallEventConstants.ts +++ b/Lib/src/constants/SmallEventConstants.ts @@ -1,5 +1,5 @@ -import {Constants} from "../Constants"; -import {ItemRarity} from "../../../../Lib/src/constants/ItemConstants"; +import {Constants} from "./Constants"; +import {ItemRarity} from "./ItemConstants"; export abstract class SmallEventConstants { static readonly HEALTH = { diff --git a/Lib/src/instances/Logger.ts b/Lib/src/instances/Logger.ts index 2421c0dcb..87874b1ec 100644 --- a/Lib/src/instances/Logger.ts +++ b/Lib/src/instances/Logger.ts @@ -1,6 +1,6 @@ import * as fs from "fs"; import {WriteStream} from "fs"; -import {Constants} from "../Constants"; +import {Constants} from "../constants/Constants"; enum LogWritingState { BUILDING, @@ -53,7 +53,7 @@ export class Logger { return; } this.lineCount++; - if (this.lineCount > Constants.LOGS.MAX_LOGS_COUNT) { + if (this.lineCount > Constants.LOGS.LOG_COUNT_LINE_LIMIT) { this.lineCount = 0; process.removeListener("uncaughtException", this.currentListener!); this.fileStream!.end(); diff --git a/Lib/src/utils/StringUtils.ts b/Lib/src/utils/StringUtils.ts index 9737d3987..6b30171be 100644 --- a/Lib/src/utils/StringUtils.ts +++ b/Lib/src/utils/StringUtils.ts @@ -1,5 +1,5 @@ import {StringConstants} from "../constants/StringConstants"; -import {ConstantRange} from "../Constants"; +import {ConstantRange} from "../constants/Constants"; /** * Remove discord formatting scrap from usernames