//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  Logic 105: Hey, look!  It's a well!
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include "defines.txt"

if (new_room) {
  universe=90;
  load.pic(universe);
  draw.pic(universe);
  discard.pic(universe);
  set.horizon(37);


// Check what room the player came from and position them on the
// screen accordingly here, e.g:
 if (prev_room_no == 103) {
     position(ego,4,150);
 }
 if (prev_room_no == 104) {
     position(ego,150,150);
     }

 if (prev_room_no == 106) {
     position(ego,73,149);
     }

 if (pole_and_well) {
     animate.obj(o1);
    load.view(fishing_rod);
    set.view(o1,fishing_rod);
    position(o1,60,80);
    draw(o1);
  }

  load.sound(17);
  sound(17, sound_flag);

  draw(ego);
  show.pic();
}

if (said("look")) {
  print("You are outside the castle.  The walls rise up into the clouds above.  Hey, look!  There's a well here!");
}

if (said("look","well")) {
    print("It's a big well made of metamorphic rock.  Deep down, you can see the shimmer of water.");
    }

if (said("look","wall")) {
    print("The walls tower above you, vanishing into an unearthly mist.");
    print("A tree branch protrudes from between the joints of two stones.");
    }

if ((said("look","branch") ||
     said("look","tree"))) {
    print("It forms a little forked hook.  It seems strong, too.");
    }

if (said("look","stone")) {
          print("The brick is smooth and light grey.");
          }

if ((said("look","ground") ||
     said("look","grass"))) {
         print("The grass is waving as if there is a breeze, but you feel none.");
         }

if (said("look","sky")) {
         print("Far above, you see iridescent clouds swirling around the castle walls, as if the castle was some kind of nexus.");
         }


if ((said("climb","wall") ||
     said("climb","castle"))) {
          print("Eep!  The stone is smooth and the joints are narrower than your fingers.");
          }

if ((said("climb","down","well") ||
     said("get","well") ||
     said("climb","down") ||
     said("climb","well"))) {
    if (pole_and_well) {
        print("You drag out some fishing line and use it to climb down the well.");
        new.room(106);
        }
    else {
        print("The sides of the well are too slippery to climb.");
        }
    }

if ((said("climb","down","line") ||
     said("climb","line"))) {
    if (pole_and_well) {
        print("You drag out some fishing line and use it to climb down the well.");
        new.room(106);
        }
    else {
        print("There is nothing for you to climb.");
        }
    }

if (said("use","fishing pole")) {
   if (pole_and_well) {
      print("You drag out some line and use it to lower yourself down the well.");
      new.room(106);
      }
   else {
    if (has("fishing rod")) {
     animate.obj(o1);
     load.view(22);
     set.view(o1,22);
     position.v(o1,new_ego_x, new_ego_y);
     erase(ego);
     draw(o1);
     end.of.loop(o1, done_flag);
      }
    else {
      print("You can't use what you don't have.");
      }
     }
   }

if ((said("use","fishing pole","well") ||
     said("use","fishing pole","on","well"))) {
  if (pole_and_well) {
      print("You drag out some line and use it to lower yourself down the well.");
      new.room(106);
      }
  if (has("fishing rod")) {
    animate.obj(o1);
    load.view(22);
    set.view(o1,22);
    position.v(o1,new_ego_x, new_ego_y);
    erase(ego);
    draw(o1);
    end.of.loop(o1, done_flag);
    }
   }

if (done_flag) {
    erase(o1);
    discard.view(22);
    draw(ego);
    reset(done_flag);
    print("You didn't snag anything.");
    }

if ((said("use","fishing pole","branch") ||
     said("put","fishing pole","branch") ||
     said("use","fishing pole","on","branch") ||
     said("put","fishing pole","on","branch") ||
     said("use","fishing pole","tree") ||
     said("put","fishing pole","tree") ||
     said("use","fishing pole","on","tree") ||
     said("put","fishing pole","on","tree"))) {
    if (ego_on_water) {
        move.obj(ego, 76,124, 2, more_done_flag);
        }
    else {
        print("You should get a little closer.");
        }
    }

if (more_done_flag) {
    drop("fishing rod");
    set(pole_and_well);
    reset(more_done_flag);
    print("You wedge the handle of the fishing pole into the forked branch.");
    new.room(105);
    }

if (said("get","fishing pole")) {
   if (pole_and_well) {
     if (ego_on_water) {
       get("fishing rod");
       reset(pole_and_well);
        move.obj(ego, 76,124, 2, really_done_flag);
       }
     else {
       print("You should get closer.");
       }
    }
   else {
    print("You don't see it.");
    }
   }

if (really_done_flag) {
    erase(o1);
    reset(really_done_flag);
    }

if ((said("get","branch") ||
     said("get","leaf") ||
     said("get","tree"))) {
          print("No, you want this little tree to survive.  One day, it may grow big enough to break down the wall and let all the dreams escape.");
          }

if ((said("jump") ||
     said("jump","down","well"))) {
          print("You don't know how deep the water is, and you don't know how you'd get back up in any case.");
          }

if (said("use","well")) {
     print("Are you thirsty?  Do you want to make a wish?  Be more specific.");
     }

if (said("drink","water")) {
     print("You only drink charcoal purified water.");
     }

if (said("make","wish")) {
    print("You have no money.  Besides, I don't think it's that kind of well.");
    }

if (ego_edge_code == right_edge) {    // ego touching right edge of screen

    new.room(104);
}

if (ego_edge_code == left_edge) {     // ego touching left edge of screen
    new.room(103);
}

if (sound_flag) {
    sound(17, sound_flag);
    }

return();