Skip to content

Commit

Permalink
feat: new campaign: joinMemberOnBoat
Browse files Browse the repository at this point in the history
mission in between the 15th and the previous 16th
  • Loading branch information
romain22222 committed Oct 17, 2023
1 parent c363ec5 commit ee6bd05
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
8 changes: 8 additions & 0 deletions resources/text/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@
"xpToWin": 25,
"moneyToWin": 0
},
{
"missionId": "joinMemberOnBoat",
"missionVariant": 0,
"missionObjective": 1,
"gemsToWin": 3,
"xpToWin": 100,
"moneyToWin": 0
},
{
"missionId": "spendGems",
"missionVariant": 0,
Expand Down
11 changes: 11 additions & 0 deletions resources/text/missions/joinMemberOnBoat.json
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 7 additions & 1 deletion src/commands/player/JoinBoatCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/core/database/game/GameDatabaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {QueryInterface} from "sequelize";
*/
export async function addCampaignMission(context: QueryInterface, position: number): Promise<void> {
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}))`);
}

/**
Expand All @@ -22,7 +22,7 @@ export async function addCampaignMissionList(context: QueryInterface, positions:
*/
export async function removeCampaignMission(context: QueryInterface, position: number): Promise<void> {
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}))`);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/core/database/game/migrations/018-newCampaignMission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {QueryInterface} from "sequelize";
import {addCampaignMissionList, removeCampaignMissionList} from "../GameDatabaseUtils";

export async function up({context}: { context: QueryInterface }): Promise<void> {
await addCampaignMissionList(context, [16]);
}

export async function down({context}: { context: QueryInterface }): Promise<void> {
await removeCampaignMissionList(context, [16]);
}
5 changes: 4 additions & 1 deletion src/core/smallEvents/goToPVEIslandSmallEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ export async function confirmationCallback(
emote: string,
price: number,
anotherMemberOnBoat: Player = null
): Promise<void> {
): Promise<boolean> {
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,
Expand All @@ -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 = {
Expand Down

0 comments on commit ee6bd05

Please sign in to comment.