Ellen Lee | bbfd78e | 2017-10-27 10:57:24 +0800 | [diff] [blame] | 1 | require "./monster" |
arch | a9c66d3 | 2017-10-31 17:46:33 +0800 | [diff] [blame^] | 2 | require "./hero.rb" |
Ellen Lee | bbfd78e | 2017-10-27 10:57:24 +0800 | [diff] [blame] | 3 | require_relative "holy_knight" |
arch | a9c66d3 | 2017-10-31 17:46:33 +0800 | [diff] [blame^] | 4 | require_relative "mage.rb" |
Ellen Lee | bbfd78e | 2017-10-27 10:57:24 +0800 | [diff] [blame] | 5 | |
| 6 | # 建立一個有不同職業 (包括英雄、神聖武士與魔法師)的團隊 |
arch | a9c66d3 | 2017-10-31 17:46:33 +0800 | [diff] [blame^] | 7 | hero = Hero.new("Robinhood", 100, 20) |
| 8 | holy_knight = HolyKnight.new("Howard", 100, 30) |
| 9 | mage = Mage.new("Merlin",60, 20, 10) |
Ellen Lee | bbfd78e | 2017-10-27 10:57:24 +0800 | [diff] [blame] | 10 | |
| 11 | # 列印英雄隊伍 |
| 12 | team = Hero.all |
| 13 | |
| 14 | puts "You have #{Hero.count} heroes in your team:" |
| 15 | |
| 16 | team.each do |hero| |
| 17 | puts "#{hero.name} - Class:#{hero.class}, HP:#{hero.hp} " |
| 18 | end |