From ee6bd059aebb269bd3f8102f5ce67ba52d790038 Mon Sep 17 00:00:00 2001 From: romain22222 Date: Tue, 17 Oct 2023 13:53:05 +0200 Subject: [PATCH] feat: new campaign: joinMemberOnBoat mission in between the 15th and the previous 16th --- resources/text/campaign.json | 8 ++++++++ resources/text/missions/joinMemberOnBoat.json | 11 +++++++++++ src/commands/player/JoinBoatCommand.ts | 8 +++++++- src/core/database/game/GameDatabaseUtils.ts | 4 ++-- .../game/migrations/018-newCampaignMission.ts | 10 ++++++++++ src/core/smallEvents/goToPVEIslandSmallEvent.ts | 5 ++++- 6 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 resources/text/missions/joinMemberOnBoat.json create mode 100644 src/core/database/game/migrations/018-newCampaignMission.ts diff --git a/resources/text/campaign.json b/resources/text/campaign.json index 27c77e8de..89ce00c0e 100644 --- a/resources/text/campaign.json +++ b/resources/text/campaign.json @@ -120,6 +120,14 @@ "xpToWin": 25, "moneyToWin": 0 }, + { + "missionId": "joinMemberOnBoat", + "missionVariant": 0, + "missionObjective": 1, + "gemsToWin": 3, + "xpToWin": 100, + "moneyToWin": 0 + }, { "missionId": "spendGems", "missionVariant": 0, diff --git a/resources/text/missions/joinMemberOnBoat.json b/resources/text/missions/joinMemberOnBoat.json new file mode 100644 index 000000000..2a0844272 --- /dev/null +++ b/resources/text/missions/joinMemberOnBoat.json @@ -0,0 +1,11 @@ +{ + "translations": { + "fr": { + "desc": "Rejoindre un membre sur l'île via la commande {command:joinboat}" + }, + "en": { + "desc": "Join a member on the island via the {command:joinboat} command" + } + }, + "campaignOnly": true +} \ No newline at end of file diff --git a/src/commands/player/JoinBoatCommand.ts b/src/commands/player/JoinBoatCommand.ts index 660ad83bd..430b1cb02 100644 --- a/src/commands/player/JoinBoatCommand.ts +++ b/src/commands/player/JoinBoatCommand.ts @@ -15,6 +15,7 @@ import {EffectsConstants} from "../../core/constants/EffectsConstants"; import {PVEConstants} from "../../core/constants/PVEConstants"; import {LogsReadRequests} from "../../core/database/logs/LogsReadRequests"; import {DraftBotEmbed} from "../../core/messages/DraftBotEmbed"; +import {MissionsController} from "../../core/missions/MissionsController"; /** * Displays information about the profile of the player who sent the command @@ -53,7 +54,12 @@ async function executeCommand(interaction: CommandInteraction, language: string, reactionMessage: confirmMessage, embed: new DraftBotEmbed().formatAuthor(tr.get("confirmedTitle"), interaction.user), tr - },":ferry:", price, guildOnBoat[0]).then(); + }, ":ferry:", price, guildOnBoat[0]).then(async (hasJoinedBoat) => { + await MissionsController.update(player, interaction.channel, language, { + missionId: "joinMemberOnBoat", + set: hasJoinedBoat + }); + }); } ); await interaction.deferReply(); diff --git a/src/core/database/game/GameDatabaseUtils.ts b/src/core/database/game/GameDatabaseUtils.ts index f83f1a1d9..230214bc9 100644 --- a/src/core/database/game/GameDatabaseUtils.ts +++ b/src/core/database/game/GameDatabaseUtils.ts @@ -5,7 +5,7 @@ import {QueryInterface} from "sequelize"; */ export async function addCampaignMission(context: QueryInterface, position: number): Promise { await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignProgression = campaignProgression + 1 WHERE campaignProgression > ${position}`); - await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignBlob = CONCAT(SUBSTR(campaignBlob, 0, ${position - 1}), "0", SUBSTR(campaignBlob, ${position}))`); + await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignBlob = CONCAT(SUBSTR(campaignBlob, 1, ${position - 1}), "0", SUBSTR(campaignBlob, ${position}))`); } /** @@ -22,7 +22,7 @@ export async function addCampaignMissionList(context: QueryInterface, positions: */ export async function removeCampaignMission(context: QueryInterface, position: number): Promise { await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignProgression = campaignProgression - 1 WHERE campaignProgression >= ${position}`); - await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignBlob = CONCAT(SUBSTR(campaignBlob, 0, ${position - 1}), SUBSTR(campaignBlob, ${position + 1}))`); + await context.sequelize.query(`UPDATE draftbot_game.player_missions_info SET campaignBlob = CONCAT(SUBSTR(campaignBlob, 1, ${position - 1}), SUBSTR(campaignBlob, ${position + 1}))`); } /** diff --git a/src/core/database/game/migrations/018-newCampaignMission.ts b/src/core/database/game/migrations/018-newCampaignMission.ts new file mode 100644 index 000000000..4bbfc9962 --- /dev/null +++ b/src/core/database/game/migrations/018-newCampaignMission.ts @@ -0,0 +1,10 @@ +import {QueryInterface} from "sequelize"; +import {addCampaignMissionList, removeCampaignMissionList} from "../GameDatabaseUtils"; + +export async function up({context}: { context: QueryInterface }): Promise { + await addCampaignMissionList(context, [16]); +} + +export async function down({context}: { context: QueryInterface }): Promise { + await removeCampaignMissionList(context, [16]); +} \ No newline at end of file diff --git a/src/core/smallEvents/goToPVEIslandSmallEvent.ts b/src/core/smallEvents/goToPVEIslandSmallEvent.ts index 62c8e8268..504c991ae 100644 --- a/src/core/smallEvents/goToPVEIslandSmallEvent.ts +++ b/src/core/smallEvents/goToPVEIslandSmallEvent.ts @@ -30,13 +30,15 @@ export async function confirmationCallback( emote: string, price: number, anotherMemberOnBoat: Player = null -): Promise { +): Promise { + let isGoneOnIsland = false; if (messageData.reactionMessage.isValidated()) { const missionInfo = await PlayerMissionsInfos.getOfPlayer(player.id); if (missionInfo.gems < price) { messageData.embed.setDescription(`${emote} ${messageData.tr.get("notEnoughGems")}`); } else { + isGoneOnIsland = true; await TravelTime.removeEffect(player, NumberChangeReason.SMALL_EVENT); await Maps.startTravel( player, @@ -55,6 +57,7 @@ export async function confirmationCallback( embeds: [messageData.embed] }); BlockingUtils.unblockPlayer(player.discordUserId, BlockingConstants.REASONS.PVE_ISLAND); + return isGoneOnIsland; } export const smallEvent: SmallEvent = {