Skip to content

Instantly share code, notes, and snippets.

@jackieiscool
Created June 19, 2012 00:40
Show Gist options
  • Select an option

  • Save jackieiscool/2951656 to your computer and use it in GitHub Desktop.

Select an option

Save jackieiscool/2951656 to your computer and use it in GitHub Desktop.
RPG
class Hero
def initialize(level)
@level = level
@health = @level * 100
end
def life
@health
end
end
class Human < Hero
def initialize(level, name)
@name = name.capitalize
if level > 100 || level < 1
raise_error
else
@level = level
end
end
def name
"Hero #{@name} the Human"
end
def mana
@level + 2
end
end
class Orc
def initialize(level, name)
@name = name.capitalize
if level > 100 || level < 1
raise_error
else
@level = level
end
end
def name
"Hero #{@name} the Orc"
end
def mana
@level + 4
end
end
class Night_elf
def initialize(level, name)
@name = name.capitalize
if level > 100 || level < 1
raise_error
else
@level = level
end
end
def name
"Hero #{@name} the Night Elf"
end
def mana
@level + 6
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment