Skip to content

WIP on cleaning up proof of concept #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/services/attributes/character/age_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Character
class AgeField < Field
field_key :age

depends_on :job

def self.value_for(template)
age = 2 + rand(15) + rand(15) + rand(5)
if rand(100) < 30
age += rand(25)
end

{
self.key => age,
birthday: Faker::Date.birthday(min_age: age, max_age: age + 1).strftime("%B %-d") # %A, %B %-d, %Y
}
end
end
end
14 changes: 14 additions & 0 deletions app/services/attributes/character/alignment_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Character
class AlignmentField < Field
field_key :alignment

def self.value_for(template)
alignment = %w(Lawful Neutral Chaotic).sample + ' ' + %w(Good Neutral Evil).sample
alignment = 'True Neutral' if alignment == 'Neutral Neutral'

{
self.key => alignment
}
end
end
end
64 changes: 64 additions & 0 deletions app/services/attributes/character/appearance_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module Character
class AppearanceField < Field
field_key :appearance

depends_on :gender, :ethnicity

def self.value_for(template)
optional_values = {}

if rand(100) < 90
eye_color = eye_colors.sample
else
eye_color = "one #{eye_colors.sample.downcase}, one #{eye_colors.sample.downcase}"
end

# Facial hair
if rand(100) < 50 && template.fetch(:gender, nil) == 'Male'
optional_values[:facial_hair] = facial_hairs.sample
end

# Hair color/style
hair_color = hair_colors.sample
unless %w(Bald).include? hair_color
hair_style = hair_styles.sample
end
hair_description = "#{hair_color} #{hair_style.downcase}"

# Skin tone
unless template.include?('ethnicity')
optional_values[:skin_tone] = skin_tones.sample
end

{
body_type: body_types.sample,
eye_color: eye_color,
hair: hair_description,
}.merge(optional_values)
end

def self.body_types
%w(Delicate Flat Fragile Lean Lightly\ muscled Small-shouldered Thin Athletic Hourglass Bodybuilder Rectangular Muscular Thick-skinned Big-boned Round\ physique Pear-shaped)
end

def self.eye_colors
%w(Amber Black Arctic\ blue Baby\ blue China\ blue Cornflower\ blue Crystal\ blue Denim\ blue Electric\ blue Indigo Sapphire\ blue Sky\ blue Champagne\ brown Chestnut\ brown Chocolate\ brown Golden\ brown Honey\ brown Topaz Charcoal\ grey Cloudy\ grey Steel\ grey Chartreuse Emerald\ green Forest\ green Grass\ green Jade\ green Leaf\ green Sea\ green Seafoam Hazel Amethyst Hyacinth Ultramarine\ blue Light\ violet Dark\ violet)
end

def self.facial_hairs
%w(Long\ beard Short\ beard Chin\ curtain Chinstrap Fu\ Manchu Goatee Handlebar\ mustache Horseshoe\ mustache Mustache Mutton\ chops Neckbeard Pencil\ mustache Shenandoah Sideburns Soul\ patch Light\ stubble Dark\ stubble Toothbrush\ mustache Van\ Dyke\ beard Patchy\ beard Patchy\ mustache Braided\ beard Braided\ mustache Twirled\ mustache)
end

def self.hair_colors
%w(Blonde Black Brown Red Bald White Grey Balding Greying Bleached Blue Green Purple Orange Auburn Strawberry Chestnut Dirty\ Blonde Rainbow Jet\ black Raven\ black)
end

def self.hair_styles
%w(Afro Bob\ cut Bowl\ cut Bouffant Braided Bun Butch Buzz\ cut Cignon Chonmage Combover Cornrows Crew\ cut Dreadlocks Emo Fauxhawk Feathered Flattop Fringe Liberty\ spikes Straight\ long Curly\ long Wavy\ long Thin\ long Mohawk Mop-top Parted Pigtails Pixie\ cut Pompadour Ponytail Rat-tail Rocker Slicked\ back Spiked Curly\ short Wavy\ short Thin\ short Straight\ short)
end

