Skip to content

Commit dd356b0

Browse files
authored
add Cyberpunk Alias (#550)
1 parent fb36af2 commit dd356b0

11 files changed

Lines changed: 874 additions & 533 deletions

README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ See <<_channel_config>> for channel config
107107
|===
108108
| Alias Name | Alias Function
109109

110+
|`Cyberpunk Red - Alias` | roll with `cp`
110111
|`Dungeon & Dragons 5e - Alias` | roll advantage with `adv` and disadvantage with `dis`
111112
|`Fate - Alias` | roll four fate dice with `4dF`
112113
|`nWod / Chronicles of Darkness - Alias` | roll with `w` e.g. `8w`

bot/src/main/java/de/janno/discord/bot/command/help/RpgSystemCommandPreset.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ public static Config createConfig(PresetId presetId, Locale userLocale) {
169169
case HEROES_OF_CERULEA ->
170170
new CustomDiceConfig(null, ButtonHelper.parseString(I18n.getMessage("rpg.system.command.preset.HEROES_OF_CERULEA.expression", userLocale)),
171171
AnswerFormatType.without_expression, AnswerInteractionType.none, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_3d, DiceImageStyle.polyhedral_3d.getDefaultColor()), userLocale);
172-
//custom_parameter start expression: val('$fRoll',1d6 col 'white') val('$mRoll',1d6 col 'red') val('$rRoll',1d6 col 'white') val('$modi',{Modificator:-3<=>9}) if(('$fRoll' + '$mRoll' + '$rRoll'=) =? 3,val('$res','$fRoll' + '$mRoll' + '$rRoll'), val('$res','$fRoll' + replace('$mRoll',1,6) + '$rRoll')) val('$total', '$res' + '$modi'=) val('$resTotal','$res' _ ' = ' _ '$total') if('$mRoll'=?1, if(('$fRoll' + '$rRoll'=) =? 12,'$resTotal' _ ' Ultra Fantastic!', ('$fRoll' + '$rRoll'=) =? 2, '$resTotal' _ ' Botch!', '$resTotal' _' Fantastic!'), '$resTotal') answer_format: without_expression dice_image_style: d6_marvel_v2 dice_image_color: white
172+
//custom_parameter start expression: val('$fRoll',1d6 col 'white') val('$mRoll',1d6 col 'red') val('$rRoll',1d6 col 'white') val('$modi',{Modificator:-3<=>9}) if(('$fRoll' + '$mRoll' + '$rRoll'=) =? 3,val('$res','$fRoll' + '$mRoll' + '$rRoll'), val('$res','$fRoll' + replace('$mRoll',1,6) + '$rRoll')) val('$total', '$res' + '$modi'=) val('$resTotal','$res' _ ' = ' _ '$total') if('$mRoll'=?1, if(('$fRoll' + '$rRoll'=) =? 12,'$resTotal' _ ' Ultra Fantastic!', ('$fRoll' + '$rRoll'=) =? 2, '$resTotal' _ ' Botch!', '$resTotal' _' Fantastic!'), '$resTotal') answer_format: without_expression dice_image_style: d6_marvel_v2 dice_image_color: white answer_interaction: reroll
173173
case MARVEL ->
174-
new CustomParameterConfig(null, I18n.getMessage("rpg.system.command.preset.MARVEL.expression", userLocale), AnswerFormatType.without_expression, AnswerInteractionType.none, null, new DiceStyleAndColor(DiceImageStyle.d6_marvel_v2, D6MarvelV2.WHITE), userLocale);
174+
new CustomParameterConfig(null, I18n.getMessage("rpg.system.command.preset.MARVEL.expression", userLocale), AnswerFormatType.without_expression, AnswerInteractionType.reroll, null, new DiceStyleAndColor(DiceImageStyle.d6_marvel_v2, D6MarvelV2.WHITE), userLocale);
175175
case DND5_CALC2 ->
176176
new SumCustomSetConfig(null, ButtonHelper.parseString(I18n.getMessage("rpg.system.command.preset.DND5_CALC2.expression", userLocale)), true, true, false, null, null, AnswerFormatType.without_expression, AnswerInteractionType.none, null, new DiceStyleAndColor(DiceImageStyle.polyhedral_alies_v2, "blue_and_silver"), userLocale);
177177
case PBTA ->
@@ -235,6 +235,9 @@ public static Config createConfig(PresetId presetId, Locale userLocale) {
235235
// (?<numberOfDice>\\\\d+)b::val('diceRoll', if(${numberOfDice}=?0,2d6L1, ${numberOfDice}d6)) 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.')@${numberOfDice} Dice
236236
case BLADES_IN_THE_DARK_ALIAS ->
237237
new AliasConfig(ChannelConfigCommand.parseStringToMultiAliasList(I18n.getMessage("rpg.system.command.preset.BLADES_IN_THE_DARK_ALIAS.expression", userLocale)));
238+
case CYBERPUNK_RED_ALIAS ->
239+
new AliasConfig(ChannelConfigCommand.parseStringToMultiAliasList(I18n.getMessage("rpg.system.command.preset.CYBERPUNK_RED_ALIAS.expression", userLocale)));
240+
238241
};
239242
}
240243

