Skip to content

Commit 0e6e430

Browse files
committed
Add Hero System
Thanks to @ThatGuyWhatsMadeofCheese for the heavy lifting here. rewriting his original pull request to get it up to slash command stands and fix a few errors. This commit adds support for the hero system. This commit also adds support for a no total mode that prints the tally but no the results. resolves #46
1 parent c10b8d6 commit 0e6e430

File tree

5 files changed

+95
-6
lines changed

5 files changed

+95
-6
lines changed

.rubocop_todo.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Metrics/AbcSize:
3131
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
3232
# IgnoredMethods: refine
3333
Metrics/BlockLength:
34-
Max: 99
34+
Max: 150
3535

3636
# Offense count: 3
3737
# Configuration parameters: CountBlocks.
@@ -46,7 +46,7 @@ Metrics/CyclomaticComplexity:
4646
# Offense count: 18
4747
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
4848
Metrics/MethodLength:
49-
Max: 47
49+
Max: 50
5050

5151
# Offense count: 5
5252
# Configuration parameters: IgnoredMethods.

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Below are examples of the dice roll syntax.
111111

112112
`/roll s 4d6` : Simplify roll output by not showing the tally.
113113

114+
`/roll nr 4d6` : Simplify roll output by not showing the results.
115+
114116
`/roll p 4d6` : Private roll results. Roll four six-sided dice and return the results privately.
115117

116118
`/roll 4d6 ! unsort` or `!roll ul 4d6`: Roll four six-sided dice and unsort the tally.
@@ -146,6 +148,14 @@ Godbound system syntaxes:
146148

147149
`/roll gb 8d8` : Roll 8d8, compare each die against the game's damage chart, and then sum
148150

151+
Hero System 5th edition syntaxes:
152+
153+
`/roll 2hsn` : Roll 2 six-sided dice for normal damage. In the tally, body modifiers are given in parentheses. Both body and stun are calculated.
154+
155+
`/roll 5hsk1 +1d3` : Roll 5 1/2 six-sided dice for killing damage, with a plus one stun modifier. Stun modifier defaults to zero, meaning a roll of 1d6 -1, if no value is given. For partial dice, use +1 for a single pip, +1d3 for a half d6, and a whole d6 can either be added to the first number, or at the end with the partial dice. Calculates body, stun multiplier, and stun
156+
157+
`/roll 3hsh` : Adds 11 to the number supplied, then subtracts the results of 3d6. e.g. 11 + 3 - 3d6
158+
149159
## Alias Rolls
150160
Alias rolls are commands that are shorthand for a longer, more complex comand. They can also change what the dice faces appear as
151161
in most cases. Below is the complete list of aliases , with example rolls, currently supported by Dice Maiden. Have a game system that you want turned into an alias? Create an issue on github to get it added to this list!

dice_maiden.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dice bot for Discord
22
# Author: Humblemonk
3-
# Version: 8.9.0
3+
# Version: 8.10.0
44
# Copyright (c) 2017. All rights reserved.
55
# !/usr/bin/ruby
66
# If you wish to run a single instance of this bot, please follow the "Manual Install" section of the readme!
@@ -74,6 +74,11 @@
7474
@dh = false
7575
@godbound = false
7676
@ed = false
77+
@hsn = false
78+
@hsk = false
79+
@hsh = false
80+
@no_result = false
81+
7782
@private_roll = false
7883
@reroll_check = 0
7984
@reroll_indefinite_check = 0
@@ -148,6 +153,9 @@
148153
# Output aliasing
149154
@tally = alias_output_pass(@tally)
150155

156+
# Does calculation for Hero System stuff, if necessary
157+
hero_system_math if @hsn || @hsk
158+
151159
# Grab event user name, server name and timestamp for roll and log it
152160
log_roll(event) if @launch_option == 'debug'
153161

doc/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 8.10.0 -2024-06-16
2+
### Added
3+
- Hero system support
4+
- no result modifier
5+
16
## 8.9.0 - 2024-06-15
27
### Added
38
- Added dnd alias rolls for attack , skill checks and saving throws

src/dice_maiden_logic.rb

