import java.awt.Graphics;
/** 
 Program: 	Events class 
 Purpose: 	a class which executes all the events 
 @author 	john@december.com
 @version  	1.60; 21 Nov 95
 Note:          converted 1.00 beta
 */

class Events {

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

   private final int HIGHDRAMA   = 20;  // long, dramatic pauses
   private final int MEDIUMDRAMA = 10;  // medium pauses
   private final int LOWDRAMA    =  3;  // 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 star, costar;

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

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

   private void pause(int drama) {
       try {Thread.sleep(eventInterval*drama);} 
       catch (InterruptedException e){}
   }
 
   public void paint(Graphics context){
     star.paint(context);
     pause(MEDIUMDRAMA);
     costar.paint(context);
     pause(HIGHDRAMA);
   }

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

   public void stop() {
     star = null;
     costar = null;
     Actor.actorLines = 0;
   }
}