@@ -349,7 +352,8 @@ public enum PresetId {
349352
IRONSWORN,
350353
SALVAGE_UNION,
351354
FALLOUT,
352-
FORBIDDEN_LANDS;
355+
FORBIDDEN_LANDS,
356+
CYBERPUNK_RED_ALIAS;
353357

354358
public static boolean isValid(String in) {
355359
return Arrays.stream(PresetId.values()).anyMatch(s -> s.name().equals(in));

bot/src/main/resources/botMessages.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ rpg.system.command.preset.OWOD_ALIAS.expression=(?<numberOfDice>\\\\d+)r(?<targe
341341
rpg.system.command.preset.SHADOWRUN_ALIAS.expression=(?<numberOfDice>\\\\d+)sr::val('roll',${numberOfDice}d6) concat('roll'>4c, if('roll'==1c >? 'roll'c/2,' - Glitch!'))@${numberOfDice}d6
342342
rpg.system.command.preset.SAVAGE_WORLDS_ALIAS.expression=r:d!!;sw(?<sides>\\\\d+)::1d!!${sides} + 1d!!6 k1@d${sides} Wildcard
343343
rpg.system.command.preset.BLADES_IN_THE_DARK_ALIAS.expression=(?<numberOfDice>\\\\d+)b::val('diceRoll', if(${numberOfDice}=?0,2d6L1, ${numberOfDice}d6)) 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.')@${numberOfDice} Dice
344+
rpg.system.command.preset.CYBERPUNK_RED_ALIAS.expression=cp:val('$roll', 1d!10) if('$roll'=?1, '$roll'-1d!10, '$roll')@Roll
344345
#Rpg presets names
345346
rpg.system.command.preset.FATE.name=Fate without Dice Images
346347
rpg.system.command.preset.FATE_IMAGE.name=Fate
@@ -400,6 +401,7 @@ rpg.system.command.preset.OWOD_ALIAS.name=oWod / Storyteller System - Alias
400401
rpg.system.command.preset.SHADOWRUN_ALIAS.name=Shadowrun - Alias
401402
rpg.system.command.preset.SAVAGE_WORLDS_ALIAS.name=Savage Worlds - Alias
402403
rpg.system.command.preset.BLADES_IN_THE_DARK_ALIAS.name=Blades in the Dark - Alias
404+
rpg.system.command.preset.CYBERPUNK_RED_ALIAS.name=Cyberpunk - Alias
403405
##Rpg presets aliases separated by ;
404406
rpg.system.command.preset.FATE.aliases=Fudge
405407
rpg.system.command.preset.FATE_IMAGE.aliases=Fudge
@@ -458,4 +460,5 @@ rpg.system.command.preset.NWOD_ALIAS.aliases=World of Darkness;Vampire the Requi
458460
rpg.system.command.preset.OWOD_ALIAS.aliases=World of Darkness;Vampire the Masquerade
459461
rpg.system.command.preset.SHADOWRUN_ALIAS.aliases=
460462
rpg.system.command.preset.SAVAGE_WORLDS_ALIAS.aliases=
461-
rpg.system.command.preset.BLADES_IN_THE_DARK_ALIAS.aliases=
463+
rpg.system.command.preset.BLADES_IN_THE_DARK_ALIAS.aliases=
464+
rpg.system.command.preset.CYBERPUNK_RED_ALIAS.aliases=
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package de.janno.discord.bot.command;
2+
3+
import java.util.UUID;
4+
import java.util.concurrent.atomic.AtomicInteger;
5+
import java.util.function.Supplier;
6+
7+
public final class IncrementingUUIDSupplier implements Supplier<UUID> {
8+
9+
private final AtomicInteger counter = new AtomicInteger(0);
10+
11+
private IncrementingUUIDSupplier() {
12+
}
13+
14+
public static Supplier<UUID> create() {
15+
return new IncrementingUUIDSupplier();
16+
}
17+
18+
@Override
19+
public UUID get() {
20+
return UUID.fromString("00000000-0000-0000-0001-%012d".formatted(counter.getAndIncrement()));
21+
}
22+
}

bot/src/test/java/de/janno/discord/bot/command/TestingUUIDSupplier.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

bot/src/test/java/de/janno/discord/bot/command/help/QuickstartCommandMockTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import de.janno.discord.bot.ButtonEventAdaptorMock;
66
import de.janno.discord.bot.I18n;
77
import de.janno.discord.bot.SlashEventAdaptorMock;
8+
import de.janno.discord.bot.command.IncrementingUUIDSupplier;
89
import de.janno.discord.bot.command.channelConfig.AliasHelper;
910
import de.janno.discord.bot.command.channelConfig.ChannelConfigCommand;
1011
import de.janno.discord.bot.command.customDice.CustomDiceCommand;
@@ -26,6 +27,7 @@
2627
import reactor.test.StepVerifier;
2728

2829
import java.util.*;
30+
import java.util.function.Supplier;
2931
import java.util.stream.Stream;
3032

3133
import static org.assertj.core.api.Assertions.assertThat;
@@ -146,9 +148,10 @@ void quickstartAlias_directRoll(RpgSystemCommandPreset.PresetId presetId, String
146148
void config2CommandString_slashCommand_firstButton(RpgSystemCommandPreset.PresetId presetId, Locale userLocale) {
147149
PersistenceManager persistenceManager = new PersistenceManagerImpl("jdbc:h2:mem:" + UUID.randomUUID(), null, null);
148150
CachingDiceEvaluator cachingDiceEvaluator = new CachingDiceEvaluator((minExcl, maxIncl) -> minExcl + 1);
149-
CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator);
150-
CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator);
151-
SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator);
151+
Supplier<UUID> uuidSupplier = IncrementingUUIDSupplier.create();
152+
CustomDiceCommand customDiceCommand = new CustomDiceCommand(persistenceManager, cachingDiceEvaluator, uuidSupplier);
153+
CustomParameterCommand customParameterCommand = new CustomParameterCommand(persistenceManager, cachingDiceEvaluator, uuidSupplier);
154+
SumCustomSetCommand sumCustomSetCommand = new SumCustomSetCommand(persistenceManager, cachingDiceEvaluator, uuidSupplier);
152155
ChannelConfigCommand channelConfigCommand = new ChannelConfigCommand(persistenceManager);
153156

154157
String command = RpgSystemCommandPreset.getCommandString(presetId, userLocale);
@@ -160,21 +163,21 @@ void config2CommandString_slashCommand_firstButton(RpgSystemCommandPreset.Preset
160163
.name("start")
161164
.options(getOptionsFromString(commandOptions, customDiceCommand))
162165
.build()), userLocale);
163-
slashRes = customDiceCommand.handleSlashCommandEvent(slashEventAdaptor, () -> UUID.fromString("00000000-0000-0000-0000-000000000000"), userLocale);
166+
slashRes = customDiceCommand.handleSlashCommandEvent(slashEventAdaptor, uuidSupplier, userLocale);
164167
} else if (command.startsWith("/custom_parameter start")) {
165168
String commandOptions = command.substring(23);
166169
slashEventAdaptor = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder()
167170
.name("start")
168171
.options(getOptionsFromString(commandOptions, customParameterCommand))
169172
.build()), userLocale);
170-
slashRes = customParameterCommand.handleSlashCommandEvent(slashEventAdaptor, () -> UUID.fromString("00000000-0000-0000-0000-000000000000"), userLocale);
173+
slashRes = customParameterCommand.handleSlashCommandEvent(slashEventAdaptor, uuidSupplier, userLocale);
171174
} else if (command.startsWith("/sum_custom_set start")) {
172175
String commandOptions = command.substring(21);
173176
slashEventAdaptor = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder()
174177
.name("start")
175178
.options(getOptionsFromString(commandOptions, sumCustomSetCommand))
176179
.build()), userLocale);
177-
slashRes = sumCustomSetCommand.handleSlashCommandEvent(slashEventAdaptor, () -> UUID.fromString("00000000-0000-0000-0000-000000000000"), userLocale);
180+
slashRes = sumCustomSetCommand.handleSlashCommandEvent(slashEventAdaptor, uuidSupplier, userLocale);
178181
} else if (command.startsWith("/channel_config alias multi_save aliases")) {
179182
String aliases = command.substring(41, command.indexOf("scope:") - 1);
180183
slashEventAdaptor = new SlashEventAdaptorMock(List.of(CommandInteractionOption.builder()
@@ -191,7 +194,7 @@ void config2CommandString_slashCommand_firstButton(RpgSystemCommandPreset.Preset
191194
.stringValue("all_users_in_this_channel")
192195
.build())
193196
.build()), userLocale);
194-
slashRes = channelConfigCommand.handleSlashCommandEvent(slashEventAdaptor, () -> UUID.fromString("00000000-0000-0000-0000-000000000000"), userLocale);
197+
slashRes = channelConfigCommand.handleSlashCommandEvent(slashEventAdaptor, uuidSupplier, userLocale);
195198
} else {
196199
throw new IllegalStateException("Unknown command for " + presetId);
197200
}

0 commit comments

Comments
 (0)