Skip to content

Commit

Permalink
Add support for godbound damage chart
Browse files Browse the repository at this point in the history
This commit adds support for rolling damage against godbounds damage
chart. Thanks to csheepy for putting the legwork in here before the
slash command update
  • Loading branch information
Humblemonk committed Jun 15, 2024
1 parent 8663c80 commit 64101e7
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Style/FrozenStringLiteralComment:
- 'src/dice_maiden_logic.rb'
- 'src/earthdawn_logic.rb'
- 'tools/dice_maiden_quota.rb'
- 'godbound_logic.rb'

# Offense count: 13
# Configuration parameters: AllowedVariables.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ Dark Heresy 2nd edition syntaxes:

`/roll dh 4d10` : Roll four ten-sided dice for dark heresy 2nd edition. If your roll contains a natural 10, you will be prompted with a righteous fury notification!

Godbound system:

`/roll gb 1d12+4` : Roll 1d12, add 4, then compare against the game's damage chart

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

## 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
1 change: 1 addition & 0 deletions dice_maiden.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
@simple_output = false
@wng = false
@dh = false
@godbound = false
@ed = false
@private_roll = false
@reroll_check = 0
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 8.9.0 - 2024-06-15
### Added
- Added dnd alias rolls for attack , skill checks and saving throws
- Added godbound dice roll system

## 8.8.1 - 2024-04-07
### Added
Expand Down
18 changes: 18 additions & 0 deletions src/dice_maiden_logic.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# All bot logic that is not handled by Dice-Bag lives here
require_relative 'godbound_logic'

# Returns an input string after it's been put through the aliases
def alias_input_pass(input)
Expand Down Expand Up @@ -215,6 +216,8 @@ def process_rpn_token_queue(input_queue)

raise 'Extra numbers detected!' if output_stack.length > 1

return godbound_damage_conversion(output_stack[0]) if @godbound == true # allow stuff like 1d12+4 to be summed before converting

output_stack[0] # There can be only one!
end

Expand Down Expand Up @@ -269,6 +272,15 @@ def process_roll_token(_event, token)
end
@tally += roll_tally

if @godbound == true
t = dice_roll.result.sections[0].tally
if t.length > 1
# for something like 5d8, just add it up and don't process afterwards
@godbound = false
return godbound_damage_total(t)
end
end

token_total
end

Expand Down Expand Up @@ -690,6 +702,12 @@ def check_roll_modes
@input.sub!('p', '')
end

# check for godbound game mode roll
if @input.match(/\s?(gb)\s/i)
@godbound = true
@input.sub!('gb', '')
end

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

Expand Down
22 changes: 22 additions & 0 deletions src/godbound_logic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

# godbound roll logic

def godbound_damage_total(results)
results.reduce(0) do |sum, n|
sum + godbound_damage_conversion(n)
end
end

def godbound_damage_conversion(raw_number)
case [raw_number, 10].min
when 10
4
when 6..9
2
when 2..5
1
when 1
0
end
end

0 comments on commit 64101e7

Please sign in to comment.