Skip to content

Commit

Permalink
Add names to DnD generator (#2735)
Browse files Browse the repository at this point in the history
- Add first name, last name, full name, first name with title
- Remove deprecated species method
  • Loading branch information
dollerbill authored Mar 23, 2023
1 parent 5384338 commit 1a3f471
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 8 deletions.
8 changes: 8 additions & 0 deletions doc/games/dnd.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ Faker::Games::DnD.background #=> "Urchin"

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

Faker::Games::DnD.first_name #=> "Celestine"

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

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

Faker::Games::DnD.last_name #=> "Nightbreeze"

Faker::Games::DnD.melee_weapon #=> "Handaxe"

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

Faker::Games::DnD.name #=> "Drust Silverveil"

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

Faker::Games::DnD.ranged_weapon #=> "Shortbow"

Faker::Games::DnD.title_name #=> "Selene the Dreamer"
```
56 changes: 49 additions & 7 deletions lib/faker/games/dnd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ def city
fetch('dnd.cities')
end

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

##
# Produces the name of a class from Dungeons and Dragons (PHB).
#
Expand All @@ -69,6 +82,19 @@ def language
fetch('dnd.languages')
end

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

##
# Produces the name of a melee weapon from Dungeons and Dragons.
#
Expand All @@ -95,6 +121,19 @@ def monster
fetch('dnd.monsters')
end

##
# Produces a full name from Dungeons and Dragons.
#
# @return [String]
#
# @example
# Faker::Games::DnD.name #=> "Drakon Blackthorn"
#
# @faker.version next
def name
"#{fetch('dnd.name.first_name')} #{fetch('dnd.name.last_name')}"
end

##
# Produces the name of a race from Dungeons and Dragons (PHB).
#
Expand All @@ -121,14 +160,17 @@ 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.
##
# Produces a last name from Dungeons and Dragons.
#
# @deprecated Use {#race} instead.
def species
warn '`DnD.species` is deprecated. Use `DnD.race` instead.'

super
# @return [String]
#
# @example
# Faker::Games::DnD.title_name #=> "Corvus the Cunning"
#
# @faker.version next
def title_name
"#{fetch('dnd.name.first_name')} #{fetch('dnd.name.title')}"
end
end
end
Expand Down
187 changes: 186 additions & 1 deletion lib/locales/en/dnd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,191 @@ en:
- Verdan
- Warforged
- Yuan-Ti
name:
first_name:
- Aeliana
- Alaric
- Aldric
- Alessia
- Alistair
- Althea
- Amonar
- Andros
- Anya
- Aria
- Ariadne
- Ariella
- Azarion
- Baelgor
- Baelin
- Belmorn
- Brondar
- Caelum
- Calista
- Cassandra
- Celestia
- Celestine
- Corvus
- Delara
- Drakon
- Drust
- Eamon
- Eilonwy
- Elara
- Eldric
- Elowen
- Elyria
- Emeric
- Faelina
- Fionna
- Freya
- Galen
- Garrick
- Gavric
- Gideon
- Gruffudd
- Illiana
- Isolde
- Kael
- Kael'thas
- Kaela
- Kaelis
- Kaldris
- Kethric
- Kyros
- Leilani
- Liora
- Lorimar
- Lucius
- Lysandra
- Lysara
- Maelis
- Magnus
- Marik
- Melisandra
- Nymeria
- Nymira
- Oriana
- Orianna
- Osric
- Ragnor
- Rendal
- Rhovaniel
- Rurik
- Selene
- Seraphina
- Seraphine
- Seren
- Sylvaria
- Taryn
- Thalia
- Thane
- Tharivol
- Thorgrim
- Throrin
- Tordek
- Torvald
- Uldar
- Ulfgar
- Valthor
- Vespera
- Xander
- Xanthe
- Ygritte
- Yondalla
- Zara
- Zarathos
- Zephyra
- Zoltan
last_name:
- Axebreaker
- Blackthorn
- Brightsong
- Dawnbringer
- Dreamweaver
- Earthshaker
- Fireheart
- Ironfoot
- Ironheart
- Leafwhisper
- Lightbringer
- Lightfoot
- Mistwalker
- Moonfall
- Moonshadow
- Moonsong
- Moonwhisper
- Nightbreeze
- Nightshade
- Nightstalker
- Ravenscar
- Ravenshadow
- Shadowbane
- Shadowdancer
- Silverhand
- Silverveil
- Starborn
- Starweaver
- Starwhisper
- Stonewarden
- Stormborn
- Stormbringer
- Stormcloak
- Stormrider
- Sunweaver
- Swiftwind
- Wildheart
- Willowbrook
- Winddancer
title:
- the Arcane
- the Bard
- the Beautiful
- the Bold
- the Brave
- the Clever
- the Cunning
- the Defender
- the Dreamer
- the Elegant
- the Enchanted
- the Enchanter
- the Enchantress
- the Fair
- the Fearless
- the Fierce
- the Gentle
- the Graceful
- the Healer
- the Huntress
- the Illusionist
- the Just
- the Kind
- the Loyal
- the Mighty
- the Moonlit
- the Poet
- the Protector
- the Radiant
- the Relentless
- the Resolute
- the Scribe
- the Seeker
- the Silent
- the Slayer
- the Stalwart
- the Stoic
- the Strong
- the Swift
- the Unbreakable
- the Unbroken
- the Unconquered
- the Unseen
- the Unyielding
- the Vindicator
- the Wanderer
- the Wild
- the Wise
ranged_weapons:
- Blowgun
- Boomerang
Expand All @@ -448,4 +633,4 @@ en:
- Longbow
- Net
- Shortbow
- Sling
- Sling
16 changes: 16 additions & 0 deletions test/faker/games/test_faker_dnd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def test_city
assert_match(/\w+/, @tester.city)
end

def test_first_name
assert_match(/\w+/, @tester.first_name)
end

def test_klass
assert_match(/\w+/, @tester.klass)
end
Expand All @@ -27,6 +31,10 @@ def test_language
assert_match(/\w+/, @tester.language)
end

def test_last_name
assert_match(/\w+/, @tester.last_name)
end

def test_melee_weapon
assert_match(/\w+/, @tester.melee_weapon)
end
Expand All @@ -35,11 +43,19 @@ def test_monster
assert_match(/\w+/, @tester.monster)
end

def test_name
assert_match(/\w+/, @tester.name)
end

def test_race
assert_match(/\w+/, @tester.race)
end

def test_ranged_weapon
assert_match(/\w+/, @tester.ranged_weapon)
end

def test_title_name
assert_match(/\w+/, @tester.title_name)
end
end

0 comments on commit 1a3f471

Please sign in to comment.