-
-
Save havenwood/d36a1ee469aa19e1e12b69136cb00d90 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
# 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