def self.skin_tones
%w(Albino Light Pale Fair White Grey Medium Olive Moderate\ brown Brown Dark\ brown Chocolate Black)
end
end
end
15 changes: 15 additions & 0 deletions app/services/attributes/character/archetype_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Character
class ArchetypeField < Field
field_key :archetype

def self.value_for(template)
{
self.key => possible_values.sample
}
end

def self.possible_values
%w(Anthropomorphic\ Personification Anti-Hero Archmage Barefoot\ Sage Background\ Character Big\ Fun Blind\ Seer Blue-Collar\ Warlock Bruiser\ with\ a\ Soft\ Center The\ Champion The\ Chosen\ One The\ Chooser\ of\ The\ One Classic\ Villain The\ Cynic The\ Dragonslayer The\ Drunken\ Sailor Dumb\ Muscle Eccentric\ Mentor Enigmatic\ Empowering\ Entity Evil\ Overlord The\ Fair\ Folk Father\ Neptune Ferryman The\ Fool Fool\ for\ Love Gary\ Sue Gentle\ Giant The\ Good\ King Granny\ Classic The\ Grotesque Herald Heroic\ Archetype Heroic\ Wannabe The\ High\ Queen Higher\ Self The\ Hunter Ideal\ Hero The\ Idealist Ineffectual\ Loner The\ Kirk The\ Klutz Knight\ in\ Shining\ Armor Lady\ and\ Knight Loser\ Archetype Lovable\ Rogue Magical\ Barefooter Mary\ Sue The\ McCoy Mentor Messianic Mixed Mock\ Millionaire Modern\ Major\ General My\ Girl\ Back\ Home Obstructive\ Bureaucrat Oedipus\ Complex Old\ Soldier The\ Paladin The\ Patriarch Person\ of\ Mass\ Destruction The\ Pollyanna Powers\ That\ Be Prince\ Charming Princess\ Classic Protagonist Rebel\ Leader Rebellious\ Spirit Reluctant\ Monster Satanic\ Archetype Seeker\ Archetype Shadow\ Archetype Shapeshifter Side\ Character The\ Spock Star-Crossed\ Lovers The\ Storyteller Threshold\ Guardians Turn\ Coat The\ Trickster Visitor Wicked\ Stepmother Wicked\ Witch Wizard\ Classic Wolf\ Man Witch)
end
end
end
11 changes: 11 additions & 0 deletions app/services/attributes/character/background_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Character
class BackgroundField < Field
field_key :background

def self.value_for(template)
{
self.key => "background TBD"
}
end
end
end
11 changes: 11 additions & 0 deletions app/services/attributes/character/blood_type_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Character
class BloodTypeField < Field
field_key :blood_type

def self.value_for(template)
{
self.key => Faker::Blood.group
}
end
end
end
20 changes: 20 additions & 0 deletions app/services/attributes/character/education_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Character
class EducationField < Field
field_key :education

depends_on :age

def self.value_for(template)
degree = Faker::Demographic.educational_attainment

case degree.split(' ').last.downcase
when 'degree'
degree += " in #{Faker::Educator.subject} from #{Faker::Educator.university}"
end

{
self.key => degree
}
end
end
end
13 changes: 13 additions & 0 deletions app/services/attributes/character/ethnicity_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Character
class EthnicityField < Field
field_key :ethnicity

def self.value_for(template)
{ self.key => possible_values.sample }
end

def self.possible_values
%w(American\ Indian Alaskan\ Native Asian Black African\ American Native\ Hawaiian Pacific\ Islander White White White African Caribbean Indian Melanesian Aboriginal Chinese Guamanian Japanese Korean Polynesian European Anglo\ Saxon Latino Arabic Vietnamese Micronesian Hispanic Puerto\ Rican Filipino Mexican Cuban Spaniard Italian Russian)
end
end
end
21 changes: 21 additions & 0 deletions app/services/attributes/character/fantasy_race_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Character
class FantasyRaceField < Field
field_key :species

