Created
September 20, 2015 21:53
-
-
Save tra38/c11ad345cb5467806941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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