Skip to content

Commit

Permalink
Merge pull request #113 from faker-ruby/master
Browse files Browse the repository at this point in the history
Update DnD generator (faker-ruby#2098)
  • Loading branch information
sanikkenway committed Aug 4, 2020
2 parents 11aed93 + c81da5a commit 17fda18
Show file tree
Hide file tree
Showing 4 changed files with 558 additions and 56 deletions.
16 changes: 13 additions & 3 deletions doc/games/dnd.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Faker::Games::DnD

```ruby
Faker::Games::DnD.species #=> "Dwarf"
Faker::Games::DnD.alignment #=> "Lawful Neutral"

Faker::Games::DnD.background #=> "Urchin"

Faker::Games::DnD.city #=> "Earthfast"

Faker::Games::DnD.klass #=> "Warlock"

Faker::Games::DnD.background #=> "Urchin"
Faker::Games::DnD.language #=> "Gnomish"

Faker::Games::DnD.alignment #=> "Lawful Neutral"
Faker::Games::DnD.melee_weapon #=> "Handaxe"

Faker::Games::DnD.monster #=> "Manticore"

Faker::Games::DnD.race #=> "Dwarf"

Faker::Games::DnD.ranged_weapon #=> "Shortbow"
```
103 changes: 89 additions & 14 deletions lib/faker/games/dnd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,42 @@ class Games
class DnD < Base
class << self
##
# Produces the name of a race from Dungeons and Dragons (PHB).
# Produces the name of an alignment from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.species #=> "Dwarf"
# Faker::Games::DnD.alignment #=> "Lawful Neutral"
#
# @faker.version 2.13.0
def species
fetch('dnd.species')
def alignment
fetch('dnd.alignments')
end

##
# Produces the name of a background from Dungeons and Dragons (PHB).
#
# @return [String]
#
# @example
# Faker::Games::DnD.background #=> "Urchin"
#
# @faker.version 2.13.0
def background
fetch('dnd.backgrounds')
end

##
# Produces the name of a city from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.city #=> "Earthfast"
#
# @faker.version next
def city
fetch('dnd.cities')
end

##
Expand All @@ -31,29 +57,78 @@ def klass
end

##
# Produces the name of a background from Dungeons and Dragons (PHB).
# Produces the name of a language from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.background #=> "Urchin"
# Faker::Games::DnD.language #=> "Gnomish"
#
# @faker.version 2.13.0
def background
fetch('dnd.backgrounds')
# @faker.version next
def language
fetch('dnd.languages')
end

##
# Produces the name of an alignment from Dungeons and Dragons.
# Produces the name of a melee weapon from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.alignment #=> "Lawful Neutral"
# Faker::Games::DnD.melee_weapon #=> "Handaxe"
#
# @faker.version 2.13.0
def alignment
fetch('dnd.alignments')
# @faker.version next
def melee_weapon
fetch('dnd.melee_weapons')
end

##
# Produces the name of a monster from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.monster #=> "Manticore"
#
# @faker.version next
def monster
fetch('dnd.monsters')
end

##
# Produces the name of a race from Dungeons and Dragons (PHB).
#
# @return [String]
#
# @example
# Faker::Games::DnD.races #=> "Dwarf"
#
# @faker.version next
def race
fetch('dnd.races')
end

##
# Produces the name of a ranged weapon from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.ranged_weapon #=> "Shortbow"
#
# @faker.version next
def ranged_weapon
fetch('dnd.ranged_weapons')
end

# This method is deprecated. The implementation will be removed in a near future release.
# Use `DnD.race` instead.
#
# @deprecated Use {#race} instead.
def species
warn '`DnD.species` is deprecated. Use `DnD.race` instead.'

super
end
end
end
Expand Down
Loading

0 comments on commit 17fda18

Please sign in to comment.