require_relative '08-adventure-character'
require_relative '08-adventure-room'
require_relative '08-adventure-vocabulary'
require_relative '08-adventure-item'

jungle, cavefront, foyer, clinic, chamber, lair= (1..6)
  .collect do Room.new end;
lizards = (1..2).collect do Lizard.create end
trolls = (1..2).collect do Troll.create  end
smaug = Dragon.create
sword = Weapon.new("sword",50)
spade = Item.new("spade")

# Descriptions
jungle.description <<END
******************* Jungle **********************************
You are in the middle of a jungle. Sunlight filters through
the canopy, and in the distance, a thrush sings.
END
jungle.short_description "Back to the beginning."

cavefront.description <<END
******************** Cave Front *****************************
In front of you is the opening of a cave.
END
cavefront.short_description "in front of the cave."
cavefront.items spade

foyer.description <<END
******************* Foyer ***********************************
Inside the cave.
END
foyer.short_description "Foyer"
foyer.burrowable=true

chamber.description <<END
****************** Underground Chamber *********************
A dank chamber. In a corner, water drips on to a stalactite.
END
chamber.short_description "Chamber."
chamber.items sword

# this is a hack. the keg should be a takeable item
clinic.description "There is a keg on the floor."
lair.description <<END
****************** Smaug's Lair *****************************
The faint smell of sulphur hangs in the air. The air is unbearably hot,
and angry red glow permeates. 
END
lair.short_description "Smaug's lair."

# Map
jungle.east= cavefront
cavefront.east= foyer
foyer.north= clinic
foyer.east= lair
foyer.down= chamber

jungle.monster lizards[1]
foyer.monster  trolls[1]
lair.monster smaug

# The game starts here
# adventurer
hero = Adventurer.new("Hero",100,jungle)

# Game Loop
while true
  print "? "
  input = gets.chomp
  two_part_action = input.split(" ")
  if is_synonym two_part_action[0], "move"
    hero.move two_part_action[1]
  elsif is_synonym two_part_action[0], "attack"
    hero.attacks_in hero.position
  elsif two_part_action[0] == "take"
    item = hero.position.remove_item_by_name(two_part_action[1])
    hero.add_item(item)
  elsif two_part_action[0] == "quit"
    break
  elsif two_part_action[0] == "drink"
    hero.swill
  elsif two_part_action[0] == "inventory"
    hero.inventory
  else
    puts "you too, sir."
  end
end
