Guest User

Untitled

a guest
Oct 18th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.38 KB | None | 0 0
  1. ingredients = Hash.new
  2. potion = 0
  3.  
  4. puts "Welcome to potion brewer! To make a health potion you must combine 4 TOF + 7 TOW + 2 AF. Let's get started.\n\n"
  5. puts "Here are some basic conversions:\n\n"
  6. puts "4 EON + 2 WOB = 3 AF + 4 TOW\n"
  7. puts "3 TOW + 1 TOF = 2 EON\n"
  8. puts "1 WOB + 2 AF = 1 TOF\n\n"
  9.  
  10. puts "The program will now calculate the maximum amount of potions you can make given your ingredients.\n\n"
  11.  
  12. puts "How many EON do you have?"
  13.  
  14. ingredients["EON"] = gets.to_i
  15.  
  16. puts "How many TOF do you have?"
  17.  
  18. ingredients["TOF"] = gets.to_i
  19.  
  20. puts "How many WOB do you have?"
  21.  
  22. ingredients["WOB"] = gets.to_i
  23.  
  24. puts "How many AF do you have?"
  25.  
  26. ingredients["AF"] = gets.to_i
  27.  
  28. puts "How many TOW do you have?"
  29.  
  30. ingredients["TOW"] = gets.to_i
  31.  
  32. # ==/== DEBUG ==/==
  33. #for name in ingredients.keys
  34. #    puts "Great, you have #{ingredients[name]} " + name + "."
  35. #end
  36.  
  37. #tof_left = ingredients["TOF"] % 4
  38. #tow_left = ingredients["TOW"] % 7
  39. #af_left = ingredients["AF"] % 2
  40.  
  41. while (ingredients["TOF"] >= 4 and ingredients["TOW"] >= 7 and ingredients["AF"] >= 2)
  42.     potion += 1
  43.     ingredients["TOF"] -= 4
  44.     ingredients["TOW"] -= 7
  45.     ingredients["AF"] -= 2
  46.     # ==/== DEBUG ==/==
  47.     #puts "Potion created.."
  48. end
  49.  
  50. puts "\n\nMade #{potion} potion(s).\n\n"
  51.  
  52. for name in ingredients.keys
  53. puts "You have " + ingredients[name].to_s + " " + name + " left.\n\n"
  54. end
Advertisement
Add Comment
Please, Sign In to add comment