diff --git a/doc/games/dnd.md b/doc/games/dnd.md new file mode 100644 index 0000000000..51720987b9 --- /dev/null +++ b/doc/games/dnd.md @@ -0,0 +1,11 @@ +# Faker::Games::DnD + +```ruby +Faker::Games::DnD.race #=> "Dwarf" + +Faker::Games::DnD.klass #=> "Warlock" + +Faker::Games::DnD.background #=> "Urchin" + +Faker::Games::DnD.alignment #=> "Lawful Neutral" +``` diff --git a/lib/faker/games/dnd.rb b/lib/faker/games/dnd.rb new file mode 100644 index 0000000000..e9a19ac148 --- /dev/null +++ b/lib/faker/games/dnd.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module Faker + class Games + class DnD < Base + class << self + ## + # Produces the name of a race from Dungeons and Dragons (PHB). + # + # @return [String] + # + # @example + # Faker::Games::DnD.race #=> "Dwarf" + # + # @faker.version next + def species + fetch('dnd.species') + end + + ## + # Produces the name of a class from Dungeons and Dragons (PHB). + # + # @return [String] + # + # @example + # Faker::Games::DnD.klass #=> "Warlock" + # + # @faker.version next + def klass + fetch('dnd.klasses') + end + + ## + # Produces the name of a background from Dungeons and Dragons (PHB). + # + # @return [String] + # + # @example + # Faker::Games::DnD.background #=> "Urchin" + # + # @faker.version next + def background + fetch('dnd.backgrounds') + end + + ## + # Produces the name of an alignment from Dungeons and Dragons. + # + # @return [String] + # + # @example + # Faker::Games::DnD.alignment #=> "Lawful Neutral" + # + # @faker.version next + def alignment + fetch('dnd.alignments') + end + end + end + end +end diff --git a/lib/locales/en/dnd.yml b/lib/locales/en/dnd.yml new file mode 100644 index 0000000000..81e1e2a8cc --- /dev/null +++ b/lib/locales/en/dnd.yml @@ -0,0 +1,54 @@ +en: + faker: + dnd: + species: + - Dragonborn + - Dwarf + - Elf + - Gnome + - Half-Elf + - Halfling + - Half-Orc + - Human + - Tielfing + klasses: + - Barbarian + - Bard + - Cleric + - Druid + - Fighter + - Monk + - Paladin + - Ranger + - Rogue + - Sorcerer + - Warlock + - Wizard + backgrounds: + - Acolyte + - Charlatan + - Criminal + - Entertainer + - Folk Hero + - Gladiator + - Guild Artisan + - Guild Merchant + - Hermit + - Noble + - Outlander + - Pirate + - Sage + - Sailor + - Soldier + - Spy + - Urchin + alignments: + - Lawful Good + - Neutral Good + - Chaotic Good + - Lafwul Neutral + - Neutral + - Chaotic Neutral + - Lawful Evil + - Neutral Evil + - Chaotic Evil diff --git a/test/faker/games/test_dnd.rb b/test/faker/games/test_dnd.rb new file mode 100644 index 0000000000..b3eb9435c4 --- /dev/null +++ b/test/faker/games/test_dnd.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require_relative '../../test_helper' + +class TestFakerDnD < Test::Unit::TestCase + def setup + @tester = Faker::Games::DnD + end + + def test_species + assert @tester.species.match(/\w+/) + end + + def test_klass + assert @tester.klass.match(/\w+/) + end + + def test_background + assert @tester.background.match(/\w+/) + end + + def test_alignment + assert @tester.alignment.match(/\w+/) + end +end