Skip to content

Instantly share code, notes, and snippets.

@tra38
Created September 20, 2015 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tra38/c11ad345cb5467806941 to your computer and use it in GitHub Desktop.
Save tra38/c11ad345cb5467806941 to your computer and use it in GitHub Desktop.
require 'yaml'
characters_data = YAML.load_file("yml/characters.yml")
@words_data = YAML.load_file("yml/words.yml")
@selfverbs = @words_data["SelfVerbs"]
CHARACTERS = characters_data["Characters"]
#Method to sample from a Hash
#Reference: http://stackoverflow.com/questions/15454632/is-there-an-equivalent-to-arraysample-for-hashes-in-ruby
def sample(original_hash)
original_hash[original_hash.keys.sample]
end
def location
@words_data["Locations"].sample
end
def adverb
@words_data["Adverbs"].sample
end
def filler
@words_data["Filler"].sample
end
def word(trait)
puts trait
@selfverbs[trait].sample
end
def random_trait_category
["Purpose","Motivation","Methodology","Evaluation"].sample
end
def random_word(character, category=random_trait_category )
random_trait = character[category].sample
word(random_trait)
end
def name(character)
character["Name"]
end
def enemy(character)
character["Enemy"]
end
def goal(character)
character["Goal"]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment