From dd7b3b56852088938f403c8228b4616b879d4e72 Mon Sep 17 00:00:00 2001 From: twonirwana Date: Mon, 18 Mar 2024 14:29:46 +0100 Subject: [PATCH] Blades in the Dark - Detail and Welcome update (#474) * Blades in the Dark - Detail and Welcome update * update dice evaluator lib --- README.adoc | 8 +- bot/build.gradle.kts | 2 +- .../main/java/de/janno/discord/bot/Bot.java | 7 +- .../CustomParameterCommand.java | 4 +- .../command/help/RpgSystemCommandPreset.java | 9 ++ .../bot/command/help/WelcomeCommand.java | 141 +++++++----------- .../bot/dice/CachingDiceEvaluator.java | 6 +- bot/src/main/resources/botMessages.properties | 3 + .../bot/command/FetchCommandMockTest.java | 2 +- .../channelConfig/ChannelConfigMockTest.java | 2 +- .../customDice/CustomDiceCommandMockTest.java | 48 +++--- .../customDice/CustomDiceCommandTest.java | 2 +- .../CustomParameterCommandMockTest.java | 42 +++--- .../CustomParameterCommandTest.java | 6 +- .../directRoll/AliasRollCommandTest.java | 2 +- .../directRoll/AliasRollCommandTest.snap | 8 +- .../directRoll/DirectRollCommandMockTest.java | 26 ++-- .../directRoll/DirectRollCommandTest.java | 2 +- .../directRoll/DirectRollCommandTest.snap | 8 +- .../directRoll/HiddenRollCommandMockTest.java | 24 +-- .../directRoll/HiddenRollCommandTest.java | 2 +- .../directRoll/HiddenRollCommandTest.snap | 8 +- .../directRoll/ValidationCommandTest.java | 2 +- .../directRoll/ValidationCommandTest.snap | 8 +- .../help/QuickstartCommandMockTest.java | 4 +- .../help/QuickstartCommandMockTest.snap | 92 ++++++++++++ .../command/help/QuickstartCommandTest.java | 4 +- .../command/help/WelcomeCommandMockTest.java | 98 ++++++++++++ .../command/help/WelcomeCommandMockTest.snap | 47 ++++++ .../bot/command/help/WelcomeCommandTest.java | 63 ++------ .../SumCustomSetCommandMockTest.java | 40 ++--- .../sumCustomSet/SumCustomSetCommandTest.java | 6 +- .../dice/image/ImageResultCreatorTest.java | 102 ++++++------- bot/src/test/resources/application-test.yaml | 4 +- config.yaml | 2 + 35 files changed, 519 insertions(+), 315 deletions(-) create mode 100644 bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.java create mode 100644 bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.snap diff --git a/README.adoc b/README.adoc index 418b21e9..4fe35609 100644 --- a/README.adoc +++ b/README.adoc @@ -47,6 +47,7 @@ Please let me know if you have a good new preset or an improved version for an e |=== |`A Song of Ice and Fire` |`Blades in the Dark` +|`Blades in the Dark - Detail` |`Blades in the Dark without Dice Images` |`Bluebeard's Bride` |`Call of Cthulhu 7th Edition` @@ -581,7 +582,7 @@ All operators are case insensitiv. |=== |Name |Notation |Example |Description |Precedent |Associativity |Left parameter |Right parameter |Repeat |`x` |`3x2d6` |Repeats the expression separately a number of times given in . This should be used outside other expressions and will not work inside most expressions |0 |left |a single integer number between 1-10 | a expression -|List Repeat |`r` |`3r(2d6=)` |Repeats the expression a number of times given in and combines the results in one list. |1 |left |a single integer number between 0-10 | a expression +|List Repeat |`r` |`3r(2d6=)` |Repeats the expression a number of times given in and combines the results in one list. |1 |left |a single integer number between 0-20 | a expression | Concat |`_` |`d20_'dmg''` | Combines the result of both expression into on single element |2 |left |one or more elements | one or more elements |Or |`\|\|` |`d6=?5 \|\| d6=?6` | Boolean or operation of the two boolean values | 3 |left | boolean value | boolean value |And |`&&` |`d6=?5 && d6=?6` | Boolean and operation of the two boolean values | 4 |left | boolean value | boolean value @@ -596,7 +597,7 @@ All operators are case insensitiv. |Modulo |` mod ` |`d6 mod 2` | returns the remainder of the division |13 |left |a single integer number |a single non zero integer number |Multiply |` * ` |`2 * 6` |Multiplies the right number with the left number |14|left |a single number |a single number |Divide |` / ` |`4 / 2` |Divides the right number with the left number and rounds down to the next full number |15 |left |a single integer number |a single integer number -|Decimal Divide |` // ` |`4 / 2` |Divides the right number with the left number and provides a decimal number with up to 5 decimal digital |16 |left |a single number |a single number +|Decimal Divide |` // ` |`4 // 3` |Divides the right number with the left number and provides a decimal number with up to 5 decimal digital |16 |left |a single number |a single number |Count |` c` |`3d6>3c` |Counts the number of elements in a list |17 |left |a list |- |Greater Then Filter |` > ` |`3d6>3` |Keeps only the elements of the left list that are bigger as the right number. Applies only to elements with the same tag. |18 |left |one or more numbers |a single number |Lesser Then Filter |` < ` |`3d6<3` |Keeps only the elements of the left list that are lesser as the right number. Applies only to elements with the same tag. |19 |left |one or more numbers |a single number @@ -627,7 +628,8 @@ All functions are case insensitiv. |sort asc |`asc(, ...)` |`asc(4d6)` |sorts all elements ascending of one or more inner expressions. Text is compared alphabetically |sort desc |`desc(, ...)` |`desc(4d6)` |sorts all elements descending of one or more inner expressions. Text is compared alphabetically |cancel |`cancel(, , )` |`cancel(8d10, 10, 1)` |the elements of listA and listB (can also be single elements) cancel each other and remove each other from the result. -|replace |`replace(, , ...)` |`replace(8d10, [9/10], 'bonus')` | each element in `` that matches on of the elements in `` will be replaced with the elements in ``. `` can be an empty list `[]` or literal `''` and thereby removing the found elements. It is possible to add multiple / pairs to replace different elements in one replace. +|replace |`replace(, , ...)` |`replace(8d10, [9/10], 'bonus')` | each element in `` that matches on of the elements in `` will be replaced with the elements in ``. `` can be an empty list `[]` or literal `''` and thereby removing the found elements. It is possible to add multiple / pairs to replace different elements in one replace. If the expression contains dice then they will only be rolled on a matching find element and for each matching element again. +|explode |`exp(,,` |`exp(d[1/2/3],[2/3])` or `exp(d[1/2/3],[2/3], 2)` | Rerolls the `` expression if any of its result elements are in the elements of `` and returns the original result and all reroll results. If `` contain more then one die then all are rerolled, even if only on result of one die matches the reroll list. `` define the maximum number of rerolls bevor the function stops with rerolls and returns the current result. `` must be a number between 0 and 100. If `` is not provided as argument then 100 will be used. |if |`if(,,)` |`if(1d6=?6,'six','not six')` or `if(1d6=?6,'six')` or `val('$r',1d6), if('$r'=?1,'one','$r'=?2,'two','else') |if `` equal true then return the `` expression or else the `` expression. The `` expression is optional, if it is missing and `` is `false` then the result empty. It is possible to add more than `,` pair in the function, the result will be the `` of the first true ``, coming from left. All must be non-empty and contain only on element (therefor can't contain only `val`). `val` are will only set in the first . Use the following structure to use `if` to set different value in a `val`: `if(1d6>?4, val('$a',10), val('$a',-10))`, this will set '$a' to 10 if the 1d6 roll is bigger than 4 and to -10 otherwise. |group count |`groupC(, ...)` |`groupC(20d6)` | counts all elements of with the same value and provides the results as list in the format of `x` |concatenate |`concat(, ...)` |`concat('Attack: ', 2d20, ' Damage:', 3d6+5=)` | Joining all expressions together to a single result. diff --git a/bot/build.gradle.kts b/bot/build.gradle.kts index be9feead..48d51102 100644 --- a/bot/build.gradle.kts +++ b/bot/build.gradle.kts @@ -11,7 +11,7 @@ repositories { dependencies { implementation(project(":discord-connector")) implementation("com.github.twonirwana:dice-parser:0.7.1") - implementation("io.github.twonirwana:dice-evaluator:v0.5.8") + implementation("io.github.twonirwana:dice-evaluator:v0.6.1") implementation(libs.log4j.to.slf4j) implementation(libs.reactor.core) diff --git a/bot/src/main/java/de/janno/discord/bot/Bot.java b/bot/src/main/java/de/janno/discord/bot/Bot.java index 9da1846b..623f1611 100644 --- a/bot/src/main/java/de/janno/discord/bot/Bot.java +++ b/bot/src/main/java/de/janno/discord/bot/Bot.java @@ -2,8 +2,8 @@ import com.google.common.base.Strings; -import de.janno.discord.bot.command.FetchCommand; import de.janno.discord.bot.command.ClearCommand; +import de.janno.discord.bot.command.FetchCommand; import de.janno.discord.bot.command.channelConfig.ChannelConfigCommand; import de.janno.discord.bot.command.countSuccesses.CountSuccessesCommand; import de.janno.discord.bot.command.customDice.CustomDiceCommand; @@ -54,7 +54,10 @@ public static void main(final String[] args) throws Exception { Set allGuildIdsInPersistence = persistenceManager.getAllGuildIds(); CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(), Config.getInt("diceEvaluator.maxNumberOfDice", 1000), - Config.getInt("diceEvaluator.cacheSize", 10_000)); + Config.getInt("diceEvaluator.cacheSize", 10_000), + Config.getInt("diceEvaluator.maxNumberOfElements", 10_000), + Config.getBool("diceEvaluator.keepChildrenRolls", false) + ); CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); diff --git a/bot/src/main/java/de/janno/discord/bot/command/customParameter/CustomParameterCommand.java b/bot/src/main/java/de/janno/discord/bot/command/customParameter/CustomParameterCommand.java index 00c5ca68..6474997c 100644 --- a/bot/src/main/java/de/janno/discord/bot/command/customParameter/CustomParameterCommand.java +++ b/bot/src/main/java/de/janno/discord/bot/command/customParameter/CustomParameterCommand.java @@ -514,7 +514,7 @@ private boolean hasAnySelectedValues(@Nullable State s @Override protected @NonNull Optional getStartOptionsValidationMessage(@NonNull CommandInteractionOption options, long channelId, long userId, @NonNull Locale userLocale) { String baseExpression = options.getStringSubOptionWithName(EXPRESSION_OPTION_NAME).orElse(""); - log.info("Start validating: {}", baseExpression.replace("\n", " ")); + log.trace("Start validating: {}", baseExpression.replace("\n", " ")); int variableCount = 0; Matcher variableMatcher = PARAMETER_VARIABLE_PATTERN.matcher(baseExpression); while (variableMatcher.find()) { @@ -559,7 +559,7 @@ private Optional validateAllPossibleStates(CustomParameterConfig config) .map(s -> validateStateWithCustomIdAndParameter(config, s)) .filter(Objects::nonNull) .findFirst(); - log.info("{} with parameter options {} in {}ms validated", + log.debug("{} with parameter options {} in {}ms validated", config.getBaseExpression().replace("\n", " "), config.getParameters(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); diff --git a/bot/src/main/java/de/janno/discord/bot/command/help/RpgSystemCommandPreset.java b/bot/src/main/java/de/janno/discord/bot/command/help/RpgSystemCommandPreset.java index 67b61154..9912c09a 100644 --- a/bot/src/main/java/de/janno/discord/bot/command/help/RpgSystemCommandPreset.java +++ b/bot/src/main/java/de/janno/discord/bot/command/help/RpgSystemCommandPreset.java @@ -20,6 +20,7 @@ import de.janno.discord.connector.api.message.EmbedOrMessageDefinition; import lombok.AllArgsConstructor; +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.UUID; @@ -94,6 +95,9 @@ public static Config createConfig(PresetId presetId, Locale userLocale) { case BLADES_IN_THE_DARK_IMAGE -> new CustomParameterConfig(null, I18n.getMessage("rpg.system.command.preset.BLADES_IN_THE_DARK.expression", userLocale), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.without_expression, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_RdD, DiceImageStyle.polyhedral_RdD.getDefaultColor()), userLocale); + case BLADES_IN_THE_DARK_DETAIL -> + new CustomParameterConfig(null, I18n.getMessage("rpg.system.command.preset.BLADES_IN_THE_DARK_DETAIL.expression", userLocale), + DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.without_expression, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_RdD, DiceImageStyle.polyhedral_RdD.getDefaultColor()), userLocale); //7th Edition Call of Cthulhu: custom_dice start buttons: 1d100; 2d100L1@1d100 Advantage; 2d100K1@1d100 Penalty; 1d3; 1d4; 1d6; 1d8; 1d10; 1d12; 1d20; 3d6 case CALL_OF_CTHULHU_7ED -> new CustomDiceConfig(null, ButtonHelper.parseString(I18n.getMessage("rpg.system.command.preset.CALL_OF_CTHULHU_7ED.expression", userLocale)), @@ -242,6 +246,7 @@ public enum PresetId { TRAVELLER, BLADES_IN_THE_DARK, BLADES_IN_THE_DARK_IMAGE, + BLADES_IN_THE_DARK_DETAIL, CALL_OF_CTHULHU_7ED, EXALTED_3ED, VAMPIRE_5ED, @@ -284,5 +289,9 @@ public List getSynonymes(Locale locale) { } return List.of(aliasString); } + + public static boolean isValid(String in) { + return Arrays.stream(PresetId.values()).anyMatch(s -> s.name().equals(in)); + } } } diff --git a/bot/src/main/java/de/janno/discord/bot/command/help/WelcomeCommand.java b/bot/src/main/java/de/janno/discord/bot/command/help/WelcomeCommand.java index 2ff44100..fd4a16d2 100644 --- a/bot/src/main/java/de/janno/discord/bot/command/help/WelcomeCommand.java +++ b/bot/src/main/java/de/janno/discord/bot/command/help/WelcomeCommand.java @@ -2,7 +2,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; import de.janno.discord.bot.BotMetrics; import de.janno.discord.bot.I18n; import de.janno.discord.bot.command.*; @@ -23,7 +22,10 @@ import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Mono; -import java.util.*; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.UUID; import java.util.function.Function; import java.util.function.Supplier; @@ -101,27 +103,30 @@ public Optional createMessageConfig(@NonNull UUID configUUID, long guildId, long channelId) { BotMetrics.incrementButtonMetricCounter(COMMAND_NAME, "[" + state.getButtonValue() + "]"); - if (ButtonIds.isInvalid(state.getButtonValue())) { - return Optional.empty(); - } UUID newConfigUUID = uuidSupplier.get(); - final RpgSystemCommandPreset.PresetId presetId = getPresetIdFromButton(state.getButtonValue()); - return Optional.of(rpgSystemCommandPreset.createMessage(presetId, newConfigUUID, guildId, channelId, config.getConfigLocale())); + final Optional presetId = getPresetIdFromButton(state.getButtonValue()); + return presetId.map(id -> rpgSystemCommandPreset.createMessage(id, newConfigUUID, guildId, channelId, config.getConfigLocale())); } - private RpgSystemCommandPreset.PresetId getPresetIdFromButton(String buttonValue) { - return switch (ButtonIds.valueOf(buttonValue)) { - case fate -> RpgSystemCommandPreset.PresetId.FATE; - case fate_image -> RpgSystemCommandPreset.PresetId.FATE_IMAGE; - case dnd5 -> RpgSystemCommandPreset.PresetId.DND5; - case dnd5_image -> RpgSystemCommandPreset.PresetId.DND5_IMAGE; - case nWoD -> RpgSystemCommandPreset.PresetId.NWOD; - case oWoD -> RpgSystemCommandPreset.PresetId.OWOD; - case shadowrun -> RpgSystemCommandPreset.PresetId.SHADOWRUN; - case coin -> RpgSystemCommandPreset.PresetId.COIN; - case dice_calculator -> RpgSystemCommandPreset.PresetId.DICE_CALCULATOR; + private Optional getPresetIdFromButton(String buttonValue) { + if (RpgSystemCommandPreset.PresetId.isValid(buttonValue)) { + return Optional.of(RpgSystemCommandPreset.PresetId.valueOf(buttonValue)); + } + + //legacy ids + return switch (buttonValue) { + case "fate" -> Optional.of(RpgSystemCommandPreset.PresetId.FATE); + case "fate_image" -> Optional.of(RpgSystemCommandPreset.PresetId.FATE_IMAGE); + case "dnd5" -> Optional.of(RpgSystemCommandPreset.PresetId.DND5); + case "dnd5_image" -> Optional.of(RpgSystemCommandPreset.PresetId.DND5_IMAGE); + case "nWoD" -> Optional.of(RpgSystemCommandPreset.PresetId.NWOD); + case "oWoD" -> Optional.of(RpgSystemCommandPreset.PresetId.OWOD); + case "shadowrun" -> Optional.of(RpgSystemCommandPreset.PresetId.SHADOWRUN_IMAGE); + case "coin" -> Optional.of(RpgSystemCommandPreset.PresetId.COIN); + case "dice_calculator" -> Optional.of(RpgSystemCommandPreset.PresetId.DICE_CALCULATOR); + default -> Optional.empty(); }; } @@ -133,17 +138,24 @@ protected boolean shouldKeepExistingButtonMessage(@NonNull ButtonEventAdaptor ev @Override protected void addFurtherActions(List> actions, ButtonEventAdaptor event, Config config, State state) { - RpgSystemCommandPreset.PresetId presetId = getPresetIdFromButton(state.getButtonValue()); - String commandString = RpgSystemCommandPreset.getCommandString(presetId, event.getRequester().getUserLocal()); - actions.add(Mono.defer(() -> event.createMessageWithoutReference(EmbedOrMessageDefinition.builder() - .type(EmbedOrMessageDefinition.Type.MESSAGE) - .shortedContent("`%s`".formatted(commandString)) - .build())).ofType(Void.class) - .doOnSuccess(v -> - log.info("{}: Welcome Button {}", - event.getRequester().toLogString(), - presetId.name() - ))); + Optional presetId = getPresetIdFromButton(state.getButtonValue()); + + if (presetId.isEmpty()) { + log.warn("{}: Unknown welcome button id: {}", + event.getRequester().toLogString(), + state.getButtonValue()); + } else { + String commandString = RpgSystemCommandPreset.getCommandString(presetId.get(), event.getRequester().getUserLocal()); + actions.add(Mono.defer(() -> event.createMessageWithoutReference(EmbedOrMessageDefinition.builder() + .type(EmbedOrMessageDefinition.Type.MESSAGE) + .shortedContent("`%s`".formatted(commandString)) + .build())).ofType(Void.class) + .doOnSuccess(v -> + log.info("{}: Welcome Button {}", + event.getRequester().toLogString(), + presetId.get().name() + ))); + } } @Override @@ -173,74 +185,37 @@ protected Optional> createNewConfigAndStateIfM .descriptionOrContent(I18n.getMessage("welcome.message", config.getConfigLocale())) .componentRowDefinition(ComponentRowDefinition.builder() .buttonDefinitions( - ImmutableList.of( - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.fate.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.fate.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.fate_image.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.fate_image.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.dnd5.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.dnd5.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.dnd5_image.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.dnd5_image.name().toUpperCase()), config.getConfigLocale())) - .build() - + List.of( + createButtonDefinition(RpgSystemCommandPreset.PresetId.DND5_IMAGE, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.DND5, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.FATE_IMAGE, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.COIN, configUUID, config.getConfigLocale()) ) ) .build()) .componentRowDefinition(ComponentRowDefinition.builder() .buttonDefinitions( - ImmutableList.of( - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.nWoD.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.nWoD.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.oWoD.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.oWoD.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.shadowrun.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.shadowrun.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.coin.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.coin.name().toUpperCase()), config.getConfigLocale())) - .build(), - ButtonDefinition.builder() - .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), ButtonIds.dice_calculator.name(), configUUID)) - .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(ButtonIds.dice_calculator.name().toUpperCase()), config.getConfigLocale())) - .build() + List.of( + createButtonDefinition(RpgSystemCommandPreset.PresetId.NWOD, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.OWOD, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.SHADOWRUN_IMAGE, configUUID, config.getConfigLocale()), + createButtonDefinition(RpgSystemCommandPreset.PresetId.DICE_CALCULATOR, configUUID, config.getConfigLocale()) ) ) .build()) .build(); } + private ButtonDefinition createButtonDefinition(RpgSystemCommandPreset.PresetId presetId, UUID configUUID, Locale userLocal) { + return ButtonDefinition.builder() + .id(BottomCustomIdUtils.createButtonCustomId(getCommandId(), presetId.name(), configUUID)) + .label(I18n.getMessage("rpg.system.command.preset.%s.name".formatted(presetId), userLocal)) + .build(); + } + @Override protected @NonNull Config getConfigFromStartOptions(@NonNull CommandInteractionOption options, @NonNull Locale userLocale) { return new Config(null, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, DiceImageStyle.none.getDefaultColor()), userLocale); } - private enum ButtonIds { - fate, - fate_image, - dnd5, - dnd5_image, - nWoD, - oWoD, - shadowrun, - coin, - dice_calculator; - - public static boolean isInvalid(String in) { - return Arrays.stream(ButtonIds.values()).noneMatch(s -> s.name().equals(in)); - } - } } diff --git a/bot/src/main/java/de/janno/discord/bot/dice/CachingDiceEvaluator.java b/bot/src/main/java/de/janno/discord/bot/dice/CachingDiceEvaluator.java index 56c728a1..eb97e9cf 100644 --- a/bot/src/main/java/de/janno/discord/bot/dice/CachingDiceEvaluator.java +++ b/bot/src/main/java/de/janno/discord/bot/dice/CachingDiceEvaluator.java @@ -21,8 +21,8 @@ public class CachingDiceEvaluator { private final LoadingCache diceRollerCache; private final DiceEvaluator diceEvaluator; - public CachingDiceEvaluator(NumberSupplier numberSupplier, int maxNumberOfDice, int cacheSize) { - diceEvaluator = new DiceEvaluator(numberSupplier, maxNumberOfDice); + public CachingDiceEvaluator(NumberSupplier numberSupplier, int maxNumberOfDice, int cacheSize, int maxNumberOfElements, boolean keepChildrenRolls) { + diceEvaluator = new DiceEvaluator(numberSupplier, maxNumberOfDice, maxNumberOfElements, keepChildrenRolls); diceRollerCache = CacheBuilder.newBuilder() .maximumSize(cacheSize) .recordStats() @@ -30,7 +30,7 @@ public CachingDiceEvaluator(NumberSupplier numberSupplier, int maxNumberOfDice, @Override public @NonNull RollerOrError load(@NonNull String expression) { try { - log.debug("create roller for: {}", expression.replace("\n"," ")); + log.trace("create roller for: {}", expression.replace("\n"," ")); Roller roller = diceEvaluator.buildRollSupplier(expression); roller.roll(); return new RollerOrError(expression, roller, true, null); diff --git a/bot/src/main/resources/botMessages.properties b/bot/src/main/resources/botMessages.properties index 2f279460..3828e6ae 100644 --- a/bot/src/main/resources/botMessages.properties +++ b/bot/src/main/resources/botMessages.properties @@ -276,6 +276,7 @@ rpg.system.command.preset.OSR.expression=1d20@D20;1d6@D6;2d6@2D6;1d4@D4;1d8@D8;6 rpg.system.command.preset.TRAVELLER.expression=+2d6;+(3d6k2)@Boon;+(3d6l2)@Bane;+1d6;+1;+2;+3;+4;-1;-2;-3;-4 rpg.system.command.preset.SAVAGE_WORLDS.expression=(d!!{Dice:4@D4/6@D6/8@D8/12@D12/20@D20} + {Type: 0@Regular/1d!!6@Wildcard})k1 rpg.system.command.preset.BLADES_IN_THE_DARK.expression=val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Die/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) if('$sixes'>?1,'Critical Success - You do it with increased effect.', '$sixes'=?1,'Success - You do it.','$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or have reduced effect.','Failure - You suffer severe harm, a serious complication occurs, or you lose this opportunity for action.') +rpg.system.command.preset.BLADES_IN_THE_DARK_DETAIL.expression=val('$rollType',{Roll Type:1@Generic/2@Controlled Action/3@Risky Action/4@Desperate Action/5@Engagement/6@Resistance/7@Asset Quality/8@Progress Clock/9@Heat Reduction/10@Incarceration}) val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Dice/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) val('$stressbase',6) if('$rollType' =?1 && '$sixes'>?1,'Critical Success', '$rollType' =?1 && '$sixes'=?1, 'Success' , '$rollType' =?1 && '$partials' >? 0,'Partial Success', '$rollType' =?1 && '$partials' =?0, 'Failure', '$rollType' =?2 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?2 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?2 && '$partials' >? 0,'Partial Success - You hesitate. Do it with a minor consequence (lesser harm, minor complication, reduced effect or end up in a risky position) OR try another approach.', '$rollType' =?2 && '$partials' =?0, 'Failure - You falter. Press on with a risky opportunity OR withdraw and try another approach.', '$rollType' =?3 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?3 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?3 && '$partials' >? 0,'Partial Success - You do it but suffer harm, a complication, reduced effect or end up in a desperate position.', '$rollType' =?3 && '$partials' =?0, 'Failure - Things go badly. You suffer harm, a complication, end up in a desperate position or lose this opportunity for action.', '$rollType' =?4 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?4 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?4 && '$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or reduced effect.', '$rollType' =?4 && '$partials' =?0, 'Failure - Things could not go worse. You suffer severe harm, a serious complication, or lose this opportunity for action.', '$rollType' =?5 && '$sixes'>?1,'Critical Success - This first obstacle is overcome and you move to a controlled position for the next.', '$rollType' =?5 && '$sixes'=?1, 'Controlled - You are in a controlled position to act.' , '$rollType' =?5 && '$partials' >? 0,'Risky - You are in a risky position to act.', '$rollType' =?5 && '$partials' =?0, 'Desperate - You are in a desperate position to act.', '$rollType' =?6 && '$sixes'>?1,'Spectacular success - recover 1 stress.', '$rollType' =?6 && '$sixes'=?1, 'Well within your ability - no stress.' , '$rollType' =?6, concat ('You succeed with an effort - take ',('$stressbase' - ('$diceRoll'k1)=), ' stress.'), '$rollType' =?7 && '$sixes'>?1,'Exceptional Quality - Crew Tier +2', '$rollType' =?7 && '$sixes'=?1, 'Fine Quality - Crew Tier +1' , '$rollType' =?7 && '$partials' >? 0,'Standard Quality - Equal to Crew Tier', '$rollType' =?7 && '$partials' =?0, 'Inferior Quality - Crew Tier -1', '$rollType' =?8 && '$sixes'>?1,'Mark off 5 progress segments.', '$rollType' =?8 && '$sixes'=?1, 'Mark off 3 progress segments.' , '$rollType' =?8 && '$partials' >? 0,'Mark off two progress segments.', '$rollType' =?8 && '$partials' =?0, 'Mark off 1 progress segment.', '$rollType' =?9 && '$sixes'>?1,'Reduce 5 Heat.', '$rollType' =?9 && '$sixes'=?1, 'Reduce 3 Heat.' , '$rollType' =?9 && '$partials' >? 0,'Reduce 2 Heat.', '$rollType' =?9 && '$partials' =?0, 'Reduce 1 Heat.', '$rollType' =?10 && '$sixes'>?1,'You make a name for yourself (+3 rep, +1 prison claim, +1 faction).', '$rollType' =?10 && '$sixes'=?1, 'You do your time well (+1 prison claim, +1 faction).' , '$rollType' =?10 && '$partials' >? 0,'You keep your head down and do your time without incident.', '$rollType' =?10 && '$partials' =?0, 'A horrific experience - you suffer a level of Trauma.', '') rpg.system.command.preset.CALL_OF_CTHULHU_7ED.expression=1d100;2d100L1@1d100 Advantage; 2d100K1@1d100 Penalty; 1d3; 1d4; 1d6; 1d8; 1d10; 1d12; 1d20; 3d6 rpg.system.command.preset.EXALTED_3ED.expression=val('$1', cancel(double({number of dice}d10,10),1,[7/8/9/10])), ifE(('$1'>=7)c,0,ifG(('$1'<=1)c,0,'Botch')) rpg.system.command.preset.VAMPIRE_5ED.expression=val('$r',{regular dice:1<=>16}d10 col 'blue') val('$h',{hunger dice:0<=>5}d10 col 'purple_dark') val('$s',('$r'+'$h')>=6c) val('$rt','$r'==10c) val('$ht','$h'==10c) val('$ho','$h'==1c) val('$2s',((('$rt'+'$ht'=))/2)*2) val('$ts',('$s'+'$2s'=)) concat('successes: ', '$ts', ifE('$ts',0,ifG('$ho',1,' bestial failure' , ''),''), ifE('$rt' mod 2, 1, ifE('$ht' mod 2, 1, ' messy critical', ''), '')) @@ -320,6 +321,7 @@ rpg.system.command.preset.TRAVELLER.name=Traveller rpg.system.command.preset.SAVAGE_WORLDS.name=Savage Worlds rpg.system.command.preset.BLADES_IN_THE_DARK.name=Blades in the Dark without Dice Images rpg.system.command.preset.BLADES_IN_THE_DARK_IMAGE.name=Blades in the Dark +rpg.system.command.preset.BLADES_IN_THE_DARK_DETAIL.name=Blades in the Dark - Detail rpg.system.command.preset.CALL_OF_CTHULHU_7ED.name=Call of Cthulhu 7th Edition rpg.system.command.preset.EXALTED_3ED.name=Exalted 3ed rpg.system.command.preset.VAMPIRE_5ED.name=Vampire 5ed @@ -364,6 +366,7 @@ rpg.system.command.preset.TRAVELLER.aliases= rpg.system.command.preset.SAVAGE_WORLDS.aliases= rpg.system.command.preset.BLADES_IN_THE_DARK.aliases= rpg.system.command.preset.BLADES_IN_THE_DARK_IMAGE.aliases= +rpg.system.command.preset.BLADES_IN_THE_DARK_DETAIL.aliases= rpg.system.command.preset.CALL_OF_CTHULHU_7ED.aliases= rpg.system.command.preset.EXALTED_3ED.aliases= rpg.system.command.preset.VAMPIRE_5ED.aliases= diff --git a/bot/src/test/java/de/janno/discord/bot/command/FetchCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/FetchCommandMockTest.java index fe2ce093..15862851 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/FetchCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/FetchCommandMockTest.java @@ -44,7 +44,7 @@ class FetchCommandMockTest { @BeforeEach void setup() { persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true); customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); diff --git a/bot/src/test/java/de/janno/discord/bot/command/channelConfig/ChannelConfigMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/channelConfig/ChannelConfigMockTest.java index 021c7498..afe8b2c1 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/channelConfig/ChannelConfigMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/channelConfig/ChannelConfigMockTest.java @@ -35,7 +35,7 @@ void setup() throws IOException { @Test void saveConfigDelete_default() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() diff --git a/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandMockTest.java index 889c57e1..03aa05fc 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandMockTest.java @@ -62,7 +62,7 @@ void cleanUp() throws IOException { @Test void legacy_id() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ButtonEventAdaptorMock buttonEvent = new ButtonEventAdaptorMock("custom_dice\u00001d6\u0000"); underTest.handleComponentInteractEvent(buttonEvent).block(); @@ -75,7 +75,7 @@ void legacy_id() { void without_configUUID_existingLegacyData() { String url = "jdbc:h2:mem:" + UUID.randomUUID(); persistenceManager = new PersistenceManagerImpl(url, null, null); - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); JdbcConnectionPool connectionPool = JdbcConnectionPool.create(url, null, null); UUID configUUID = UUID.fromString("00000000-0000-0000-0000-000000000001"); @@ -118,7 +118,7 @@ void without_configUUID_existingLegacyData() { @Test void without_configUUID_missingData() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ButtonEventAdaptorMock buttonEvent = new ButtonEventAdaptorMock("custom_dice", "1_button", new AtomicLong(0)); UUID configUUID = UUID.fromString("00000000-0000-0000-0000-000000000001"); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -133,7 +133,7 @@ void without_configUUID_missingData() { @Test void roll_diceEvaluator_full() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -150,7 +150,7 @@ void roll_diceEvaluator_full() { @Test void roll_diceEvaluator_full_german() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.GERMAN); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -167,7 +167,7 @@ void roll_diceEvaluator_full_german() { @Test void roll_diceEvaluator_full_ptBR() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.of("pt", "BR")); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -184,7 +184,7 @@ void roll_diceEvaluator_full_ptBR() { @Test void roll_diceEvaluator_full_with_images() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -201,7 +201,7 @@ void roll_diceEvaluator_full_with_images() { @Test void roll_diceEvaluator_onlyResult_with_images() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.only_result, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -218,7 +218,7 @@ void roll_diceEvaluator_onlyResult_with_images() { @Test void roll_diceEvaluator_onlyResult_multiResult() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6,2d6,3d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.only_result, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -239,7 +239,7 @@ void roll_diceEvaluator_onlyResult_multiResult() { @Test void roll_diceEvaluator_onlyResult_without_images() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.only_result, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); ButtonEventAdaptorMock buttonEvent = factory.getButtonClickOnLastButtonMessage("1_button"); @@ -256,7 +256,7 @@ void roll_diceEvaluator_onlyResult_without_images() { @Test void roll_diceEvaluator_full_with_images_d100() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d100", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold"), Locale.ENGLISH); @@ -275,7 +275,7 @@ void roll_diceEvaluator_full_with_images_d100() { @Test void roll_diceParser_full() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1", false, false)), DiceParserSystem.DICEROLL_PARSER, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); @@ -293,7 +293,7 @@ void roll_diceParser_full() { @Test void roll_diceEvaluator_compact() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.compact, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); @@ -311,7 +311,7 @@ void roll_diceEvaluator_compact() { @Test void roll_diceEvaluator_minimal() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.minimal, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); @@ -329,7 +329,7 @@ void roll_diceEvaluator_minimal() { @Test void roll_pinned() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, true); @@ -346,7 +346,7 @@ void roll_pinned() { @Test void roll_pinnedTwice() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, true); @@ -372,7 +372,7 @@ void roll_pinnedTwice() { @Test void slash_start() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -390,7 +390,7 @@ void slash_start() { @Test void slash_start_multiLine() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -424,7 +424,7 @@ void slash_start_multiLine() { @Test void slash_start_warn() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -442,7 +442,7 @@ void slash_start_warn() { @Test void slash_targetChannelTheSame_error() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -462,7 +462,7 @@ void slash_targetChannelTheSame_error() { @Test void roll_answerChannel() { - CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomDiceConfig config = new CustomDiceConfig(2L, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); ButtonEventAdaptorMockFactory factory = new ButtonEventAdaptorMockFactory<>("custom_dice", underTest, config, persistenceManager, false); @@ -478,7 +478,7 @@ void roll_answerChannel() { @Test void roll_answerChannelTwice() { - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100, 10_000, true); CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), cachingDiceEvaluator); CustomDiceConfig config = new CustomDiceConfig(2L, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "1d6", false, false)), DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -502,7 +502,7 @@ void roll_answerChannelTwice() { @Test void channelAlias() { - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100, 10_000, true); CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), cachingDiceEvaluator); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); @@ -532,7 +532,7 @@ void channelAlias() { @Test void userChannelAlias() { - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 100, 10_000, true); CustomDiceCommand underTest = new CustomDiceCommand(persistenceManager, new DiceParser(), cachingDiceEvaluator); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); diff --git a/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandTest.java index ee6def5a..5bdc3277 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/customDice/CustomDiceCommandTest.java @@ -81,7 +81,7 @@ void getConfigOptionStringList(String buttons, CustomDiceConfig expected) { @BeforeEach void setup() { diceMock = mock(Dice.class); - underTest = new CustomDiceCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> 3, 10, 0)); + underTest = new CustomDiceCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> 3, 10, 0, 10_000, true)); } diff --git a/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandMockTest.java index d0db8647..f131196e 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandMockTest.java @@ -34,7 +34,7 @@ void setup() { @Test void roll_full() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -57,7 +57,7 @@ void roll_full() { @Test void roll_direct() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{n}d{s:4/6/10/20@!20}+{modi:1/2/3}=", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -81,7 +81,7 @@ void roll_direct() { @Test void roll_ignore_direct() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{n}d{s:4/6/10/20@!20}+{modi:1/2/3}=", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -109,7 +109,7 @@ void roll_ignore_direct() { @Test void slash_start_multiLine() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -143,7 +143,7 @@ void slash_start_multiLine() { @Test void slash_start_directRoll() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator((min, max) -> max, 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator((min, max) -> max, 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -172,7 +172,7 @@ void slash_start_directRoll() { @Test void roll_fullGerman() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.GERMAN); @@ -196,7 +196,7 @@ void roll_fullGerman() { @Test void roll_full_ptBR() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.of("pt", "BR")); @@ -220,7 +220,7 @@ void roll_full_ptBR() { @Test void roll_textLegacy() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{dice:d4/d['-','0','1']@Fate}+{bonus:1<=>10}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -242,7 +242,7 @@ void roll_textLegacy() { @Test void roll_textLegacy2() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{bonus:-5<=>5}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -261,7 +261,7 @@ void roll_textLegacy2() { @Test void roll_text() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{dice:d4/d['-','0','1']@Fate}+{bonus:1<=>10}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -284,7 +284,7 @@ void roll_text() { @Test void roll_full_withLabel() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}@Roll", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -307,7 +307,7 @@ void roll_full_withLabel() { @Test void roll_withoutExpression() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.without_expression, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -330,7 +330,7 @@ void roll_withoutExpression() { @Test void roll_withoutExpression_withLabel() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}@Roll", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.without_expression, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -353,7 +353,7 @@ void roll_withoutExpression_withLabel() { @Test void roll_compact() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.compact, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -376,7 +376,7 @@ void roll_compact() { @Test void roll_minimal() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.minimal, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -399,7 +399,7 @@ void roll_minimal() { @Test void lockedToUser_block() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.minimal, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -426,7 +426,7 @@ void lockedToUser_block() { @Test void clear() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -445,7 +445,7 @@ void clear() { @Test void roll_pinned() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -467,7 +467,7 @@ void roll_pinned() { @Test void roll_answerChannel() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(2L, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -489,7 +489,7 @@ void roll_answerChannel() { @Test void roll_pinnedTwice() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(null, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); @@ -525,7 +525,7 @@ void roll_pinnedTwice() { @Test void roll_answerChannelTwice() { - CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + CustomParameterCommand underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); CustomParameterConfig config = new CustomParameterConfig(2L, "{numberOfDice:1<=>10}d{sides:1/4/6/8/10/12/20/100}", DiceParserSystem.DICE_EVALUATOR, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH); diff --git a/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandTest.java index 1d03b288..357e5c8e 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/customParameter/CustomParameterCommandTest.java @@ -111,7 +111,7 @@ public static Stream generateExpression2Parameters() { @BeforeEach void setup() { - underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); } @@ -161,7 +161,7 @@ void createParameterListFromBaseExpression(String parameterExpression, List maxIncl, 1000, 0)); + underTest = new CustomParameterCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator((minExcl, maxIncl) -> maxIncl, 1000, 0, 10_000, true)); Optional res = underTest.getStartOptionsValidationMessage(CommandInteractionOption.builder() .name("start") @@ -248,7 +248,7 @@ public void filterToCornerCases() { @Test void checkPersistence() { PersistenceManager persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - underTest = new CustomParameterCommand(persistenceManager, mock(Dice.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 0, 10, 0)); + underTest = new CustomParameterCommand(persistenceManager, mock(Dice.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 0, 10, 10_000, 10000, true)); UUID configUUID = UUID.randomUUID(); long channelId = System.currentTimeMillis(); diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.java index e0c2e790..c68fcbb7 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.java @@ -50,7 +50,7 @@ void setup() throws IOException { FileUtils.cleanDirectory(cacheDirectory); } persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - underTest = new AliasRollCommand(persistenceManager, new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0)); + underTest = new AliasRollCommand(persistenceManager, new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0, 10_000, true)); } @ParameterizedTest(name = "{index} locale={0}") diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.snap b/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.snap index 78a4247f..8a3a5d39 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.snap +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/AliasRollCommandTest.snap @@ -49,7 +49,7 @@ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.getCommandDefinitio de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[de]=[ { - "descriptionOrContent": "Schreib `/a`und ein Alias oder Würfelausdruck. Verfügbare Alias werden im Autocomplete gezeigt, es ist aber auch möglich normale Ausrücke zu würfeln. Aliase können mit `/channel_config alias` angelegt oder gelöscht werden. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Schreib `/a`und ein Alias oder Würfelausdruck. Verfügbare Alias werden im Autocomplete gezeigt, es ist aber auch möglich normale Ausrücke zu würfeln. Aliase können mit `/channel_config alias` angelegt oder gelöscht werden. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Beispiel", @@ -80,7 +80,7 @@ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[de]=[ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[en]=[ { - "descriptionOrContent": "Type `/a` and an alias or dice expression. Available alias will be presented as autocomplete, but it is possible to roll all expression. `/channel_config alias` can be used to add and delete alias. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Type `/a` and an alias or dice expression. Available alias will be presented as autocomplete, but it is possible to roll all expression. `/channel_config alias` can be used to add and delete alias. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Example", @@ -111,7 +111,7 @@ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[en]=[ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[fr]=[ { - "descriptionOrContent": "Tapez `/a` et un alias ou une expression de dé. Les alias disponibles seront présentés en autocomplétion, mais il est possible de lancer toutes les expressions. `/channel_config alias` peut être utilisé pour ajouter et supprimer des alias. Le type de sortie, les images des dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Tapez `/a` et un alias ou une expression de dé. Les alias disponibles seront présentés en autocomplétion, mais il est possible de lancer toutes les expressions. `/channel_config alias` peut être utilisé pour ajouter et supprimer des alias. Le type de sortie, les images des dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemple", @@ -142,7 +142,7 @@ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[fr]=[ de.janno.discord.bot.command.directRoll.AliasRollCommandTest.testHelp[pt_BR]=[ { - "descriptionOrContent": "Digite `/a` e um alias ou expressão de dados. O alias disponível será apresentado como preenchimento automático, mas é possível rolar todas as expressões. O `/channel_config alias` pode ser usado para adicionar e excluir alias. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Digite `/a` e um alias ou expressão de dados. O alias disponível será apresentado como preenchimento automático, mas é possível rolar todas as expressões. O `/channel_config alias` pode ser usado para adicionar e excluir alias. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemplo", diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandMockTest.java index b69b7d49..0f666731 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandMockTest.java @@ -34,7 +34,7 @@ void setup() throws IOException { @Test void roll_default() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -50,7 +50,7 @@ void roll_default() { @Test void roll_multiLine() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -78,7 +78,7 @@ void roll_multiLine() { @Test void roll_warn() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -96,7 +96,7 @@ void roll_warn() { @Test void help() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -113,7 +113,7 @@ void help() { @Test void invalidExpression() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -129,7 +129,7 @@ void invalidExpression() { @Test void roll_default_withLabel() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -146,7 +146,7 @@ void roll_default_withLabel() { @Test void roll_config_full_imageNone() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -181,7 +181,7 @@ void roll_config_full_imageNone() { @Test void roll_config_withoutExpression() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -216,7 +216,7 @@ void roll_config_withoutExpression() { @Test void roll_config_withoutExpression_withLabel() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -251,7 +251,7 @@ void roll_config_withoutExpression_withLabel() { @Test void roll_config_compact() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -287,7 +287,7 @@ void roll_config_compact() { @Test void roll_config_minimal() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -323,7 +323,7 @@ void roll_config_minimal() { @Test void channelAlias() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -351,7 +351,7 @@ void channelAlias() { @Test void userChannelAlias() { - DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + DirectRollCommand directRollCommand = new DirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock slashEvent1 = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.java index d7a3c786..38ea1f99 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.java @@ -46,7 +46,7 @@ static Stream generateAllLocaleData() { @BeforeEach void setup() { - underTest = new DirectRollCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0)); + underTest = new DirectRollCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0, 10_000, true)); } @ParameterizedTest(name = "{index} locale={0}") diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.snap b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.snap index b916ab04..125ea21e 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.snap +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/DirectRollCommandTest.snap @@ -54,7 +54,7 @@ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.getId=[ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[de]=[ { - "descriptionOrContent": "Schreib `/r` und ein Würfelausdruck. Es ist möglich einen Wurf mit `@` einen Namen zu geben. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Schreib `/r` und ein Würfelausdruck. Es ist möglich einen Wurf mit `@` einen Namen zu geben. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Beispiel", @@ -80,7 +80,7 @@ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[de]=[ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[en]=[ { - "descriptionOrContent": "Type `/r` and a dice expression. It is possible to give the roll a label by adding it with a `@`. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Type `/r` and a dice expression. It is possible to give the roll a label by adding it with a `@`. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Example", @@ -106,7 +106,7 @@ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[en]=[ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[fr]=[ { - "descriptionOrContent": "Tapez `/r` et une expression de dés. Il est possible de donner une étiquette au rouleau en l'ajoutant avec un `@`. Le type de sortie, les images de dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Tapez `/r` et une expression de dés. Il est possible de donner une étiquette au rouleau en l'ajoutant avec un `@`. Le type de sortie, les images de dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemple", @@ -132,7 +132,7 @@ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[fr]=[ de.janno.discord.bot.command.directRoll.DirectRollCommandTest.testHelp[pt_BR]=[ { - "descriptionOrContent": "Digite `/r` e uma expressão de dados. É possível dar um rótulo ao rolo adicionando-o com um `@`. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Digite `/r` e uma expressão de dados. É possível dar um rótulo ao rolo adicionando-o com um `@`. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemplo", diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandMockTest.java index b7ff9b6c..13c7b7f4 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandMockTest.java @@ -36,7 +36,7 @@ void setup() throws IOException { @Test void roll_default() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock hiddenRollCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -65,7 +65,7 @@ void roll_default() { @Test void roll_NoWarn() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock hiddenRollCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -96,7 +96,7 @@ void roll_NoWarn() { @Test void help() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock hiddenRollCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -114,7 +114,7 @@ void help() { @Test void invalidExpression() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock hiddenRollCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -130,7 +130,7 @@ void invalidExpression() { @Test void roll_default_withLabel() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock hiddenRollCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("expression") @@ -160,7 +160,7 @@ void roll_default_withLabel() { @Test void roll_config_full_imageNone() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -210,7 +210,7 @@ void roll_config_full_imageNone() { @Test void roll_config_withoutExpression() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -259,7 +259,7 @@ void roll_config_withoutExpression() { @Test void roll_config_withoutExpression_withLabel() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -307,7 +307,7 @@ void roll_config_withoutExpression_withLabel() { @Test void roll_config_compact() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -356,7 +356,7 @@ void roll_config_compact() { @Test void roll_config_minimal() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -405,7 +405,7 @@ void roll_config_minimal() { @Test void channelAlias() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() @@ -447,7 +447,7 @@ void channelAlias() { @Test void userChannelAlias() { - HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + HiddenDirectRollCommand underTest = new HiddenDirectRollCommand(persistenceManager, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); SlashEventAdaptorMock configCommandEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.java index 1526b464..48b55e45 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.java @@ -30,7 +30,7 @@ static Stream generateAllLocaleData() { @BeforeEach void setup() { - underTest = new HiddenDirectRollCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0)); + underTest = new HiddenDirectRollCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0, 10_000, true)); } @ParameterizedTest(name = "{index} locale={0}") diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.snap b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.snap index 51c3ad18..777f1c74 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.snap +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/HiddenRollCommandTest.snap @@ -54,7 +54,7 @@ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.getId=[ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[de]=[ { - "descriptionOrContent": "Schreib `/h` und ein Würfelausdruck. Das Ergebniss wird erstmal den aktuellen Benutzer gezeigt und der kann es später für alle sichtbar machen. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Schreib `/h` und ein Würfelausdruck. Das Ergebniss wird erstmal den aktuellen Benutzer gezeigt und der kann es später für alle sichtbar machen. Antwort Format und Würfelbilder können mit `/channel_config save_direct_roll_config` konfiguriert werden.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Beispiel", @@ -80,7 +80,7 @@ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[de]=[ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[en]=[ { - "descriptionOrContent": "Type `/h` and a dice expression. The result will only be shown the roller and they can make it visible to all later. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Type `/h` and a dice expression. The result will only be shown the roller and they can make it visible to all later. The output type, dice images etc. can be configuration with `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Example", @@ -106,7 +106,7 @@ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[en]=[ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[fr]=[ { - "descriptionOrContent": "Tapez `/h` et une expression de dés. Le résultat ne sera montré qu'au joueur et il pourra le rendre visible à tous plus tard. Le type de sortie, les images des dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Tapez `/h` et une expression de dés. Le résultat ne sera montré qu'au joueur et il pourra le rendre visible à tous plus tard. Le type de sortie, les images des dés, etc. peuvent être configurés avec `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemple", @@ -132,7 +132,7 @@ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[fr]=[ de.janno.discord.bot.command.directRoll.HiddenRollCommandTest.testHelp[pt_BR]=[ { - "descriptionOrContent": "Digite `/h` e uma expressão de dados. O resultado será exibido apenas para o rolador e ele poderá torná-lo visível para todos posteriormente. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Digite `/h` e uma expressão de dados. O resultado será exibido apenas para o rolador e ele poderá torná-lo visível para todos posteriormente. O tipo de saída, as imagens de dados etc. podem ser configurados com `/channel_config save_direct_roll_config`\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemplo", diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.java index 7ba513dd..0e1f2070 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.java @@ -45,7 +45,7 @@ static Stream generateAllLocaleData() { @BeforeEach void setup() { - underTest = new ValidationCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0)); + underTest = new ValidationCommand(mock(PersistenceManager.class), new CachingDiceEvaluator((minExcl, maxIncl) -> 1, 1000, 0, 10_000, true)); } @ParameterizedTest(name = "{index} locale={0}") diff --git a/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.snap b/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.snap index 8893f708..8eaefc7d 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.snap +++ b/bot/src/test/java/de/janno/discord/bot/command/directRoll/ValidationCommandTest.snap @@ -54,7 +54,7 @@ de.janno.discord.bot.command.directRoll.ValidationCommandTest.getId=[ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[de]=[ { - "descriptionOrContent": "Schreib `/validation` und ein Würfelausdruck, der Autocomplete zeigt dann ob der Ausdruck korrekt ist oder nicht.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Schreib `/validation` und ein Würfelausdruck, der Autocomplete zeigt dann ob der Ausdruck korrekt ist oder nicht.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Beispiel", @@ -80,7 +80,7 @@ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[de]=[ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[en]=[ { - "descriptionOrContent": "Type `/validation` and a dice expression, the autocomplete will show if there are errors in the expression.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Type `/validation` and a dice expression, the autocomplete will show if there are errors in the expression.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Example", @@ -106,7 +106,7 @@ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[en]=[ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[fr]=[ { - "descriptionOrContent": "Tapez `/validation` et une expression de dé, l'autocomplétion montrera s'il y a des erreurs dans l'expression.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Tapez `/validation` et une expression de dé, l'autocomplétion montrera s'il y a des erreurs dans l'expression.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemple", @@ -132,7 +132,7 @@ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[fr]=[ de.janno.discord.bot.command.directRoll.ValidationCommandTest.testHelp[pt_BR]=[ { - "descriptionOrContent": "Digite `/validation` e uma expressão de dados; o preenchimento automático mostrará se há erros na expressão.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", + "descriptionOrContent": "Digite `/validation` e uma expressão de dados; o preenchimento automático mostrará se há erros na expressão.\n```\n| Name | Notation | Example |\r\n|----------------------|------------|--------------------|\r\n| Regular Dice | d | d6, 3d6 |\r\n| Custom Dice | d[x,y,...] | 3d[Head,Tail] |\r\n| Exploding Dice | d! | 4d!6 |\r\n| Exploding Add Dice | d!! | 4d!!6 |\r\n| Keep Highest | k | 3d6k2 |\r\n| Keep Lowest | l | 3d6l2 |\r\n| Sum | = | 3d6= |\r\n| Add to List | + | 3d6+2d12 |\r\n| Concatenate | _ | 3d6 _ 'dmg' |\r\n| Negative add to List | - | 3d6-2d12 or -2d6 |\r\n| Decimal Divide | // | 2/6 |\r\n| Divide | / | 12/6 |\r\n| Multiply | * | 12*d6 |\r\n| Modulo | mod | d6 mod 2 |\r\n| Equal Filter | == | 3d6==3 |\r\n| Greater Then Filter | > | 3d6>3 |\r\n| Lesser Then Filter | < | 3d6<3 |\r\n| Greater Equal Filter | >= | 3d6>=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Lesser Equal Filter | <= | 3d6<=3 |\r\n| Count | c | 3d6<3c |\r\n| Multiple Rolls | , | 1d6,2d10 |\r\n| Repeat | x | 3x2d6 |\r\n| Repeat List | r | 3r2d6 |\r\n| Reroll | rr | 3d10 rr 1 |\r\n| Equal | =? | d6=?6 |\r\n| Greater | >? | d6>?5 |\r\n| Greater Equal | >=? | d6>=?5 |\r\n| Lower | ?1 && d6<5 |\r\n| Or | || | d6>?1 || d6<5 |\r\n| Negate | ! | !d6>?1 |\r\n| Color | col | d6 col 'red' |\r\n| Tag | tag | d6 tag 'marked' |\r\n| Brackets | () | (2d4=)d6 |\r\n| Text | '' | 'Damage ' + d6 |\r\n| Sort asc | asc() | asc(10d10) |\r\n| Sort desc | desc() | desc(10d10) |\r\n| Min | min() | min(3d4, 8) |\r\n| Max | max() | max(3d4, 8) |\r\n| Chancel | chancel() | chancel(8d10,10,1) |\r\n| Replace | replace() | replace(6d10,1,2) |\r\n| Explode | exp() | exp(d6,1,2) |\r\n| If | if() | if(d6=?6,'Y','N') |\r\n| Group Count | groupC() | groupC(20d6) |\r\n| Concatenate | concat() | concat('Att:',d20) |\r\n| Value | val() | val('$1',10d10) |\r\n\n```", "fields": [ { "name": "Exemplo", diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.java index 5a8bb713..684cc99b 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.java @@ -72,7 +72,7 @@ private static List getOptionsFromString(String comman @MethodSource("generateRpgSystemLocaleData") void handleSlashCommandEvent(RpgSystemCommandPreset.PresetId presetId, Locale userLocale) { PersistenceManager persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true); CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); @@ -94,7 +94,7 @@ void handleSlashCommandEvent(RpgSystemCommandPreset.PresetId presetId, Locale us @MethodSource("generateRpgSystemLocaleData") void config2CommandString_slashCommand_firstButton(RpgSystemCommandPreset.PresetId presetId, Locale userLocale) { PersistenceManager persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator((minExcl, maxIncl) -> minExcl + 1, 1000, 0); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator((minExcl, maxIncl) -> minExcl + 1, 1000, 0, 10_000, true); CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.snap b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.snap index 2098a7b8..fac665d6 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.snap +++ b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.snap @@ -54,6 +54,34 @@ de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString ] +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[firstButtonEvent:BLADES_IN_THE_DARK_DETAIL_de]=[ + [ + "editMessage: message:invokingUser: Bitte wähle den Wert für **Number of Dice**, buttonValues=id1,id2,id3,id4,id5,id6,id7,id8,clear" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[firstButtonEvent:BLADES_IN_THE_DARK_DETAIL_en]=[ + [ + "editMessage: message:invokingUser: Please select value for **Number of Dice**, buttonValues=id1,id2,id3,id4,id5,id6,id7,id8,clear" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[firstButtonEvent:BLADES_IN_THE_DARK_DETAIL_fr]=[ + [ + "editMessage: message:invokingUser: Veuillez sélectionner la valeur de **Number of Dice**, buttonValues=id1,id2,id3,id4,id5,id6,id7,id8,clear" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[firstButtonEvent:BLADES_IN_THE_DARK_DETAIL_pt_BR]=[ + [ + "editMessage: message:invokingUser: Por favor selecione um valor para **Number of Dice**, buttonValues=id1,id2,id3,id4,id5,id6,id7,id8,clear" + ] +] + + de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[firstButtonEvent:BLADES_IN_THE_DARK_IMAGE_de]=[ [ "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Bitte wähle den Wert für **Number of Dice**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=No Dice, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1 Die, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2 Dice, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3 Dice, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4 Dice, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=5 Dice, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=6 Dice, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7 Dice, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", @@ -1590,6 +1618,38 @@ de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString ] +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[slashCommand:BLADES_IN_THE_DARK_DETAIL_de]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Bitte wähle den Wert für **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[slashCommand:BLADES_IN_THE_DARK_DETAIL_en]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Please select value for **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[slashCommand:BLADES_IN_THE_DARK_DETAIL_fr]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Veuillez sélectionner la valeur de **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[slashCommand:BLADES_IN_THE_DARK_DETAIL_pt_BR]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Por favor selecione um valor para **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + de.janno.discord.bot.command.help.QuickstartCommandMockTest.config2CommandString_slashCommand_firstButton[slashCommand:BLADES_IN_THE_DARK_IMAGE_de]=[ [ "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Bitte wähle den Wert für **Number of Dice**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=No Dice, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1 Die, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2 Dice, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3 Dice, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4 Dice, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=5 Dice, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=6 Dice, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7 Dice, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", @@ -2966,6 +3026,38 @@ de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEv ] +de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEvent[BLADES_IN_THE_DARK_DETAIL_de]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Bitte wähle den Wert für **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: `/custom_parameter start expression: val('$rollType',{Roll Type:1@Generic/2@Controlled Action/3@Risky Action/4@Desperate Action/5@Engagement/6@Resistance/7@Asset Quality/8@Progress Clock/9@Heat Reduction/10@Incarceration}) val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Dice/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) val('$stressbase',6) if('$rollType' =?1 && '$sixes'>?1,'Critical Success', '$rollType' =?1 && '$sixes'=?1, 'Success' , '$rollType' =?1 && '$partials' >? 0,'Partial Success', '$rollType' =?1 && '$partials' =?0, 'Failure', '$rollType' =?2 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?2 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?2 && '$partials' >? 0,'Partial Success - You hesitate. Do it with a minor consequence (lesser harm, minor complication, reduced effect or end up in a risky position) OR try another approach.', '$rollType' =?2 && '$partials' =?0, 'Failure - You falter. Press on with a risky opportunity OR withdraw and try another approach.', '$rollType' =?3 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?3 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?3 && '$partials' >? 0,'Partial Success - You do it but suffer harm, a complication, reduced effect or end up in a desperate position.', '$rollType' =?3 && '$partials' =?0, 'Failure - Things go badly. You suffer harm, a complication, end up in a desperate position or lose this opportunity for action.', '$rollType' =?4 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?4 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?4 && '$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or reduced effect.', '$rollType' =?4 && '$partials' =?0, 'Failure - Things could not go worse. You suffer severe harm, a serious complication, or lose this opportunity for action.', '$rollType' =?5 && '$sixes'>?1,'Critical Success - This first obstacle is overcome and you move to a controlled position for the next.', '$rollType' =?5 && '$sixes'=?1, 'Controlled - You are in a controlled position to act.' , '$rollType' =?5 && '$partials' >? 0,'Risky - You are in a risky position to act.', '$rollType' =?5 && '$partials' =?0, 'Desperate - You are in a desperate position to act.', '$rollType' =?6 && '$sixes'>?1,'Spectacular success - recover 1 stress.', '$rollType' =?6 && '$sixes'=?1, 'Well within your ability - no stress.' , '$rollType' =?6, concat ('You succeed with an effort - take ',('$stressbase' - ('$diceRoll'k1)=), ' stress.'), '$rollType' =?7 && '$sixes'>?1,'Exceptional Quality - Crew Tier +2', '$rollType' =?7 && '$sixes'=?1, 'Fine Quality - Crew Tier +1' , '$rollType' =?7 && '$partials' >? 0,'Standard Quality - Equal to Crew Tier', '$rollType' =?7 && '$partials' =?0, 'Inferior Quality - Crew Tier -1', '$rollType' =?8 && '$sixes'>?1,'Mark off 5 progress segments.', '$rollType' =?8 && '$sixes'=?1, 'Mark off 3 progress segments.' , '$rollType' =?8 && '$partials' >? 0,'Mark off two progress segments.', '$rollType' =?8 && '$partials' =?0, 'Mark off 1 progress segment.', '$rollType' =?9 && '$sixes'>?1,'Reduce 5 Heat.', '$rollType' =?9 && '$sixes'=?1, 'Reduce 3 Heat.' , '$rollType' =?9 && '$partials' >? 0,'Reduce 2 Heat.', '$rollType' =?9 && '$partials' =?0, 'Reduce 1 Heat.', '$rollType' =?10 && '$sixes'>?1,'You make a name for yourself (+3 rep, +1 prison claim, +1 faction).', '$rollType' =?10 && '$sixes'=?1, 'You do your time well (+1 prison claim, +1 faction).' , '$rollType' =?10 && '$partials' >? 0,'You keep your head down and do your time without incident.', '$rollType' =?10 && '$partials' =?0, 'A horrific experience - you suffer a level of Trauma.', '') answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEvent[BLADES_IN_THE_DARK_DETAIL_en]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Please select value for **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: `/custom_parameter start expression: val('$rollType',{Roll Type:1@Generic/2@Controlled Action/3@Risky Action/4@Desperate Action/5@Engagement/6@Resistance/7@Asset Quality/8@Progress Clock/9@Heat Reduction/10@Incarceration}) val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Dice/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) val('$stressbase',6) if('$rollType' =?1 && '$sixes'>?1,'Critical Success', '$rollType' =?1 && '$sixes'=?1, 'Success' , '$rollType' =?1 && '$partials' >? 0,'Partial Success', '$rollType' =?1 && '$partials' =?0, 'Failure', '$rollType' =?2 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?2 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?2 && '$partials' >? 0,'Partial Success - You hesitate. Do it with a minor consequence (lesser harm, minor complication, reduced effect or end up in a risky position) OR try another approach.', '$rollType' =?2 && '$partials' =?0, 'Failure - You falter. Press on with a risky opportunity OR withdraw and try another approach.', '$rollType' =?3 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?3 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?3 && '$partials' >? 0,'Partial Success - You do it but suffer harm, a complication, reduced effect or end up in a desperate position.', '$rollType' =?3 && '$partials' =?0, 'Failure - Things go badly. You suffer harm, a complication, end up in a desperate position or lose this opportunity for action.', '$rollType' =?4 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?4 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?4 && '$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or reduced effect.', '$rollType' =?4 && '$partials' =?0, 'Failure - Things could not go worse. You suffer severe harm, a serious complication, or lose this opportunity for action.', '$rollType' =?5 && '$sixes'>?1,'Critical Success - This first obstacle is overcome and you move to a controlled position for the next.', '$rollType' =?5 && '$sixes'=?1, 'Controlled - You are in a controlled position to act.' , '$rollType' =?5 && '$partials' >? 0,'Risky - You are in a risky position to act.', '$rollType' =?5 && '$partials' =?0, 'Desperate - You are in a desperate position to act.', '$rollType' =?6 && '$sixes'>?1,'Spectacular success - recover 1 stress.', '$rollType' =?6 && '$sixes'=?1, 'Well within your ability - no stress.' , '$rollType' =?6, concat ('You succeed with an effort - take ',('$stressbase' - ('$diceRoll'k1)=), ' stress.'), '$rollType' =?7 && '$sixes'>?1,'Exceptional Quality - Crew Tier +2', '$rollType' =?7 && '$sixes'=?1, 'Fine Quality - Crew Tier +1' , '$rollType' =?7 && '$partials' >? 0,'Standard Quality - Equal to Crew Tier', '$rollType' =?7 && '$partials' =?0, 'Inferior Quality - Crew Tier -1', '$rollType' =?8 && '$sixes'>?1,'Mark off 5 progress segments.', '$rollType' =?8 && '$sixes'=?1, 'Mark off 3 progress segments.' , '$rollType' =?8 && '$partials' >? 0,'Mark off two progress segments.', '$rollType' =?8 && '$partials' =?0, 'Mark off 1 progress segment.', '$rollType' =?9 && '$sixes'>?1,'Reduce 5 Heat.', '$rollType' =?9 && '$sixes'=?1, 'Reduce 3 Heat.' , '$rollType' =?9 && '$partials' >? 0,'Reduce 2 Heat.', '$rollType' =?9 && '$partials' =?0, 'Reduce 1 Heat.', '$rollType' =?10 && '$sixes'>?1,'You make a name for yourself (+3 rep, +1 prison claim, +1 faction).', '$rollType' =?10 && '$sixes'=?1, 'You do your time well (+1 prison claim, +1 faction).' , '$rollType' =?10 && '$partials' >? 0,'You keep your head down and do your time without incident.', '$rollType' =?10 && '$partials' =?0, 'A horrific experience - you suffer a level of Trauma.', '') answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEvent[BLADES_IN_THE_DARK_DETAIL_fr]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Veuillez sélectionner la valeur de **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: `/custom_parameter start expression: val('$rollType',{Roll Type:1@Generic/2@Controlled Action/3@Risky Action/4@Desperate Action/5@Engagement/6@Resistance/7@Asset Quality/8@Progress Clock/9@Heat Reduction/10@Incarceration}) val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Dice/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) val('$stressbase',6) if('$rollType' =?1 && '$sixes'>?1,'Critical Success', '$rollType' =?1 && '$sixes'=?1, 'Success' , '$rollType' =?1 && '$partials' >? 0,'Partial Success', '$rollType' =?1 && '$partials' =?0, 'Failure', '$rollType' =?2 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?2 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?2 && '$partials' >? 0,'Partial Success - You hesitate. Do it with a minor consequence (lesser harm, minor complication, reduced effect or end up in a risky position) OR try another approach.', '$rollType' =?2 && '$partials' =?0, 'Failure - You falter. Press on with a risky opportunity OR withdraw and try another approach.', '$rollType' =?3 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?3 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?3 && '$partials' >? 0,'Partial Success - You do it but suffer harm, a complication, reduced effect or end up in a desperate position.', '$rollType' =?3 && '$partials' =?0, 'Failure - Things go badly. You suffer harm, a complication, end up in a desperate position or lose this opportunity for action.', '$rollType' =?4 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?4 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?4 && '$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or reduced effect.', '$rollType' =?4 && '$partials' =?0, 'Failure - Things could not go worse. You suffer severe harm, a serious complication, or lose this opportunity for action.', '$rollType' =?5 && '$sixes'>?1,'Critical Success - This first obstacle is overcome and you move to a controlled position for the next.', '$rollType' =?5 && '$sixes'=?1, 'Controlled - You are in a controlled position to act.' , '$rollType' =?5 && '$partials' >? 0,'Risky - You are in a risky position to act.', '$rollType' =?5 && '$partials' =?0, 'Desperate - You are in a desperate position to act.', '$rollType' =?6 && '$sixes'>?1,'Spectacular success - recover 1 stress.', '$rollType' =?6 && '$sixes'=?1, 'Well within your ability - no stress.' , '$rollType' =?6, concat ('You succeed with an effort - take ',('$stressbase' - ('$diceRoll'k1)=), ' stress.'), '$rollType' =?7 && '$sixes'>?1,'Exceptional Quality - Crew Tier +2', '$rollType' =?7 && '$sixes'=?1, 'Fine Quality - Crew Tier +1' , '$rollType' =?7 && '$partials' >? 0,'Standard Quality - Equal to Crew Tier', '$rollType' =?7 && '$partials' =?0, 'Inferior Quality - Crew Tier -1', '$rollType' =?8 && '$sixes'>?1,'Mark off 5 progress segments.', '$rollType' =?8 && '$sixes'=?1, 'Mark off 3 progress segments.' , '$rollType' =?8 && '$partials' >? 0,'Mark off two progress segments.', '$rollType' =?8 && '$partials' =?0, 'Mark off 1 progress segment.', '$rollType' =?9 && '$sixes'>?1,'Reduce 5 Heat.', '$rollType' =?9 && '$sixes'=?1, 'Reduce 3 Heat.' , '$rollType' =?9 && '$partials' >? 0,'Reduce 2 Heat.', '$rollType' =?9 && '$partials' =?0, 'Reduce 1 Heat.', '$rollType' =?10 && '$sixes'>?1,'You make a name for yourself (+3 rep, +1 prison claim, +1 faction).', '$rollType' =?10 && '$sixes'=?1, 'You do your time well (+1 prison claim, +1 faction).' , '$rollType' =?10 && '$partials' >? 0,'You keep your head down and do your time without incident.', '$rollType' =?10 && '$partials' =?0, 'A horrific experience - you suffer a level of Trauma.', '') answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`" + ] +] + + +de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEvent[BLADES_IN_THE_DARK_DETAIL_pt_BR]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Por favor selecione um valor para **Roll Type**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Generic, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Controlled Action, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Risky Action, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Desperate Action, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Engagement, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Resistance, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Asset Quality, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Progress Clock, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Heat Reduction, id=custom_parameter\u001Eid9\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=Incarceration, id=custom_parameter\u001Eid10\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: `/custom_parameter start expression: val('$rollType',{Roll Type:1@Generic/2@Controlled Action/3@Risky Action/4@Desperate Action/5@Engagement/6@Resistance/7@Asset Quality/8@Progress Clock/9@Heat Reduction/10@Incarceration}) val('$diceRoll',{Number of Dice:2d6L1@No Dice/1d6@1 Dice/2d6@2 Dice/3d6@3 Dice/4d6@4 Dice/5d6@5 Dice/6d6@6 Dice/7d6@7 Dice}) val('$sixes','$diceRoll'==6c) val('$partials','$diceRoll'>3<6c) val('$stressbase',6) if('$rollType' =?1 && '$sixes'>?1,'Critical Success', '$rollType' =?1 && '$sixes'=?1, 'Success' , '$rollType' =?1 && '$partials' >? 0,'Partial Success', '$rollType' =?1 && '$partials' =?0, 'Failure', '$rollType' =?2 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?2 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?2 && '$partials' >? 0,'Partial Success - You hesitate. Do it with a minor consequence (lesser harm, minor complication, reduced effect or end up in a risky position) OR try another approach.', '$rollType' =?2 && '$partials' =?0, 'Failure - You falter. Press on with a risky opportunity OR withdraw and try another approach.', '$rollType' =?3 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?3 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?3 && '$partials' >? 0,'Partial Success - You do it but suffer harm, a complication, reduced effect or end up in a desperate position.', '$rollType' =?3 && '$partials' =?0, 'Failure - Things go badly. You suffer harm, a complication, end up in a desperate position or lose this opportunity for action.', '$rollType' =?4 && '$sixes'>?1,'Critical Success - You do it with increased effect.', '$rollType' =?4 && '$sixes'=?1, 'Success - You do it.' , '$rollType' =?4 && '$partials' >? 0,'Partial Success - You do it but suffer severe harm, a serious complication or reduced effect.', '$rollType' =?4 && '$partials' =?0, 'Failure - Things could not go worse. You suffer severe harm, a serious complication, or lose this opportunity for action.', '$rollType' =?5 && '$sixes'>?1,'Critical Success - This first obstacle is overcome and you move to a controlled position for the next.', '$rollType' =?5 && '$sixes'=?1, 'Controlled - You are in a controlled position to act.' , '$rollType' =?5 && '$partials' >? 0,'Risky - You are in a risky position to act.', '$rollType' =?5 && '$partials' =?0, 'Desperate - You are in a desperate position to act.', '$rollType' =?6 && '$sixes'>?1,'Spectacular success - recover 1 stress.', '$rollType' =?6 && '$sixes'=?1, 'Well within your ability - no stress.' , '$rollType' =?6, concat ('You succeed with an effort - take ',('$stressbase' - ('$diceRoll'k1)=), ' stress.'), '$rollType' =?7 && '$sixes'>?1,'Exceptional Quality - Crew Tier +2', '$rollType' =?7 && '$sixes'=?1, 'Fine Quality - Crew Tier +1' , '$rollType' =?7 && '$partials' >? 0,'Standard Quality - Equal to Crew Tier', '$rollType' =?7 && '$partials' =?0, 'Inferior Quality - Crew Tier -1', '$rollType' =?8 && '$sixes'>?1,'Mark off 5 progress segments.', '$rollType' =?8 && '$sixes'=?1, 'Mark off 3 progress segments.' , '$rollType' =?8 && '$partials' >? 0,'Mark off two progress segments.', '$rollType' =?8 && '$partials' =?0, 'Mark off 1 progress segment.', '$rollType' =?9 && '$sixes'>?1,'Reduce 5 Heat.', '$rollType' =?9 && '$sixes'=?1, 'Reduce 3 Heat.' , '$rollType' =?9 && '$partials' >? 0,'Reduce 2 Heat.', '$rollType' =?9 && '$partials' =?0, 'Reduce 1 Heat.', '$rollType' =?10 && '$sixes'>?1,'You make a name for yourself (+3 rep, +1 prison claim, +1 faction).', '$rollType' =?10 && '$sixes'=?1, 'You do your time well (+1 prison claim, +1 faction).' , '$rollType' =?10 && '$partials' >? 0,'You keep your head down and do your time without incident.', '$rollType' =?10 && '$partials' =?0, 'A horrific experience - you suffer a level of Trauma.', '') answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`" + ] +] + + de.janno.discord.bot.command.help.QuickstartCommandMockTest.handleSlashCommandEvent[BLADES_IN_THE_DARK_IMAGE_de]=[ [ "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Bitte wähle den Wert für **Number of Dice**, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=No Dice, id=custom_parameter\u001Eid1\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1 Die, id=custom_parameter\u001Eid2\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2 Dice, id=custom_parameter\u001Eid3\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=3 Dice, id=custom_parameter\u001Eid4\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=4 Dice, id=custom_parameter\u001Eid5\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=5 Dice, id=custom_parameter\u001Eid6\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=6 Dice, id=custom_parameter\u001Eid7\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=7 Dice, id=custom_parameter\u001Eid8\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandTest.java index 9c369272..4594d4c0 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandTest.java @@ -32,7 +32,7 @@ class QuickstartCommandTest { @BeforeEach void setup() { PersistenceManager persistenceManager = Mockito.mock(PersistenceManager.class); - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true); CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); @@ -151,6 +151,7 @@ void getAutoCompleteAnswer_All() { a.assertThat(res.stream().map(AutoCompleteAnswer::getName)).containsExactly( "A Song of Ice and Fire", "Blades in the Dark", + "Blades in the Dark - Detail", "Blades in the Dark without Dice Images", "Bluebeard's Bride", "Call of Cthulhu 7th Edition", @@ -195,6 +196,7 @@ void getAutoCompleteAnswer_All() { a.assertThat(res.stream().map(AutoCompleteAnswer::getValue)).containsExactly( "ASOIAF", "BLADES_IN_THE_DARK_IMAGE", + "BLADES_IN_THE_DARK_DETAIL", "BLADES_IN_THE_DARK", "BLUEBEARD_BRIDE", "CALL_OF_CTHULHU_7ED", diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.java new file mode 100644 index 00000000..530f63a4 --- /dev/null +++ b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.java @@ -0,0 +1,98 @@ +package de.janno.discord.bot.command.help; + +import au.com.origin.snapshots.Expect; +import au.com.origin.snapshots.junit5.SnapshotExtension; +import de.janno.discord.bot.ButtonEventAdaptorMock; +import de.janno.discord.bot.SlashEventAdaptorMock; +import de.janno.discord.bot.command.customDice.CustomDiceCommand; +import de.janno.discord.bot.command.customParameter.CustomParameterCommand; +import de.janno.discord.bot.command.sumCustomSet.SumCustomSetCommand; +import de.janno.discord.bot.dice.CachingDiceEvaluator; +import de.janno.discord.bot.persistance.PersistenceManager; +import de.janno.discord.bot.persistance.PersistenceManagerImpl; +import de.janno.discord.connector.api.slash.CommandInteractionOption; +import de.janno.evaluator.dice.random.RandomNumberSupplier; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import java.util.*; +import java.util.concurrent.atomic.AtomicLong; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(SnapshotExtension.class) +public class WelcomeCommandMockTest { + + PersistenceManager persistenceManager; + private Expect expect; + + @BeforeEach + void setup() { + persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); + } + + @Test + void slashStartWelcome_firstButton() { + WelcomeCommand underTest = getWelcomeCommand(); + + SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() + .name("start") + .build())); + underTest.handleSlashCommandEvent(slashEvent, () -> UUID.fromString("00000000-0000-0000-0000-000000000001"), Locale.ENGLISH).block(); + + expect.scenario("slash").toMatchSnapshot(Set.copyOf(slashEvent.getSortedActions())); + + Optional buttonEvent = slashEvent.getFirstButtonEventMockOfLastButtonMessage(); + assertThat(buttonEvent).isPresent(); + underTest.handleComponentInteractEvent(buttonEvent.get()).block(); + expect.scenario("button").toMatchSnapshot(buttonEvent.get().getSortedActions()); + } + + @Test + void slashStartWelcome_legacyDnD5Id() { + WelcomeCommand underTest = getWelcomeCommand(); + + SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() + .name("start") + .build())); + underTest.handleSlashCommandEvent(slashEvent, () -> UUID.fromString("00000000-0000-0000-0000-000000000001"), Locale.ENGLISH).block(); + + expect.scenario("slash").toMatchSnapshot(Set.copyOf(slashEvent.getSortedActions())); + + ButtonEventAdaptorMock buttonEvent = new ButtonEventAdaptorMock("welcome", "dnd5_image", new AtomicLong(0)); + underTest.handleComponentInteractEvent(buttonEvent).block(); + expect.scenario("button").toMatchSnapshot(buttonEvent.getSortedActions()); + } + + @Test + void slashStartWelcome_invalidId() { + WelcomeCommand underTest = getWelcomeCommand(); + + SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() + .name("start") + .build())); + underTest.handleSlashCommandEvent(slashEvent, () -> UUID.fromString("00000000-0000-0000-0000-000000000001"), Locale.ENGLISH).block(); + + expect.scenario("slash").toMatchSnapshot(Set.copyOf(slashEvent.getSortedActions())); + + ButtonEventAdaptorMock buttonEvent = new ButtonEventAdaptorMock("welcome", "invalidId", new AtomicLong(0)); + underTest.handleComponentInteractEvent(buttonEvent).block(); + expect.scenario("button").toMatchSnapshot(buttonEvent.getSortedActions()); + } + + @NotNull + private WelcomeCommand getWelcomeCommand() { + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true); + + CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); + CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); + SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); + RpgSystemCommandPreset rpgSystemCommandPreset = new RpgSystemCommandPreset(persistenceManager, customParameterCommand, customDiceCommand, sumCustomSetCommand); + + return new WelcomeCommand(persistenceManager, rpgSystemCommandPreset, () -> UUID.fromString("00000000-0000-0000-0000-000000000000")); + } + + +} diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.snap b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.snap new file mode 100644 index 00000000..39244090 --- /dev/null +++ b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandMockTest.snap @@ -0,0 +1,47 @@ +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_firstButton[button]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on a button to roll the dice, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=D20, id=custom_dice\u001E1_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=D20 Advantage, id=custom_dice\u001E2_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=D20 Disadvantage, id=custom_dice\u001E3_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d4, id=custom_dice\u001E4_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d6, id=custom_dice\u001E5_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d8, id=custom_dice\u001E6_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d10, id=custom_dice\u001E7_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d12, id=custom_dice\u001E8_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d100, id=custom_dice\u001E9_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d4, id=custom_dice\u001E10_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d6, id=custom_dice\u001E11_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d8, id=custom_dice\u001E12_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=custom_dice\u001E13_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=2d12, id=custom_dice\u001E14_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d20, id=custom_dice\u001E15_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=`/custom_dice start buttons: D20;2d20k1@D20 Advantage;2d20L1@D20 Disadvantage;;1d4;1d6;1d8;1d10;1d12;1d100;2d4=@2d4;2d6=@2d6;2d8=@2d8;2d10=@2d10;2d12=@2d12;2d20=@2d20 answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`, fields=[], componentRowDefinitions=[], hasImage=false, type=MESSAGE)", + "editMessage: message:Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, buttonValues=DND5_IMAGE,DND5,FATE_IMAGE,COIN,NWOD,OWOD,SHADOWRUN_IMAGE,DICE_CALCULATOR" + ] +] + + +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_firstButton[slash]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Dungeon & Dragons 5e, id=welcome\u001EDND5_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dungeon & Dragons 5e without Dice Images, id=welcome\u001EDND5\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Fate, id=welcome\u001EFATE_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Coin Toss, id=welcome\u001ECOIN\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=nWod / Chronicles of Darkness, id=welcome\u001ENWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=oWod / Storyteller System, id=welcome\u001EOWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Shadowrun, id=welcome\u001ESHADOWRUN_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dice Calculator, id=welcome\u001EDICE_CALCULATOR\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_invalidId[button]=[ + [ + "editMessage: message:Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, buttonValues=DND5_IMAGE,DND5,FATE_IMAGE,COIN,NWOD,OWOD,SHADOWRUN_IMAGE,DICE_CALCULATOR" + ] +] + + +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_invalidId[slash]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Dungeon & Dragons 5e, id=welcome\u001EDND5_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dungeon & Dragons 5e without Dice Images, id=welcome\u001EDND5\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Fate, id=welcome\u001EFATE_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Coin Toss, id=welcome\u001ECOIN\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=nWod / Chronicles of Darkness, id=welcome\u001ENWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=oWod / Storyteller System, id=welcome\u001EOWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Shadowrun, id=welcome\u001ESHADOWRUN_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dice Calculator, id=welcome\u001EDICE_CALCULATOR\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] + + +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_legacyDnD5Id[button]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Click on a button to roll the dice, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=D20, id=custom_dice\u001E1_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=D20 Advantage, id=custom_dice\u001E2_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=D20 Disadvantage, id=custom_dice\u001E3_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d4, id=custom_dice\u001E4_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d6, id=custom_dice\u001E5_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d8, id=custom_dice\u001E6_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d10, id=custom_dice\u001E7_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=1d12, id=custom_dice\u001E8_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=1d100, id=custom_dice\u001E9_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d4, id=custom_dice\u001E10_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d6, id=custom_dice\u001E11_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d8, id=custom_dice\u001E12_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d10, id=custom_dice\u001E13_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=2d12, id=custom_dice\u001E14_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false), ButtonDefinition(label=2d20, id=custom_dice\u001E15_button\u001E00000000-0000-0000-0000-000000000000, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=`/custom_dice start buttons: D20;2d20k1@D20 Advantage;2d20L1@D20 Disadvantage;;1d4;1d6;1d8;1d10;1d12;1d100;2d4=@2d4;2d6=@2d6;2d8=@2d8;2d10=@2d10;2d12=@2d12;2d20=@2d20 answer_format: without_expression dice_image_style: polyhedral_RdD dice_image_color: default`, fields=[], componentRowDefinitions=[], hasImage=false, type=MESSAGE)", + "editMessage: message:Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, buttonValues=DND5_IMAGE,DND5,FATE_IMAGE,COIN,NWOD,OWOD,SHADOWRUN_IMAGE,DICE_CALCULATOR" + ] +] + + +de.janno.discord.bot.command.help.WelcomeCommandMockTest.slashStartWelcome_legacyDnD5Id[slash]=[ + [ + "createMessageWithoutReference: EmbedOrMessageDefinition(title=null, descriptionOrContent=Welcome to the Button Dice Bot,\nuse one of the example buttons below to start one of the RPG dice systems, use `/quickstart system` to select one of many RPG presets or use the slash command to configure your own custom dice system (see https://github.com/twonirwana/DiscordDiceBot for details or the slash command `/help`).\nYou can also use the slash command `/r` to directly roll dice with.\nFor help or feature request come to the support discord server: https://discord.gg/e43BsqKpFr, fields=[], componentRowDefinitions=[ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=Dungeon & Dragons 5e, id=welcome\u001EDND5_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dungeon & Dragons 5e without Dice Images, id=welcome\u001EDND5\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Fate, id=welcome\u001EFATE_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Coin Toss, id=welcome\u001ECOIN\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)]), ComponentRowDefinition(buttonDefinitions=[ButtonDefinition(label=nWod / Chronicles of Darkness, id=welcome\u001ENWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=oWod / Storyteller System, id=welcome\u001EOWOD\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Shadowrun, id=welcome\u001ESHADOWRUN_IMAGE\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false), ButtonDefinition(label=Dice Calculator, id=welcome\u001EDICE_CALCULATOR\u001E00000000-0000-0000-0000-000000000001, style=PRIMARY, disabled=false)])], hasImage=false, type=MESSAGE)", + "reply: commandString" + ] +] \ No newline at end of file diff --git a/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandTest.java index 550d594c..d9303e15 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/help/WelcomeCommandTest.java @@ -40,7 +40,7 @@ class WelcomeCommandTest { @BeforeEach void setup() { PersistenceManager persistenceManager = Mockito.mock(PersistenceManager.class); - CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0); + CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true); CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator); CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator); SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator); @@ -49,38 +49,10 @@ void setup() { } @Test - public void getButtonMessageWithState_fate() { + public void getButtonMessageWithState_legacyKey() { Optional res = underTest.createNewButtonMessageWithState(UUID.fromString("00000000-0000-0000-0000-000000000000"), - new Config(null, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH), new State<>("fate", StateData.empty()), 1L, 2L); - assertThat(res.map(EmbedOrMessageDefinition::getDescriptionOrContent)) - .contains("Please select value for **Modifier**"); - assertThat(res.map(EmbedOrMessageDefinition::getComponentRowDefinitions) - .stream() - .flatMap(Collection::stream) - .flatMap(s -> s.getButtonDefinitions().stream()) - .map(ButtonDefinition::getId)) - .containsExactly("custom_parameterid100000000-0000-0000-0000-000000000000", - "custom_parameterid200000000-0000-0000-0000-000000000000", - "custom_parameterid300000000-0000-0000-0000-000000000000", - "custom_parameterid400000000-0000-0000-0000-000000000000", - "custom_parameterid500000000-0000-0000-0000-000000000000", - "custom_parameterid600000000-0000-0000-0000-000000000000", - "custom_parameterid700000000-0000-0000-0000-000000000000", - "custom_parameterid800000000-0000-0000-0000-000000000000", - "custom_parameterid900000000-0000-0000-0000-000000000000", - "custom_parameterid1000000000-0000-0000-0000-000000000000", - "custom_parameterid1100000000-0000-0000-0000-000000000000", - "custom_parameterid1200000000-0000-0000-0000-000000000000", - "custom_parameterid1300000000-0000-0000-0000-000000000000", - "custom_parameterid1400000000-0000-0000-0000-000000000000", - "custom_parameterid1500000000-0000-0000-0000-000000000000"); - assertThat(res.map(EmbedOrMessageDefinition::getComponentRowDefinitions) - .stream() - .flatMap(Collection::stream) - .flatMap(s -> s.getButtonDefinitions().stream()) - .map(ButtonDefinition::getLabel)) - .containsExactly("-4", "-3", "-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); - + new Config(null, AnswerFormatType.full, null, new DiceStyleAndColor(DiceImageStyle.none, "none"), Locale.ENGLISH), new State<>("invalidId", StateData.empty()), 1L, 2L); + assertThat(res).isEmpty(); } @Test @@ -353,35 +325,32 @@ public void getWelcomeMessage() { .flatMap(s -> s.getButtonDefinitions().stream()) .map(ButtonDefinition::getId)) .containsExactly( - "welcomefate00000000-0000-0000-0000-000000000000", - "welcomefate_image00000000-0000-0000-0000-000000000000", - "welcomednd500000000-0000-0000-0000-000000000000", - "welcomednd5_image00000000-0000-0000-0000-000000000000", - "welcomenWoD00000000-0000-0000-0000-000000000000", - "welcomeoWoD00000000-0000-0000-0000-000000000000", - "welcomeshadowrun00000000-0000-0000-0000-000000000000", - "welcomecoin00000000-0000-0000-0000-000000000000", - "welcomedice_calculator00000000-0000-0000-0000-000000000000"); + "welcomeDND5_IMAGE00000000-0000-0000-0000-000000000000", + "welcomeDND500000000-0000-0000-0000-000000000000", + "welcomeFATE_IMAGE00000000-0000-0000-0000-000000000000", + "welcomeCOIN00000000-0000-0000-0000-000000000000", + "welcomeNWOD00000000-0000-0000-0000-000000000000", + "welcomeOWOD00000000-0000-0000-0000-000000000000", + "welcomeSHADOWRUN_IMAGE00000000-0000-0000-0000-000000000000", + "welcomeDICE_CALCULATOR00000000-0000-0000-0000-000000000000"); assertThat(res.getComponentRowDefinitions() .stream() .flatMap(s -> s.getButtonDefinitions().stream()) .map(ButtonDefinition::getLabel)) .containsExactly( - "Fate without Dice Images", - "Fate", - "Dungeon & Dragons 5e without Dice Images", "Dungeon & Dragons 5e", + "Dungeon & Dragons 5e without Dice Images", + "Fate", + "Coin Toss", "nWod / Chronicles of Darkness", "oWod / Storyteller System", - "Shadowrun without Dice Images", - "Coin Toss", + "Shadowrun", "Dice Calculator"); } @ParameterizedTest @CsvSource({ - "fate", "fate_image", "dnd5", "dnd5_image", diff --git a/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandMockTest.java b/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandMockTest.java index 4c4055cf..c757db67 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandMockTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandMockTest.java @@ -42,7 +42,7 @@ void setup() { @Test void roll_fullExpression() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -64,7 +64,7 @@ void roll_fullExpression() { @Test void roll_full() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -86,7 +86,7 @@ void roll_full() { @Test void directRoll() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of( @@ -106,7 +106,7 @@ void directRoll() { @Test void roll_disabled() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of( @@ -122,7 +122,7 @@ void roll_disabled() { @Test void directRoll_disabled() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of( @@ -138,7 +138,7 @@ void directRoll_disabled() { @Test void slash_start_multiLine() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -164,7 +164,7 @@ void slash_start_multiLine() { @Test void slash_start_directRoll() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 0, 10_000, true)); SlashEventAdaptorMock slashEvent = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder() .name("start") @@ -194,7 +194,7 @@ void slash_start_directRoll() { @Test void roll_fullGerman() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -215,7 +215,7 @@ void roll_fullGerman() { @Test void roll_full_ptBR() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -236,7 +236,7 @@ void roll_full_ptBR() { @Test void roll_compact() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -257,7 +257,7 @@ void roll_compact() { @Test void roll_minimal() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -278,7 +278,7 @@ void roll_minimal() { @Test void roll_locked() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -302,7 +302,7 @@ void roll_locked() { @Test void clear() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -320,7 +320,7 @@ void clear() { @Test void backBack() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -341,7 +341,7 @@ void backBack() { @Test void roll_pinned() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -362,7 +362,7 @@ void roll_pinned() { @Test void roll_answerChannel() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(2L, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -383,7 +383,7 @@ void roll_answerChannel() { @Test void roll_pinnedTwice() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(null, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -410,7 +410,7 @@ void roll_pinnedTwice() { @Test void roll_answerChannelTwice() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); SumCustomSetConfig config = new SumCustomSetConfig(2L, ImmutableList.of(new ButtonIdLabelAndDiceExpression("1_button", "Dmg", "+1d6", false, false), @@ -437,7 +437,7 @@ void roll_answerChannelTwice() { @Test void channelAlias() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); @@ -468,7 +468,7 @@ void channelAlias() { @Test void userChannelAlias() { - SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + SumCustomSetCommand underTest = new SumCustomSetCommand(persistenceManager, new DiceParser(), new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10000, true)); ChannelConfigCommand channelConfig = new ChannelConfigCommand(persistenceManager); diff --git a/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandTest.java b/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandTest.java index 68faa490..879337a1 100644 --- a/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandTest.java +++ b/bot/src/test/java/de/janno/discord/bot/command/sumCustomSet/SumCustomSetCommandTest.java @@ -58,7 +58,7 @@ static Stream generateGetEditButtonMessageData() { @BeforeEach void setup() { diceMock = mock(Dice.class); - underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> 0, 1000, 0)); + underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> 0, 1000, 0, 10_000, true)); } @ParameterizedTest(name = "{index} config={0}, buttonId={1} -> {2}") @@ -210,7 +210,7 @@ void rollDice_1d6plus10() { @Test void rollDice_PrePostfix() { - underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> maxIncl, 1000, 0)); + underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator((minExcl, maxIncl) -> maxIncl, 1000, 0, 10_000, true)); SumCustomSetConfig config = new SumCustomSetConfig(123L, List.of( new ButtonIdLabelAndDiceExpression("1_button", "5d6", "+5d6", false, false), new ButtonIdLabelAndDiceExpression("2_button", "2d10", "+2d10", true, false) @@ -536,7 +536,7 @@ public void testToCommandString() { @Test void checkPersistence() { PersistenceManager persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null); - underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000)); + underTest = new SumCustomSetCommand(persistenceManager, diceMock, new CachingDiceEvaluator(new RandomNumberSupplier(0), 1000, 10000, 10_000, true)); UUID configUUID = UUID.randomUUID(); long channelId = System.currentTimeMillis(); diff --git a/bot/src/test/java/de/janno/discord/bot/dice/image/ImageResultCreatorTest.java b/bot/src/test/java/de/janno/discord/bot/dice/image/ImageResultCreatorTest.java index 8dc35f02..80809d72 100644 --- a/bot/src/test/java/de/janno/discord/bot/dice/image/ImageResultCreatorTest.java +++ b/bot/src/test/java/de/janno/discord/bot/dice/image/ImageResultCreatorTest.java @@ -98,7 +98,7 @@ void cleanUp() throws IOException { @Test void getImageForRoll_ResultImageNone() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000).evaluate("1d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000, 10_000, true).evaluate("1d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.none, "none")); @@ -107,7 +107,7 @@ void getImageForRoll_ResultImageNone() throws ExpressionException { @Test void createRollCacheNameTest_blackGold() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000).evaluate("6d6+1d6+3d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6+1d6+3d6"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -116,7 +116,7 @@ void createRollCacheNameTest_blackGold() throws ExpressionException { @Test void createRollCacheNameTest_multiColor() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 8, 10, 12, 20, 99), 1000).evaluate("color(1d4,'gray') + color(1d6,'black') + color(1d8,'white') + color(1d10,'red') + color(1d12,'blue') + color(1d20,'green') + color(1d100,'orange')"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 8, 10, 12, 20, 99), 1000, 10_000, true).evaluate("color(1d4,'gray') + color(1d6,'black') + color(1d8,'white') + color(1d10,'red') + color(1d12,'blue') + color(1d20,'green') + color(1d100,'orange')"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_2d, "red")); @@ -125,7 +125,7 @@ void createRollCacheNameTest_multiColor() throws ExpressionException { @Test void createRollCacheNameTest_multiCol() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 8, 10, 12, 20, 99), 1000).evaluate("1d4 col 'gray' + 1d6 col 'black' + 1d8 col 'white' + 1d10 col 'red' + 1d12 col 'blue' + 1d20 col 'green' + 1d100 col 'orange'"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 8, 10, 12, 20, 99), 1000, 10_000, true).evaluate("1d4 col 'gray' + 1d6 col 'black' + 1d8 col 'white' + 1d10 col 'red' + 1d12 col 'blue' + 1d20 col 'green' + 1d100 col 'orange'"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_2d, "red")); @@ -134,7 +134,7 @@ void createRollCacheNameTest_multiCol() throws ExpressionException { @Test void createRollCacheNameTest_fateBlack() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 1), 1000).evaluate("4d[-1,0,1]"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 1), 1000, 10_000, true).evaluate("4d[-1,0,1]"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.fate, "black")); @@ -143,7 +143,7 @@ void createRollCacheNameTest_fateBlack() throws ExpressionException { @Test void createRollCacheNameTest_explode() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000).evaluate("3d!6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000, 10_000, true).evaluate("3d!6"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -152,7 +152,7 @@ void createRollCacheNameTest_explode() throws ExpressionException { @Test void createRollCacheNameTest_explodeAdd() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000).evaluate("3d!!6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000, 10_000, true).evaluate("3d!!6"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -161,7 +161,7 @@ void createRollCacheNameTest_explodeAdd() throws ExpressionException { @Test void getImageForRoll_explode() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000).evaluate("3d!6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000, 10_000, true).evaluate("3d!6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -171,7 +171,7 @@ void getImageForRoll_explode() throws ExpressionException, IOException { @Test void getImageForRoll_explodeAdd() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000).evaluate("3d!!6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(6, 6, 5, 5, 4, 3), 1000, 10_000, true).evaluate("3d!!6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -181,7 +181,7 @@ void getImageForRoll_explodeAdd() throws ExpressionException, IOException { @Test void getImageForRoll_blackGold() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000).evaluate("6d6+1d6+3d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6+1d6+3d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -191,7 +191,7 @@ void getImageForRoll_blackGold() throws ExpressionException, IOException { @Test void getImageForRoll_noDie_blackGold() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(), 1000).evaluate("5"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(), 1000, 10_000, true).evaluate("5"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -200,7 +200,7 @@ void getImageForRoll_noDie_blackGold() throws ExpressionException { @Test void getImageForRoll_D7_blackGold() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000).evaluate("1d7"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000, 10_000, true).evaluate("1d7"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -209,7 +209,7 @@ void getImageForRoll_D7_blackGold() throws ExpressionException { @Test void getImageForRoll_D100_00_blackGold() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -219,7 +219,7 @@ void getImageForRoll_D100_00_blackGold() throws ExpressionException, IOException @Test void getImageForRoll_D100_01_blackGold() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -229,7 +229,7 @@ void getImageForRoll_D100_01_blackGold() throws ExpressionException, IOException @Test void getImageForRoll_D100_99_blackGold() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v1, "black_and_gold")); @@ -239,7 +239,7 @@ void getImageForRoll_D100_99_blackGold() throws ExpressionException, IOException @Test void getImageForRoll_cache() throws ExpressionException, IOException, InterruptedException { - List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d6"); + List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d6"); Supplier res1 = underTest.getImageForRoll(rolls1, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); assertThat(res1).isNotNull(); @@ -250,7 +250,7 @@ void getImageForRoll_cache() throws ExpressionException, IOException, Interrupte Thread.sleep(100); - List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d6"); + List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d6"); Supplier cachedRes1 = underTest.getImageForRoll(rolls2, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); assertThat(cachedRes1).isNotNull(); @@ -261,7 +261,7 @@ void getImageForRoll_cache() throws ExpressionException, IOException, Interrupte Thread.sleep(100); - List rolls3 = new DiceEvaluator(new GivenNumberSupplier(2), 1000).evaluate("1d6"); + List rolls3 = new DiceEvaluator(new GivenNumberSupplier(2), 1000, 10_000, true).evaluate("1d6"); Supplier res2 = underTest.getImageForRoll(rolls3, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); assertThat(res2).isNotNull(); @@ -274,14 +274,14 @@ void getImageForRoll_cache() throws ExpressionException, IOException, Interrupte @Test void getImageForRoll_noCacheForLargeDiceSets() throws ExpressionException, IOException { - List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("7d10"); + List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("7d10"); Supplier res1 = underTest.getImageForRoll(rolls1, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); assertThat(res1).isNotNull(); File cacheFolder = new File("imageCache/"); assertThat(cacheFolder).isEmptyDirectory(); assertThat(getDataHash(res1)).isEqualTo("c6ea9275d2ab8391ff4978a4fd8e3f36fa0ef0ab4dc6fa85074a175e2bd307b0"); - List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("7d10"); + List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("7d10"); Supplier res2 = underTest.getImageForRoll(rolls2, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); assertThat(cacheFolder).isEmptyDirectory(); @@ -291,7 +291,7 @@ void getImageForRoll_noCacheForLargeDiceSets() throws ExpressionException, IOExc @Test void getImageForCustomRoll_cache() throws ExpressionException, IOException, InterruptedException { - List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d[-1,0,1]"); + List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d[-1,0,1]"); Supplier res1 = underTest.getImageForRoll(rolls1, new DiceStyleAndColor(DiceImageStyle.fate, "black")); assertThat(res1).isNotNull(); @@ -302,7 +302,7 @@ void getImageForCustomRoll_cache() throws ExpressionException, IOException, Inte Thread.sleep(100); - List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d[-1,0,1]"); + List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d[-1,0,1]"); Supplier cachedRes1 = underTest.getImageForRoll(rolls2, new DiceStyleAndColor(DiceImageStyle.fate, "black")); assertThat(cachedRes1).isNotNull(); @@ -313,7 +313,7 @@ void getImageForCustomRoll_cache() throws ExpressionException, IOException, Inte Thread.sleep(100); - List rolls3 = new DiceEvaluator(new GivenNumberSupplier(2), 1000).evaluate("1d[-1,0,1]"); + List rolls3 = new DiceEvaluator(new GivenNumberSupplier(2), 1000, 10_000, true).evaluate("1d[-1,0,1]"); Supplier res2 = underTest.getImageForRoll(rolls3, new DiceStyleAndColor(DiceImageStyle.fate, "black")); assertThat(res2).isNotNull(); @@ -326,14 +326,14 @@ void getImageForCustomRoll_cache() throws ExpressionException, IOException, Inte @Test void getImageForCustomRoll_noCacheForLargeDiceSets() throws ExpressionException, IOException { - List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("7d[-1,0,1]"); + List rolls1 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("7d[-1,0,1]"); Supplier res1 = underTest.getImageForRoll(rolls1, new DiceStyleAndColor(DiceImageStyle.fate, "black")); assertThat(res1).isNotNull(); File cacheFolder = new File("imageCache/"); assertThat(cacheFolder).isEmptyDirectory(); assertThat(getDataHash(res1)).isEqualTo("b3929fb41bad88f279554cb27e729c05ca783f03134ffe531f6bd3c3cb315d5a"); - List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("7d[-1,0,1]"); + List rolls2 = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("7d[-1,0,1]"); Supplier res2 = underTest.getImageForRoll(rolls2, new DiceStyleAndColor(DiceImageStyle.fate, "black")); assertThat(cacheFolder).isEmptyDirectory(); @@ -343,7 +343,7 @@ void getImageForCustomRoll_noCacheForLargeDiceSets() throws ExpressionException, @Test void createRollCacheNameTest_3dRedWhite() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000).evaluate("6d6+1d6+3d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6+1d6+3d6"); String res = underTest.createRollCacheName(rolls.getFirst(), new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -352,7 +352,7 @@ void createRollCacheNameTest_3dRedWhite() throws ExpressionException { @Test void getImageForRoll_3dRedWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000).evaluate("6d6+1d6+3d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6+1d6+3d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -362,7 +362,7 @@ void getImageForRoll_3dRedWhite() throws ExpressionException, IOException { @Test void getImageForRoll_d6DotsWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000).evaluate("6d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.d6_dots, "white")); @@ -372,7 +372,7 @@ void getImageForRoll_d6DotsWhite() throws ExpressionException, IOException { @Test void getImageForRoll_d6DotsBlackAndGold() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000).evaluate("6d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.d6_dots, "black_and_gold")); @@ -383,7 +383,7 @@ void getImageForRoll_d6DotsBlackAndGold() throws ExpressionException, IOExceptio @Test void getImageForRoll_noDie_3dRedWhite() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(), 1000).evaluate("5"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(), 1000, 10_000, true).evaluate("5"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -392,7 +392,7 @@ void getImageForRoll_noDie_3dRedWhite() throws ExpressionException { @Test void getImageForRoll_D7_3dRedWhite() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000).evaluate("1d7"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000, 10_000, true).evaluate("1d7"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -401,7 +401,7 @@ void getImageForRoll_D7_3dRedWhite() throws ExpressionException { @Test void getImageForRoll_D100_00_3dRedWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(100), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -411,7 +411,7 @@ void getImageForRoll_D100_00_3dRedWhite() throws ExpressionException, IOExceptio @Test void getImageForRoll_D100_01_3dRedWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -421,7 +421,7 @@ void getImageForRoll_D100_01_3dRedWhite() throws ExpressionException, IOExceptio @Test void getImageForRoll_D100_99_3dRedWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -435,12 +435,12 @@ void testLegacyPolyhedralResultImage(ResultImage resultImage, List side ImageResultCreator underTestWithoutCache = new ImageResultCreator(-1); for (int d : sides) { for (int s = 1; s <= d; s++) { - List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000).evaluate("1d%d".formatted(d)); + List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000, 10_000, true).evaluate("1d%d".formatted(d)); Supplier res = underTestWithoutCache.getImageForRoll(rolls, LegacyImageConfigHelper.getStyleAndColor(resultImage)); assertThat(res).isNotNull(); } } - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d[abc/cde]"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d[abc/cde]"); Supplier res = underTest.getImageForRoll(rolls, LegacyImageConfigHelper.getStyleAndColor(resultImage)); assertThat(res).isNull(); } @@ -451,7 +451,7 @@ void testPolyhedralResultImage(DiceImageStyle diceImageStyle, List side ImageResultCreator underTestWithoutCache = new ImageResultCreator(-1); for (int d : sides) { for (int s = 1; s <= d; s++) { - List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000).evaluate("1d%d".formatted(d)); + List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000, 10_000, true).evaluate("1d%d".formatted(d)); for (String color : diceImageStyle.getSupportedColors()) { Supplier res = underTestWithoutCache.getImageForRoll(rolls, new DiceStyleAndColor(diceImageStyle, color)); assertThat(res).isNotNull(); @@ -459,7 +459,7 @@ void testPolyhedralResultImage(DiceImageStyle diceImageStyle, List side } } } - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d[abc/cde]"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d[abc/cde]"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(diceImageStyle, "notAColor")); assertThat(res).isNull(); } @@ -469,19 +469,19 @@ void testPolyhedralResultImage(DiceImageStyle diceImageStyle, List side void testPolyhedralResultImagePerColor(DiceImageStyle diceImageStyle, List sides, String color) throws ExpressionException { for (int d : sides) { for (int s = 1; s <= d; s++) { - List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000).evaluate("1d%d".formatted(d)); + List rolls = new DiceEvaluator(new GivenNumberSupplier(s), 1000, 10_000, true).evaluate("1d%d".formatted(d)); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(diceImageStyle, color)); assertThat(res).isNotNull(); } } - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d[abc/cde]"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d[abc/cde]"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(diceImageStyle, "notAColor")); assertThat(res).isNull(); } @Test void getImageForRoll_polyhedralDrawColor() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(2, 4, 6, 8, 10, 12, 20, 99), 1000) + List rolls = new DiceEvaluator(new GivenNumberSupplier(2, 4, 6, 8, 10, 12, 20, 99), 1000, 10000, true) .evaluate("color(1d2,'indigo') +color(1d4,'gray') + color(1d6,'black') + color(1d8,'white') + color(1d10,'red') + color(1d12,'blue') + color(1d20,'green') + color(1d100,'orange')"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_2d, DiceImageStyle.polyhedral_2d.getDefaultColor())); @@ -494,7 +494,7 @@ void getImageForRoll_polyhedralDrawColor() throws ExpressionException { @Test void getImageForRoll_polyhedralDrawColorCustom() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(2, 2, 6, 8, 10, 12, 20, 1, 1, 1), 1000) + List rolls = new DiceEvaluator(new GivenNumberSupplier(2, 2, 6, 8, 10, 12, 20, 1, 1, 1), 1000, 10000, true) .evaluate("color(d[\uD83D/\uD83D\uDC41],'indigo')" + "+ color(1d[-1/-2/-3/+1/+2/+3],'gray') " + "+ color(1d[0/10/20/30/40/50/60/70],'black') " + @@ -518,7 +518,7 @@ void getImageForRoll_polyhedralDrawColorCustom() throws ExpressionException { @Test void getImageForRoll_polyhedralDrawUtf16Emoji() throws ExpressionException, IOException { - DiceEvaluator evaluator = new DiceEvaluator(new GivenNumberSupplier(1, 2), 1000); + DiceEvaluator evaluator = new DiceEvaluator(new GivenNumberSupplier(1, 2), 1000, 10000, true); List roll1 = evaluator.evaluate("color(d[\uD83D\uDDE1/\uD83D\uDC4D],'cyan') "); List roll2 = evaluator.evaluate("color(d[\uD83D\uDDE1/\uD83D\uDC4D],'cyan') "); String image1Hash = getDataHash(underTest.getImageForRoll(roll1, new DiceStyleAndColor(DiceImageStyle.polyhedral_2d, DiceImageStyle.polyhedral_2d.getDefaultColor()))); @@ -530,7 +530,7 @@ void getImageForRoll_polyhedralDrawUtf16Emoji() throws ExpressionException, IOEx @Test void getImageForRoll_polyhedral_RdD() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 7, 8, 10, 12, 20, 99, 8, 12), 1000).evaluate("1d4 + 1d6 + 1d7 + 1d8 + 1d10 +1d12 + 1d20 + 1d100 + 1d8 col 'special' + 1d12 col 'special'"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 6, 7, 8, 10, 12, 20, 99, 8, 12), 1000, 10_000, true).evaluate("1d4 + 1d6 + 1d7 + 1d8 + 1d10 +1d12 + 1d20 + 1d100 + 1d8 col 'special' + 1d12 col 'special'"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_RdD, DiceImageStyle.polyhedral_RdD.getDefaultColor())); @@ -540,7 +540,7 @@ void getImageForRoll_polyhedral_RdD() throws ExpressionException, IOException { @Test void getImageForRoll_polyhedral_RdD_specialColor() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000).evaluate("1d100"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(99), 1000, 10_000, true).evaluate("1d100"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_RdD, "special")); @@ -549,7 +549,7 @@ void getImageForRoll_polyhedral_RdD_specialColor() throws ExpressionException { @Test void getImageForRoll_Expanse() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000).evaluate("6d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.expanse, DiceImageStyle.expanse.getDefaultColor())); @@ -559,7 +559,7 @@ void getImageForRoll_Expanse() throws ExpressionException, IOException { @Test void getImageForRoll_marvelBlue() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000).evaluate("6d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.d6_marvel, "blue")); @@ -569,7 +569,7 @@ void getImageForRoll_marvelBlue() throws ExpressionException, IOException { @Test void getImageForRoll_marvelRed() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000).evaluate("6d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2, 3, 4, 5, 6), 1000, 10_000, true).evaluate("6d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.d6_marvel, "red")); @@ -580,7 +580,7 @@ void getImageForRoll_marvelRed() throws ExpressionException, IOException { @Test void getImageForRoll_none_3dRedWhite() throws ExpressionException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000).evaluate("1d6 col 'none'"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1), 1000, 10_000, true).evaluate("1d6 col 'none'"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -589,7 +589,7 @@ void getImageForRoll_none_3dRedWhite() throws ExpressionException { @Test void getImageForRoll_noneAndVisible_3dRedWhite() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2), 1000).evaluate("1d6 col 'none' + 1d6"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(1, 2), 1000, 10_000, true).evaluate("1d6 col 'none' + 1d6"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, "red_and_white")); @@ -600,7 +600,7 @@ void getImageForRoll_noneAndVisible_3dRedWhite() throws ExpressionException, IOE @Test @Disabled void debug() throws ExpressionException, IOException { - List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 20, 99, 8, 12), 1000).evaluate("1d4 + 6d6 + 1d7 + 1d8 + 1d10 +1d12 + 1d20 + 1d100 + 1d8 col 'special' + 1d12 col 'special'"); + List rolls = new DiceEvaluator(new GivenNumberSupplier(4, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 20, 99, 8, 12), 1000, 10_000, true).evaluate("1d4 + 6d6 + 1d7 + 1d8 + 1d10 +1d12 + 1d20 + 1d100 + 1d8 col 'special' + 1d12 col 'special'"); Supplier res = underTest.getImageForRoll(rolls, new DiceStyleAndColor(DiceImageStyle.polyhedral_RdD, DiceImageStyle.polyhedral_RdD.getDefaultColor())); diff --git a/bot/src/test/resources/application-test.yaml b/bot/src/test/resources/application-test.yaml index bf3255ca..8076d4fa 100644 --- a/bot/src/test/resources/application-test.yaml +++ b/bot/src/test/resources/application-test.yaml @@ -5,4 +5,6 @@ command: minDelayBetweenButtonMessagesMs: 10 delayMessageDataDeletionMs: 10 fetch.delayMs: 0 - clear.messageDeleteDelay: 10 \ No newline at end of file + clear.messageDeleteDelay: 10 +diceEvaluator: + keepChildrenRolls: true \ No newline at end of file diff --git a/config.yaml b/config.yaml index 72e8e76a..f231a7ca 100644 --- a/config.yaml +++ b/config.yaml @@ -19,6 +19,8 @@ metric: diceEvaluator: maxNumberOfDice: 1000 cacheSize: 10000 + maxNumberOfElements: 10000 + keepChildrenRolls: true command: minDelayBetweenButtonMessagesMs: 1000 delayMessageDataDeletionMs: 10000