Skip to content

Commit

Permalink
Add Hero System
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Humblemonk committed Jun 16, 2024
1 parent c10b8d6 commit 0e6e430
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 99
Max: 150

# Offense count: 3
# Configuration parameters: CountBlocks.
Expand All @@ -46,7 +46,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 18
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 47
Max: 50

# Offense count: 5
# Configuration parameters: IgnoredMethods.
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Below are examples of the dice roll syntax.

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

`/roll nr 4d6` : Simplify roll output by not showing the results.

`/roll p 4d6` : Private roll results. Roll four six-sided dice and return the results privately.

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

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

Hero System 5th edition syntaxes:

`/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.

`/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

`/roll 3hsh` : Adds 11 to the number supplied, then subtracts the results of 3d6. e.g. 11 + 3 - 3d6

## Alias Rolls
Alias rolls are commands that are shorthand for a longer, more complex comand. They can also change what the dice faces appear as
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!
Expand Down
10 changes: 9 additions & 1 deletion dice_maiden.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dice bot for Discord
# Author: Humblemonk
# Version: 8.9.0
# Version: 8.10.0
# Copyright (c) 2017. All rights reserved.
# !/usr/bin/ruby
# If you wish to run a single instance of this bot, please follow the "Manual Install" section of the readme!
Expand Down Expand Up @@ -74,6 +74,11 @@
@dh = false
@godbound = false
@ed = false
@hsn = false
@hsk = false
@hsh = false
@no_result = false

@private_roll = false
@reroll_check = 0
@reroll_indefinite_check = 0
Expand Down Expand Up @@ -148,6 +153,9 @@
# Output aliasing
@tally = alias_output_pass(@tally)

# Does calculation for Hero System stuff, if necessary
hero_system_math if @hsn || @hsk

# Grab event user name, server name and timestamp for roll and log it
log_roll(event) if @launch_option == 'debug'

Expand Down
5 changes: 5 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 8.10.0 -2024-06-16
### Added
- Hero system support
- no result modifier

## 8.9.0 - 2024-06-15
### Added
- Added dnd alias rolls for attack , skill checks and saving throws
Expand Down
72 changes: 69 additions & 3 deletions src/dice_maiden_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def alias_input_pass(input)
[/\bdndstats\b/i, 'DnD Stat-roll', /\b(dndstats)\b/i, '6 4d6 k3'], # DnD character stats - 4d6 drop lowest 6 times
[/\battack\b/i, 'DnD attack roll', /\b(attack)\b/i, '1d20'], # DnD attack roll
[/\bskill\b/i, 'DnD skill check', /\b(skill)\b/i, '1d20'], # DnD skill check
[/\bsave\b/i, 'DnD saving throw', /\b(attack)\b/i, '1d20'] # DnD saving throw
[/\bsave\b/i, 'DnD saving throw', /\b(attack)\b/i, '1d20'], # DnD saving throw
[/\b\d+hsn\b/i, 'Hero System Normal', /\b(\d+)hsn\b/i, 'hsn \\1d6 nr'], # Hero System 5e Normal Damage
[/\b\d+hsk\d*\b/i, 'Hero System Killing', /\b(\d+)hsk(\d*)\b/i, 'hsk\\2 \\1d6 nr'], # Hero System 5e Killing Damage
[/\b\d+hsh\b/i, 'Hero System to Hit', /\b(\d+)hsh\b/i, 'hsh 11+\\1 -3d6 nr'] # Hero System 5e to Hit
]

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

new_tally = roll_tally
Expand Down Expand Up @@ -708,6 +712,37 @@ def check_roll_modes
@input.sub!('gb', '')
end

# check for Hero System 5e normal damage mode for roll
if @input.match(/\s?(hsn)\s/i)
@hsn = true
@input.sub!('hsn', '')
end

# check for Hero System 5e killing damage mode for roll
if @input.match(/\s?(hsk)\s/i)
@hsk = true
if @input.match(/hsk\d+/i)
multiplier_string = @input.scan(/(hsk)\d+/i)
@hsk_multiplier_modifier = multiplier_string.scan(/\d+/).to_i
@input.sub!(/hsk\d+/i, '')
else
@hsk_multiplier_modifier = 0
@input.sub!('hsk', '')
end
end

# check for Hero System 5e to hit mode for roll
if @input.match(/\s?(hsh)\s?/i)
@hsh = true
@input.sub!('hsh', '')
end

# check for no total mode for roll
if @input.match(/\s?(nr)\s/i)
@no_result = true
@input.sub!('nr', '')
end

@ed = true if @input.match(/^\s?(ed\d+)/i) || @input.match(/^\s?(ed4e\d+)/i)
end

Expand All @@ -727,13 +762,44 @@ def roll_sets_valid(event)
end
end

def hero_system_math
if @hsn
@hsn_body = 0
@hsn_body += @tally.scan(/\+2\D/).count
@hsn_body *= 2
@hsn_body += @tally.scan(/\+1\D/).count
@hsn_stun = @dice_result.scan(/\d+/)
end

if @hsk
@hsk_body = @dice_result.scan(/\d+/).to_i
@hsk_stun_roll = DiceBag::Roll.new('1d6').result.total
@hsk_multiplier = @hsk_stun_roll - 1 + @hsk_multiplier_modifier
if @hsk_multiplier.zero?
@hsk_multiplier = 1
end
@hsk_stun = @hsk_body * @hsk_multiplier
end
end

def build_response
response = "#{@user} Request: `[#{@roll_request.strip}]`"
unless @simple_output
response += " Roll: `#{@tally}`"
response += " Rerolls: `#{@reroll_count}`" if @show_rerolls
end
response += " #{@dice_result}"
response += " #{@dice_result}" unless @no_result
if @hsn
response += " Body: #{@hsn_body}, Stun:#{@hsn_stun}"
end

if @hsk
response += " Body: #{@hsk_body}, Stun Multiplier: #{@hsk_multiplier}, Stun: #{@hsk_stun}"
end

if @hsh
response += " Hits DCV #{@dice_result.scan(/\d+/)}"
end
response += " Reason: `#{@comment}`" if @has_comment
response
end

0 comments on commit 0e6e430

Please sign in to comment.