Skip to content

Commit

Permalink
raise exception for poorly formatted dice
Browse files Browse the repository at this point in the history
This minor change should raise an exception when certain dice rolls
start with a 0.

closes #177
  • Loading branch information
Humblemonk committed Apr 4, 2024
1 parent acdf353 commit e6ab992
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 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.7.1
# Version: 8.7.2
# 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
4 changes: 4 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 8.7.2 - 2024-04-03
### Added
- Introduced logic to better handle poorly crafted dice rolls

## 8.7.1 - 2024-03-28
### Added
- Removed rest client API functionality
Expand Down
3 changes: 3 additions & 0 deletions src/dice_maiden_logic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def convert_input_to_rpn_queue(event, input)
while input_queue.length > 0
input_queue_peek = input_queue.last

# raise an error if input queue starts with a 0
raise 'Invalid dice format!' if input_queue_peek.match?(/\A0/)

if input_queue_peek.match?(/\b\d+\b/) # If constant in string form
output_queue.prepend(Integer(input_queue.pop))

Expand Down

0 comments on commit e6ab992

Please sign in to comment.