Try setting up the classes as an array...
player_classes = ["warrior", "thief", "archer", "wizard"]
And then when you want to check if the player has entered a valid class...
while ! player_classes.include? player_class
instead.
You can use an even nicer idiom for single words...
%w(warrior thief archer wizard)
Generates
["warrior", "thief", "archer", "wizard"]
Moving forward
You could take this approach a step forward by putting the player classes into a hash.
For example:
player_classes = {
'warrior' => {:message => "Yay a warrior!", :stats => {:strength => 20} },
'thief' => {:message => "Ooh a thief!", :stats => {:dexterity => 20} },
'archer' => {:message => "Cool! an archer" },
'wizard' => {:message => "Sweet! a wizard" }
}
You can then do things like this:
while ! player_classes.key? player_class
Once you've got a match you can then pull the values out of the hash, like this:
selected_class = player_classes[player_class]
stats.merge selected_class[:stats] if selected_class[:stats]
If there's no stats in the hash for that player class nothing will happen, if there is, it'll be merged in.
e.g. to test this...
selected_class = player_classes['warrior']
stats.merge selected_class[:stats] if selected_class[:stats]
# stats is now {:strength=>20, :dexterity=>10, :charisma=>10, :stamina=>10}
selected_class = player_classes['wizard']
stats.merge selected_class[:stats] if selected_class[:stats]
# stats is now {:strength=>10, :dexterity=>10, :charisma=>10, :stamina=>10}
We can then show the message with:
puts player_classes[player_class][:message]
This would reduce your logic down to capturing the player class input and then processing the hash.
Revisting your original code
Using a hash to act as a simple data-model.
You'd end up with code like this:
#!/usr/bin/env ruby
stats = { :strength => 10, :dexterity => 10, :charisma => 10, :stamina => 10 }
player_classes = {
'warrior' => {:message => "Yay a warrior!", :stats => {:strength => 20} },
'thief' => {:message => "Ooh a thief!", :stats => {:dexterity => 20} },
'archer' => {:message => "Cool! an archer" },
'wizard' => {:message => "Sweet! a wizard" }
}
puts "Welcome brave adventurer, what is your name?"
player_name = gets.chomp.capitalize
puts "Well, #{player_name}, you are certainly brave! Choose your profession. (Choose from Warrior, Wizard, Archer, or Thief)."
player_class = gets.chomp.downcase
while ! player_classes.key? player_class
puts "I do not recognize #{player_class} as a valid class. Please choose between Warrior, Wizard, Archer, or Thief."
player_class = gets.chomp.downcase
end
selected_class = player_classes[player_class]
stats.merge selected_class[:stats] if selected_class[:stats]
puts selected_class[:message]
You should also find this more readable, however, as you extend your game, you'll find that you can't easily work with code like this. You should next learn about using functions to break up your code into different routines. There are also more things you can do with arrays, hashes and collections.
Also, as soon as possible, you should start learning about programming Ruby in an Object Oriented style, which is how it should be used, ideally.
Tutorials Point is a pretty decent site for learning more about Ruby