import awt.Graphics;
/** 
 Program: 	Events class 
 Purpose: 	a class which executes all the events 
 @author 	john@december.com
 @version  	1.56; 23 Jul 1995
 */

class Events {

   private final int OVER = 999;        // All events over
   private final int MORE = 0;          // More events still to come

   private final int HIGHDRAMA   = 10;  // long, dramatic pauses
   private final int MEDIUMDRAMA =  5;  // medium pauses
   private final int LOWDRAMA    =  1;  // short pauses

   private final int MIDDLE  = 150;     // stage location
   private final int FRONT   = 200;     // stage location
   private final int BACK    = 100;     // stage location
   private final int eventInterval = 200;

   private int status = MORE;
   private Script thePlay;
   private Actor a1, a2;

   Events() {
      // The script and characters are created and placed on the stage.
      thePlay = new Script("The Time Bandits");
      a1 = new Actor("Deni",  5, 100, MIDDLE);
      a2 = new Actor("Kevin", 5, 100, FRONT);
   }

   public boolean moreEvents() {
      return (!(status == OVER));
   }

   private void pause(int drama) {
      Thread.sleep(eventInterval*drama);
   }
 
   public void paint(Graphics context){
      a1.paint(context);
      a2.paint(context);
      pause(MEDIUMDRAMA);
   }

   public void nextEvent() {
     a1.say(thePlay.getLine(Actor.actorLines)); 
     a2.say(thePlay.getLine(Actor.actorLines)); 
     if (thePlay.doneScript(Actor.actorLines)) status = OVER; 
   }
}
