Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2302 #2314

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/core/smallEvents/cartSmallEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async function generateInitialEmbed(
builtEmbed.formatAuthor(Translations.getModule("commands.report", language).get("journal"), interaction.user);
builtEmbed.setDescription(
`${seEmbed.data.description
+ intro
+ situation
+ tr.get("menu")}`
+ intro
+ situation
+ tr.get("menu")}`
);
return builtEmbed;
}
Expand Down Expand Up @@ -92,40 +92,44 @@ async function manageTeleportation(cartObject: CartObject, interaction: Draftbot

export const smallEvent: SmallEvent = {
/**
* Check if small event can be executed
*/
* Check if small event can be executed
*/
canBeExecuted(player: Player): Promise<boolean> {
return Promise.resolve(Maps.isOnContinent(player));
},


/**
* Execute the small event
* @param interaction
* @param language
* @param player
* @param seEmbed
*/
* Execute the small event
* @param interaction
* @param language
* @param player
* @param seEmbed
*/
async executeSmallEvent(interaction: DraftbotInteraction, language: string, player: Player, seEmbed: DraftBotEmbed): Promise<void> {
const tr = Translations.getModule("smallEvents.cart", language);
const chance = RandomUtils.draftbotRandom.realZeroToOneInclusive();

const destination = await MapLinks.generateRandomMapLinkDifferentOfCurrent(player.mapLinkId);
let price = SmallEventConstants.CART.TRANSPARENT_TP_PRICE, displayedDestination = destination;
let price: number, displayedDestination: MapLink;

// 40% chance that the player knows where they will be teleported
if (chance <= SmallEventConstants.CART.HIDDEN_TP_THRESHOLD && chance > SmallEventConstants.CART.TRANSPARENT_TP_THRESHOLD) {
// 50% chance that the player doesn't know where they will be teleported
if (chance <= SmallEventConstants.CART.TRANSPARENT_TP_THRESHOLD) {
pwaillette marked this conversation as resolved.
Show resolved Hide resolved
// The player knows where they will be teleported
price = SmallEventConstants.CART.TRANSPARENT_TP_PRICE;
displayedDestination = destination;
}
else if (chance <= SmallEventConstants.CART.HIDDEN_TP_THRESHOLD) {
// The player doesn't know where they will be teleported
displayedDestination = null;
price = SmallEventConstants.CART.HIDDEN_TP_PRICE;
}
else if (chance <= SmallEventConstants.CART.SCAM_THRESHOLD) {
// 5% chance that the NPC lied about the destination but offers the trip for cheap
// The NPC lied about the destination but offers the trip for cheap
displayedDestination = await MapLinks.generateRandomMapLinkDifferentOfCurrent(player.mapLinkId);
price = SmallEventConstants.CART.SCAM_TP_PRICE;
pwaillette marked this conversation as resolved.
Show resolved Hide resolved
}
else {
// 5% chance that the trip is just cheap
// The trip is just cheap
displayedDestination = destination;
price = SmallEventConstants.CART.SCAM_TP_PRICE;
}
Expand Down
Loading