//
// ****************************************************************************
//
// Logic 41: Wheel of Jeopardy!!!
//
// ****************************************************************************

#include "defines.txt"

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


  animate.obj(o1); //Talking Grub
  load.view(115);
  set.view(o1,115);
  position(o1,5,162);
  universe=2;
  cycle.time(o1,universe);
  draw(o1);

  animate.obj(o2); //Zombie
  load.view(103);
  set.view(o2,103);
  position(o2,107,167);
  draw(o2);
  set.loop(o2,2);

  position(ego,73,167);
  program.control();
  set.loop(ego, 2);
  ego_dir = 0;
  draw(ego);

   show.pic();

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

 if (prev_room_no == 42) {
  game_point=0;
  question_no=0;
  question_data=0;
  reset(timer_started);
   print("Grub: \"It's time once again for Wheel of Jeopardy, the game show to end all game shows.  I'm your host, the Talking Grub.  With us today are Voodoo Girl and some Zombie.\"");
  print("Grub: \"For those of you at home, I'll explain the rules.\"");
  print("Grub: \"I'll read off a question, and each of our lucky contestants will have a few seconds to type-in their answer.\"");
  print("Grub: \"If they get it right, they'll gain 10 points.  If they get it wrong, they'll lose 10 points.  The first to 250 points will win the game and get a chance to go on to the castle of the Dream King.\"");
  print("Grub: \"Contestants, are you ready?  Hands on your keyboards...\"");
  }
}

display(12,10,m50);




if (said("look")) {
  print("You are on the fabulous, syndicated gameshow, Wheel of Jeopardy!");
}

if (said("exit")) {
    print("Grub \"Okay, Bu-bye.\"");
    position(ego,25,113);
    new.room(42);
    }

if (!timer_started) {

    timer1_a=0;
    if (question_no < 30) {
    question_no++;

    set(timer_started);
         //call(203);
    }

    random(75,150,universe);
    }

if (timer_started) {

    call(203);

    if (said("a")) {
        set.string(s1, m150);
           print.at("Grub: \"Voodoo Girl...  your answer... \"",10,5,30);
        if (compare.strings(s1,s2)) {
           if (game_point < 250) {
            game_point+=10;
            }
            print("Grub: \"Yes, that's correct!\"");
            reset(timer_started);
            new.room(41);
            }
        else {
            print("Grub: \"No, I'm sorry, that's incorrect.\"");
          if (game_point < 0) {
            game_point-=10;
            }
            reset(timer_Started);
            new.room(41);
            }
        }

    if (said("b")) {
        set.string(s1, m151);
           print.at("Grub: \"Voodoo Girl...  your answer... \"",10,5,30);
        if (compare.strings(s1,s2)){
          if (game_point < 250) {
            game_point+=10;
            }
            print("Grub: \"Yes, that's correct!\"");
            reset(timer_started);
            new.room(41);
            }
        else {
            print("Grub: \"No, I'm sorry, that's incorrect.\"");
          if (game_point > 0) {
            game_point-=10;
            }
            reset(timer_Started);
            new.room(41);
            }
        }

    if (said("c")) {
        set.string(s1, m152);
           print.at("Grub: \"Voodoo Girl...  your answer... \"",10,5,30);

        if (compare.strings(s1,s2)) {
          if (game_point < 250) {
            game_point+=10;
            }
            print("Grub: \"Yes, that's correct!\"");
            reset(timer_started);
            new.room(41);
            }
        else {
            print("Grub: \"No, I'm sorry, that's incorrect.\"");
          if (game_point > 0) {
            game_point-=10;
            }
            reset(timer_Started);
            new.room(41);
            }
        }

    if (said("d")) {
        set.string(s1, m153);
           print.at("Grub: \"Voodoo Girl...  your answer... \"",10,5,30);
        if (compare.strings(s1, s2)) {
          if (game_point < 250) {
            game_point+=10;
            }
            print("Grub: \"Yes, that's correct!\"");
            reset(timer_started);
            new.room(41);
            }
        else {
            print("Grub: \"No, I'm sorry, that's incorrect.\"");
          if (game_point > 0) {
            game_point-=10;
            }
            reset(timer_Started);
            new.room(41);
            }
        }



    if (timer1_a==universe) {
        print("Grub: \"Zombie...  your answer...\"");
        print("Zombie: \"Aaaargh...Rawwwww....Hernh...\"");
        print("Grub: \"No, I'm sorry, that is incorrect.\"");
        reset(timer_started);
        new.room(41);
        }

    if (timer1_a<150) {
        timer1_a++;
        }
        else {
            print("Grub: \"Time's up!  Next question!\"");
            reset(timer_started);
            }


call(203);

}

if (question_no==30 &&
    !timer_started) {
  if (game_point==250) {
    print("Grub: \"You just won that show of shows...\"");
    print("Wheel!");
    print("Of!!");
    print("JEOPARDY!!!");
    print("Grub: \"Now get out of here...  I'm sick of looking at you.\"");
    reset(grub);
    player.control();
    score+=5;
    new.room(42);
    }
  else {
    print("Grub: \"That's all the time we have...  Unfortunately, we didn't have a winner...  join us next time for...\"");
    print("Wheel!");
    print("Of!!");
    print("JEOPARDY!!!");
    player.control();
    new.room(42);
    }
  }


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

return();

#message 50 "SCORE: %v107"
#message 100 "?"
#message 150 "a"
#message 151 "b"
#message 152 "c"
#message 153 "d"