Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nereare committed Jun 27, 2024
1 parent 05b3cc4 commit 0d83e2f
Show file tree
Hide file tree
Showing 6 changed files with 703 additions and 187 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0] - 2024-06-27
### Added
- Random damage generator.
- Generator of Robe of Useful Items's items.
## Changed
- Fully refurbished DDB methods, creating:
- Attacks generator;
- Traits generator; and
- Legendary Actions generator.

## [1.1.2] - 2022-05-12
### Changed
Expand All @@ -33,7 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Recharge generation; and
- General generation.

[Unreleased]: https://github.com/Nereare/DDB-Rollable/compare/v1.1.2..HEAD
[Unreleased]: https://github.com/Nereare/DDB-Rollable/compare/v2.0.0..HEAD
[2.0.0]: https://github.com/Nereare/DDB-Rollable/compare/v1.1.2...v2.0.0
[1.1.2]: https://github.com/Nereare/DDB-Rollable/compare/v1.1.0...v1.1.2
[1.1.0]: https://github.com/Nereare/DDB-Rollable/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/Nereare/DDB-Rollable/releases/tag/v1.0.0
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

source "https://rubygems.org"

gem "humanize"
gem "clipboard"
gem "ffi", platforms: %i[mingw x64_mingw mswin mri]
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ GEM
specs:
clipboard (1.3.6)
ffi (1.17.0-x64-mingw-ucrt)
humanize (3.1.0)

PLATFORMS
x64-mingw-ucrt

DEPENDENCIES
clipboard
ffi
humanize

BUNDLED WITH
2.3.16
191 changes: 191 additions & 0 deletions classic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Classic methods for generating DDB rollables
def classic_ddb
# Final output format, with its two major fields:
final = "[rollable]OUTPUT;JSON[/rollable]"
# The JSON part of the final output, with its two mandatory parameters:
json = "{\"diceNotation\":\"DICE\",\"rollType\":\"TYPE\"OTHER}"
# An array to contain any other parameter of the JSON part:
other = []
# The rollAction parameter:
action = "\"rollAction\":\"ACTION_NAME\""
# The rollDamageType parameter:
damage = "\"rollDamageType\":\"DAMAGE_TYPE\""

# The supported rollType's:
roll_types = [
["roll", "Used for a generic dice roll"],
["to hit", "Used for attack rolls"],
["damage", "Used for damage rolls. Should include rollDamageType when using this"],
["heal", "Used for healing"],
["spell", "Can be used to differentiate a spell attack from a regular attack roll"],
["save", "Used for saving throws"],
["check", "Used for profiency checks (skills)"],
["recharge", "Used for recharging abilities"]
]
# The supported rollDamageType's:
damage_types = [
"Acid",
"Bludgeoning",
"Cold",
"Fire",
"Force",
"Lightning",
"Necrotic",
"Piercing",
"Poison",
"Psychic",
"Radiant",
"Slashing",
"Thunder"
]

puts "What do you wish to generate? (Choose from the below)"
puts " 1. To hit;"
puts " 2. Damage (default);"
puts " 3. Heal;"
puts " 4. Recharge; or"
puts " 5. General roll."

case gets.to_i
when 1
puts "What is the attack bonus?"
ab = gets.to_i
sign = (ab < 0) ? "-" : "+"

puts "Is there a name for this attack? (Leave blank if not)"
name = gets.strip
if name
action.sub!(/ACTION_NAME/, name)
json.sub!(/OTHER/, "," + action)
end

puts "Is the attack a magical one? (y/N)"
if gets.strip.downcase == "y"
json.sub!(/TYPE/, "spell")
else
json.sub!(/TYPE/, "to hit")
end

json.sub!(/DICE/, "1d20" + sign + ab.abs.to_s)

final.sub!(/OUTPUT/, sign + ab.abs.to_s)
.sub!(/JSON/, json)
when 3
puts "What is the healing amount? (Use the format NdN+/-N, where N is a natural number)"
heal = gets.downcase.gsub!(/\s/, "")

json.sub!(/TYPE/, "heal")

puts "Is there a name for this action? (Leave blank if not)"
name = gets.strip
if name
action.sub!(/ACTION_NAME/, name)
json.sub!(/OTHER/, "," + action)
end

json.sub!(/DICE/, heal)

final.sub!(/OUTPUT/, heal)
.sub!(/JSON/, json)
when 4
puts "The recharge uses 1d6? (Y/n)"
if gets.strip.downcase == "n"
puts "What is roll for this recharging? (Use the format NdN+/-N, where N is a natural number)"
roll = gets.downcase.gsub!(/\s/, "")
else
roll = "1d6"
end

puts "The recharging occurs from..."
min = gets.to_i
puts "...to..."
max = gets.to_i

text = "Recharge #{min}-#{max}"

json.sub!(/TYPE/, "recharge")

puts "Is there a name for the action to be recharged? (Leave blank if not)"
name = gets.strip
if name
action.sub!(/ACTION_NAME/, name)
json.sub!(/OTHER/, "," + action)
end

json.sub!(/DICE/, roll)

final.sub!(/OUTPUT/, text)
.sub!(/JSON/, json)
when 5
puts "What is the dice roll? (Use the format NdN+/-N, where N is a natural number)"
roll = gets.downcase.gsub!(/\s/, "")
json.sub!(/DICE/, roll)

puts "Is the text to be shown the dice roll above? (Y/n)"
if gets.strip.downcase == "n"
puts "What is the text to be shown?"
final.sub!(/OUTPUT/, gets.strip)
else
final.sub!(/OUTPUT/, roll)
end

puts "What is the type of roll? (Choose the number)"
roll_types.each_with_index do |v, i|
puts " #{i.to_s.rjust(2,"0")}. #{v[0]} (#{v[1]})"
end
index = gets.to_i
json.sub!(/TYPE/, roll_types[index][0])

puts "Is there a name for this roll? (Leave blank if not)"
name = gets.strip
if name
action.sub!(/ACTION_NAME/, name)
other.push action
end

notice = (index == 2) ? "A damage type is MADATORY when rollType is \"damage\"." : "Optional, and may not be even shown."
puts "Is the a damage type associated? #{notice} (Y/n)"
if gets.strip.downcase != "n"
puts "What is the type of damage dealt by this attack? (Choose the number)"
damage_types.each_with_index do |v, i|
puts " #{i.to_s.rjust(2,"0")}. #{v}"
end
index = gets.to_i
damage.sub!(/DAMAGE_TYPE/, damage_types[index])
other.push damage
end

json.sub!(/OTHER/, "," + other.join(","))
final.sub!(/JSON/, json)
else
puts "What is the damage? (Use the format NdN+/-N, where N is a natural number)"
dmg = gets.downcase.gsub!(/\s/, "")

json.sub!(/TYPE/, "damage")

puts "Is there a name for this attack? (Leave blank if not)"
name = gets.strip
if name
action.sub!(/ACTION_NAME/, name)
other.push action
end

puts "What is the type of damage dealt by this attack? (Choose the number)"
damage_types.each_with_index do |v, i|
puts " #{i.to_s.rjust(2,"0")}. #{v}"
end
index = gets.to_i
damage.sub!(/DAMAGE_TYPE/, damage_types[index])
other.push damage

json.sub!(/DICE/, dmg)
json.sub!(/OTHER/, "," + other.join(","))

final.sub!(/OUTPUT/, dmg)
final.sub!(/JSON/, json)
end

puts "Final output: " + final
Clipboard.copy(final)
puts "Copied to clipboard!"
end
Loading

0 comments on commit 0d83e2f

Please sign in to comment.