From ebcd4ca9b5646681a4d6978f6e3c118d56a63421 Mon Sep 17 00:00:00 2001 From: Billy Cropley Date: Thu, 23 Mar 2023 00:43:34 -0700 Subject: [PATCH] Add names to DnD generator - Add first name, last name, full name, first name with title - Remove deprecated species method --- doc/games/dnd.md | 8 ++ lib/faker/games/dnd.rb | 56 +++++++-- lib/locales/en/dnd.yml | 187 ++++++++++++++++++++++++++++- test/faker/games/test_faker_dnd.rb | 16 +++ 4 files changed, 259 insertions(+), 8 deletions(-) diff --git a/doc/games/dnd.md b/doc/games/dnd.md index 86ebeb5908..cbd3c41452 100644 --- a/doc/games/dnd.md +++ b/doc/games/dnd.md @@ -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" ``` diff --git a/lib/faker/games/dnd.rb b/lib/faker/games/dnd.rb index d3c97d5252..2bb87ee0f9 100644 --- a/lib/faker/games/dnd.rb +++ b/lib/faker/games/dnd.rb @@ -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). # @@ -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. # @@ -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). # @@ -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 diff --git a/lib/locales/en/dnd.yml b/lib/locales/en/dnd.yml index 154df94b5b..7283e31e4a 100644 --- a/lib/locales/en/dnd.yml +++ b/lib/locales/en/dnd.yml @@ -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 @@ -448,4 +633,4 @@ en: - Longbow - Net - Shortbow - - Sling \ No newline at end of file + - Sling diff --git a/test/faker/games/test_faker_dnd.rb b/test/faker/games/test_faker_dnd.rb index f9ce84b0f0..333cdec9ca 100644 --- a/test/faker/games/test_faker_dnd.rb +++ b/test/faker/games/test_faker_dnd.rb @@ -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 @@ -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 @@ -35,6 +43,10 @@ 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 @@ -42,4 +54,8 @@ def test_race def test_ranged_weapon assert_match(/\w+/, @tester.ranged_weapon) end + + def test_title_name + assert_match(/\w+/, @tester.title_name) + end end