+69-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def alias_input_pass(input)
2828
[/\bdndstats\b/i, 'DnD Stat-roll', /\b(dndstats)\b/i, '6 4d6 k3'], # DnD character stats - 4d6 drop lowest 6 times
2929
[/\battack\b/i, 'DnD attack roll', /\b(attack)\b/i, '1d20'], # DnD attack roll
3030
[/\bskill\b/i, 'DnD skill check', /\b(skill)\b/i, '1d20'], # DnD skill check
31-
[/\bsave\b/i, 'DnD saving throw', /\b(attack)\b/i, '1d20'] # DnD saving throw
31+
[/\bsave\b/i, 'DnD saving throw', /\b(attack)\b/i, '1d20'], # DnD saving throw
32+
[/\b\d+hsn\b/i, 'Hero System Normal', /\b(\d+)hsn\b/i, 'hsn \\1d6 nr'], # Hero System 5e Normal Damage
33+
[/\b\d+hsk\d*\b/i, 'Hero System Killing', /\b(\d+)hsk(\d*)\b/i, 'hsk\\2 \\1d6 nr'], # Hero System 5e Killing Damage
34+
[/\b\d+hsh\b/i, 'Hero System to Hit', /\b(\d+)hsh\b/i, 'hsh 11+\\1 -3d6 nr'] # Hero System 5e to Hit
3235
]
3336

3437
@alias_types = []
@@ -50,7 +53,8 @@ def alias_output_pass(roll_tally)
5053
# Each entry is formatted "Alias Name":[[]/gsub replacement regex/, "replace with string", etc]
5154
# Not all aliases will have an output hash
5255
alias_output_hash = {
53-
'Fudge' => [[/\b1\b/, '-'], [/\b2\b/, ' '], [/\b3\b/, '+']]
56+
'Fudge' => [[/\b1\b/, '-'], [/\b2\b/, ' '], [/\b3\b/, '+']],
57+
'Hero System Normal' => [[/\b1\b/, '1 (+0)'], [/\b([2-5])\b/, '\\1 (+1)'], [/\b6\b/, '6 (+2)']]
5458
}
5559

5660
new_tally = roll_tally
@@ -708,6 +712,37 @@ def check_roll_modes
708712
@input.sub!('gb', '')
709713
end
710714

715+
# check for Hero System 5e normal damage mode for roll
716+
if @input.match(/\s?(hsn)\s/i)
717+
@hsn = true
718+
@input.sub!('hsn', '')
719+
end
720+
721+
# check for Hero System 5e killing damage mode for roll
722+
if @input.match(/\s?(hsk)\s/i)
723+
@hsk = true
724+
if @input.match(/hsk\d+/i)
725+
multiplier_string = @input.scan(/(hsk)\d+/i)
726+
@hsk_multiplier_modifier = multiplier_string.scan(/\d+/).to_i
727+
@input.sub!(/hsk\d+/i, '')
728+
else
729+
@hsk_multiplier_modifier = 0
730+
@input.sub!('hsk', '')
731+
end
732+
end
733+
734+
# check for Hero System 5e to hit mode for roll
735+
if @input.match(/\s?(hsh)\s?/i)
736+
@hsh = true
737+
@input.sub!('hsh', '')
738+
end
739+
740+
# check for no total mode for roll
741+
if @input.match(/\s?(nr)\s/i)
742+
@no_result = true
743+
@input.sub!('nr', '')
744+
end
745+
711746
@ed = true if @input.match(/^\s?(ed\d+)/i) || @input.match(/^\s?(ed4e\d+)/i)
712747
end
713748

@@ -727,13 +762,44 @@ def roll_sets_valid(event)
727762
end
728763
end
729764

765+
def hero_system_math
766+
if @hsn
767+
@hsn_body = 0
768+
@hsn_body += @tally.scan(/\+2\D/).count
769+
@hsn_body *= 2
770+
@hsn_body += @tally.scan(/\+1\D/).count
771+
@hsn_stun = @dice_result.scan(/\d+/)
772+
end
773+
774+
if @hsk
775+
@hsk_body = @dice_result.scan(/\d+/).to_i
776+
@hsk_stun_roll = DiceBag::Roll.new('1d6').result.total
777+
@hsk_multiplier = @hsk_stun_roll - 1 + @hsk_multiplier_modifier
778+
if @hsk_multiplier.zero?
779+
@hsk_multiplier = 1
780+
end
781+
@hsk_stun = @hsk_body * @hsk_multiplier
782+
end
783+
end
784+
730785
def build_response
731786
response = "#{@user} Request: `[#{@roll_request.strip}]`"
732787
unless @simple_output
733788
response += " Roll: `#{@tally}`"
734789
response += " Rerolls: `#{@reroll_count}`" if @show_rerolls
735790
end
736-
response += " #{@dice_result}"
791+
response += " #{@dice_result}" unless @no_result
792+
if @hsn
793+
response += " Body: #{@hsn_body}, Stun:#{@hsn_stun}"
794+
end
795+
796+
if @hsk
797+
response += " Body: #{@hsk_body}, Stun Multiplier: #{@hsk_multiplier}, Stun: #{@hsk_stun}"
798+
end
799+
800+
if @hsh
801+
response += " Hits DCV #{@dice_result.scan(/\d+/)}"
802+
end
737803
response += " Reason: `#{@comment}`" if @has_comment
738804
response
739805
end

0 commit comments

Comments
 (0)