Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created October 17, 2018 06:24
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 havenwood/d36a1ee469aa19e1e12b69136cb00d90 to your computer and use it in GitHub Desktop.
Save havenwood/d36a1ee469aa19e1e12b69136cb00d90 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
class Character
SKILLS = %w[Warrior Wizard Explorer Knight Saint].freeze
DICE = %i[d4 d8 d12].freeze
NAMES_FILENAME = 'names.txt'
def initialize name: nil
@name = name || random_name
@skills = DICE.zip(SKILLS.shuffle).to_h
end
private
def random_name
File.readlines(NAMES_FILENAME, chomp: true).sample
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment