Last active
October 2, 2015 19:22
-
-
Save lgranger/d55d2e90e71672659fb3 to your computer and use it in GitHub Desktop.
Dragon Class & HP Dragon Hash
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
# Hashes for the dragon species from the Harry Potter series. Info taken form the Harry Potter Wiki. | |
DRAGON_SPECIES = { | |
opaleye: { | |
name: "Antipodean Opaleye", | |
nickname: "the most beautiful dragon", | |
color: "pearly", | |
eyes: "glittering and multi-coloured, with no pupils" | |
}, | |
long_snout: { | |
name: "Portuguese Long-Snout", | |
snout: "longer", | |
horns: 2, | |
color: "orange" | |
}, | |
fireball: { | |
name: "Catalonian Fireball", | |
snout: "oddly shaped", | |
spikes: "a row that desends down its back", | |
color: "red" | |
}, | |
lion: { | |
name: "Chinese Fireball", | |
nickname: "Lion Dragon", | |
snout: "snub-face", | |
spikes: "golden and fringe like", | |
color: "scarlet", | |
scales: "scarlet and smooth", | |
eyes: "extremely protuberant" | |
}, | |
welsh: { | |
name: "Common Welsh Green", | |
nickname: "Common Welsh, or Welsh Green", | |
horns: 2, | |
color: "green", | |
tail: "a single pointed tip, vert stream-lined" | |
}, | |
hebridean: { | |
name: "Hebridean Black", | |
scales: "dark, rough", | |
color: "black", | |
eyes: "brilliant purple", | |
tail: "tipped with an arrow-shaped spike", | |
size: "up to 30 feet long" | |
}, | |
horntail: { | |
name: "Hungarian Horntail", | |
nickname: "the most dangerous dragon", | |
snout: "lizzard-like", | |
spikes: "bronze", | |
horns: "bronze", | |
color: "black", | |
eyes: "yellow", | |
tail: "bronze spikes on the" | |
}, | |
ridgeback: { | |
name: "Norwegian Ridgeback", | |
snout: "lizzard-like", | |
spikes: "bronze", | |
horns: "bronze", | |
color: "brown/black", | |
eyes: "yellow", | |
tail: "bronze spikes on the" | |
}, | |
peruvian: { | |
name: "Peruvian Vipertooth", | |
snout: "black ridge-markings", | |
horns: "short and on the head", | |
color: "copper" | |
}, | |
longhorn: { | |
name: "Romanian Longhorn", | |
horns: "two long, long and glittering gold", | |
color: "dark green" | |
}, | |
swedish: { | |
name: "Swedish Short-Snout", | |
nickname: "blue-flame", | |
snout: "flame is hot enough to reduce timber and bone to ashes in seconds", | |
color: "silvery blue" | |
}, | |
ironbelly: { | |
name: "Ukrainian Ironbelly", | |
nickname: "the largest dragon species every recorded", | |
color: "grey", | |
scales: "metalic grey that are rough and hard as steel", | |
eyes: "deep red", | |
size: "reaches up to six tons" | |
}, | |
} |
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
require "./dragon_species_hashes.rb" | |
class Dragon | |
attr_reader :name, :species, :spikes, :scales | |
def initialize(name, species = :welsh) | |
species_hash = DRAGON_SPECIES[species] | |
@name = name.capitalize | |
@species = species_hash[:name] | |
@color = species_hash[:color] | |
@nickname = species_hash[:nickname] | |
@snout = species_hash[:snout] | |
@eyes = species_hash[:eyes] | |
@horns = species_hash[:horns] | |
@tail = species_hash[:tail] | |
@spikes = species_hash[:spikes] | |
@size = species_hash[:size] | |
@scales = species_hash[:scales] | |
@asleep = false | |
@in_tummy = 10 | |
@in_gut = 0 | |
@hydration = 10 | |
@bladder = 2 | |
puts "The egg trembbles & cracks...\nThe shell falls away...\n\nA baby #{@species} dragon is born!\nHagrid would be so proud.\nWelcome to the world #{@name}!" | |
if @nickname != nil | |
puts "#{@species} dragons are often called #{@nickname}. " | |
end | |
if ((@snout != nil) && (@eyes != nil)) | |
puts "They have #{@snout} snouts, and #{@eyes} eyes. " | |
end | |
if ((@horns != nil) && (@tail != nil)) | |
puts "Be careful! With #{@horns} horns, and #{@tail} tail, the #{@species} is not afraid to defend itself!" | |
else | |
puts "The #{@species} is an awesome beast!" | |
end | |
puts "\nRemember: \"Your dragon requires a lot of care during these first few months.\"\n -Dragon Breeding for Pleasure and Profit" | |
end | |
def passage_of_time | |
if @in_tummy > 0 | |
@in_gut += 1 | |
@in_tummy -= 1 | |
else | |
if @asleep | |
@asleep = false | |
puts "They wake up suddenly!" | |
end | |
puts "#{@name} is starving! They eat you." | |
exit | |
end | |
if @hydration > 0 | |
@bladder += 1 | |
@hydration -= 1 | |
else | |
if @asleep | |
@asleep = false | |
puts "#{@name} wakes up crying!" | |
end | |
puts "You didn't give #{@name} water! Their #{@color} flames are super hot & you catch on fire!" | |
exit | |
end | |
if ((@in_gut >= 10) || (@bladder >= 8)) | |
puts "Oops! #{@name} had a potty accident. 💩 Better clean that up!" | |
@in_gut = 0 | |
@bladder = 0 | |
end | |
if hungry? | |
puts "#{@name} has a grumbly tum tum..." | |
end | |
if thirsty? | |
puts "They puff smoke and shoot #{@color} flames, better get them some water before their flames get to hot!" | |
end | |
if potty? | |
if @asleep | |
@asleep = false | |
puts "They wake up suddenly!" | |
end | |
puts "#{@name} does the potty dance..." | |
end | |
end | |
def hungry? | |
return @in_tummy <= 2 | |
end | |
def potty? | |
return ((@in_gut >= 8) || (@bladder >= 6)) | |
end | |
def thirsty? | |
return @hydration <= 2 | |
end | |
def bed_time | |
puts "It's bed time. #{@name} snuggles up next to you." | |
@asleep = true | |
3.times do | |
passage_of_time | |
end | |
end | |
def food_time | |
puts "You feed #{@name} a bucket of brandy mixed with chicken blood. They are full." | |
@in_tummy = 10 | |
passage_of_time | |
end | |
def watering | |
put "You can lead a dragon to water, but you can't make them drink!" | |
@hydration = 10 | |
passage_of_time | |
end | |
def walkies | |
puts "Time for walkies #{@name}!!" | |
@in_gut = 0 | |
@bladder = 0 | |
passage_of_time | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment