-
Notifications
You must be signed in to change notification settings - Fork 24
Add Geschenkpapier as loot item #605
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
Merged
+203
−30
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
357f55b
Add Geschenkpapier as loot item
twobiers 37ed143
Add wrapable property to loot templates and implement wrapping functi…
twobiers d93acbb
Fix rarity attribute assignment in postLootDrop function
twobiers 2fe65bc
Use ?
twobiers fe7d34e
remove undefined
twobiers 19a4ab7
Implement LootDropCommand and update BotContext for development commands
twobiers 58f7687
Add randomized and fixed loot drop functions
twobiers 081ee26
Implement randomized / predefined drop strategy
twobiers 6cf8b44
Implement transfer strategy
twobiers bb4a157
Merge branch 'master' into geschenkpapier
holzmaster 0182518
Simplify guards
twobiers ec7c05c
Use config file for dev commands
twobiers 8e758d3
Merge branch 'master' into geschenkpapier
holzmaster 0e26b0e
Rewrite to use callbacks
twobiers c3ff6e2
rename parameters for clarity and improve wrapping paper logic
twobiers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { | ||
| ChannelType, | ||
| type CommandInteraction, | ||
| SlashCommandBuilder, | ||
| SlashCommandNumberOption, | ||
| } from "discord.js"; | ||
|
|
||
| import type { BotContext } from "#/context.ts"; | ||
| import type { ApplicationCommand } from "#/commands/command.ts"; | ||
| import { ensureChatInputCommand } from "#/utils/interactionUtils.ts"; | ||
|
|
||
| import * as lootDataService from "#/service/lootData.ts"; | ||
| import * as lootService from "#/service/loot.ts"; | ||
|
|
||
| import { postLootDrop, type LootClaimCallback } from "#/service/lootDrop.ts"; | ||
|
|
||
| export default class LootDropCommand implements ApplicationCommand { | ||
| name = "loot-drop"; | ||
| description = "Drops dir 1 Loot"; | ||
|
|
||
| applicationCommand = new SlashCommandBuilder() | ||
| .setName(this.name) | ||
| .setDescription(this.description) | ||
| .addNumberOption( | ||
| new SlashCommandNumberOption() | ||
| .setName("loot-kind-id") | ||
| .setDescription("Loot ID die gedroppt werden soll") | ||
| .setMinValue(0), | ||
| ); | ||
|
|
||
| async handleInteraction(interaction: CommandInteraction, context: BotContext) { | ||
| const command = ensureChatInputCommand(interaction); | ||
|
|
||
| if (command.guild === null) { | ||
| throw new Error("Interaction not in guild"); | ||
| } | ||
| if (command.channel?.type !== ChannelType.GuildText) { | ||
| throw new Error("Interaction not in text channel"); | ||
| } | ||
|
|
||
| const lootKindId = command.options.getNumber("loot-kind-id", false); | ||
| if (lootKindId === null) { | ||
| await command.reply({ | ||
| content: "Es muss eine Loot ID angegeben werden.", | ||
| ephemeral: true, | ||
| }); | ||
| return; | ||
| } | ||
| const lootTemplate = lootDataService.resolveLootTemplate(lootKindId); | ||
| if (lootTemplate === undefined) { | ||
| await command.reply({ | ||
| content: `Es konnte kein Loot mit der ID ${lootKindId} gefunden werden.`, | ||
| ephemeral: true, | ||
| }); | ||
| return; | ||
| } | ||
| const predefinedLootClaim: LootClaimCallback = async (winner, message) => { | ||
| const loot = await lootService.createLoot( | ||
| lootTemplate, | ||
| winner, | ||
| message, | ||
| "drop", | ||
| null, | ||
| null, | ||
| ); | ||
| if (!loot) return undefined; | ||
| return { loot, template: lootTemplate, rarity: undefined, messages: [] }; | ||
| }; | ||
| await postLootDrop(context, command.channel, command.user, predefinedLootClaim); | ||
| await command.reply({ | ||
| content: `Es wurde ${lootTemplate.id} gedroppt!`, | ||
| ephemeral: true, | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.