def self.value_for(template)
species = if rand(100) < 20
Faker::Fantasy::Tolkien.race
else
possible_values.sample
end

{
self.key => species
}
end

def self.possible_values
%w(Android Angel Animal Arachnoid Alien Bird Dark\ Elf Dwarf Elemental Elf Fairy Fey Genie Gnome Half-Dwarf Half-Elf Half-Orc Halfling Human Insectoid Orc Reptilian Robot Spirit Troll Vampire Werewolf)
end
end
end
18 changes: 18 additions & 0 deletions app/services/attributes/character/favorites_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Character
class FavoritesField < Field
field_key :favorites

def self.value_for(template)
{
favorite_book: Faker::Book.title,
favorite_author: Faker::Book.author,
favorite_genre: Faker::Book.genre,
favorite_movie: Faker::Movie.title,
favorite_artist: Faker::Artist.name,
favorite_animal: Faker::Creature::Animal.name.capitalize,
favorite_food: Faker::Food.dish,
favorite_quote: "\"#{Faker::GreekPhilosophers.quote}\""
}
end
end
end
11 changes: 11 additions & 0 deletions app/services/attributes/character/gender_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Character
class GenderField < Field
field_key :gender

def self.value_for(template)
{
self.key => Faker::Gender.type
}
end
end
end
32 changes: 32 additions & 0 deletions app/services/attributes/character/height_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Character
class HeightField < Field
field_key :height

depends_on :age

def self.value_for(template)
case template.fetch(:age, 25)
when 0..1
inches = rand(10..30)
when 1..5
inches = rand(30..45)
when 5..10
inches = rand(40..65)
when 10..15
inches = rand(45..70)
when 15..18
inches = rand(50..70)
when 18..50
inches = rand(50..75)
when 50..99
inches = rand(40..70)
end

feet = inches / 12
inches = inches % 12
{
height: "#{feet} ft, #{inches} in"
}
end
end
end
16 changes: 16 additions & 0 deletions app/services/attributes/character/hobbies_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Character
class HobbiesField < Field
field_key :job

def self.value_for(template)
hobbies = []
3.times do
hobbies << Faker::Hobby.activity
end

{
self.key => hobbies.uniq.join(', ')
}
end
end
end
11 changes: 11 additions & 0 deletions app/services/attributes/character/human_race_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Character
class HumanRaceField < Field
field_key :race

def self.value_for(template)
{
self.key => Faker::Demographic.race
}
end
end
end
12 changes: 12 additions & 0 deletions app/services/attributes/character/job_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Character
class JobField < Field
field_key :job

def self.value_for(template)
{
self.key => Faker::Company.profession.capitalize,
dream_job: Faker::Company.profession.capitalize
}
end
end
end
16 changes: 16 additions & 0 deletions app/services/attributes/character/languages_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Character
class LanguagesField < Field
field_key :languages

def self.value_for(template)
languages = [Faker::Nation.language]
while rand(100) < 10
languages << Faker::Nation.language
end

{
self.key => languages.uniq.join(', ')
}
end
end
end
11 changes: 11 additions & 0 deletions app/services/attributes/character/location_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Character
class LocationField < Field
field_key :location

def self.value_for(template)
{
self.key => Faker::Address.country
}
end
end
end
41 changes: 41 additions & 0 deletions app/services/attributes/character/name_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Character
class NameField < Field
field_key :name

depends_on :gender

def self.value_for(template)
name = []

# First name
case template.fetch(:gender)
when 'Male'
name << Faker::Name.male_first_name
when 'Female'
name << Faker::Name.female_first_name
else
name << Faker::Name.first_name
end

# Middle name(s)
if rand(100) < 95
name << Faker::Name.middle_name
end
while rand(100) < 10
name << Faker::Name.middle_name
end

# Last name
name << Faker::Name.last_name

# Suffix
if (rand(100) < 5)
name << Faker::Name.suffix
end

{
self.key => name.join(' ')
}
end
end
end
Loading