
/* Generated by Interface Builder */
/* Modified by Eric Tremblay April 18 , 1992 */
/* Updated May 8, 1994 */

#import "How.h"
#import <appkit/Button.h> /* Needed to change the image in an Icon */

@implementation How

      int TOTAL = 0;
      int i; /* dummy variable */
      int X; /* X screen coordinate */
      int Y; /* Y screen  coordinate */

- init
{
   [super init];
   return self;
 }

- StartHow:sender
/* This is used by the menu item How */
{
     [Result close]; /* close the Result panel */
     [Select orderFront:sender]; /* Selection panel "Let's start" */
     return self;
}


- Chosen:sender
/* This is for the button is the Select panel
 * once the user has chosen a number
 * he will click on this button
 */
{
    TOTAL =0;
    
 
/* Drop Select window at the bottom of the screen. */
     
      X= 247;
      Y= 177;
 
      [Select makeKeyWindow]; /* Selects the window */
      [Select orderFront:sender]; /* Places the window in front */
        
      for (i = Y; i > -435; i=i-10) {
            [Select moveTo:(X):(i)];
        }
      
      [Select close]; /* Closes the window (Even if theres no close button on the window) */
      [Select moveTo:(247):(177)]; /* re-position the Select panel at original XY on the screen */
      
/* end of Drop Select panel */
    
    [CardOne orderFront:sender]; /* display CardOne panel */
    return self;
}

- OneYes:sender
/* CardOne answer yes */
{
    [self DropCardOne:sender]; /* Drop the card method */
    TOTAL=TOTAL + 1;
    [CardTwo orderFront:sender];
    return self;
}

- OneNo:sender
/* CardOne answer no */
{
    [self DropCardOne:sender]; /* Drop the card method */
    [CardTwo orderFront:sender];
    return self;
}

-DropCardOne:sender
/* drop CardOne */
{
/* Drop CardOne window at the bottom of the screen. */
     
      X= 260;
      Y= 329;
 
      [CardOne makeKeyWindow]; /* Selects the window */
      [CardOne orderFront:sender]; /* Places the window in front */
        
      for (i = X; i > -440; i=i-10) {
            [CardOne moveTo:(i):(Y)];}
/* Move window to the left */
       
      
      [CardOne close]; /* Closes the window (Even if theres no close button on the window) */
      [CardOne moveTo:(311):(350)]; /* re-position the Select panel at original XY on the screen */
      
/* end of Drop CardOne panel */

       return self;
}

- TwoYes:sender
/* CardTwo answer yes */
{
    [self DropCardTwo:sender]; /* Drop the card method */
    TOTAL=TOTAL + 2;
    [CardThree orderFront:sender];
    return self;
}

- TwoNo:sender
/* CardTwo answer no */
{
    [self DropCardTwo:sender]; /* Drop the card method */
    [CardThree orderFront:sender];
    return self;
}

-DropCardTwo:sender
/* drop CardTwo */
{
/* Drop CardTwo window at the bottom of the screen. */
     
      X= 260;
      Y= 319;
 
      [CardTwo makeKeyWindow]; /* Selects the window */
      [CardTwo orderFront:sender]; /* Places the window in front */
        
       for (i = Y; i > -435; i=i-15) {
            [CardTwo moveTo:(X):(i)];}
/* Move window down */
       

        Y = -435; /* window is at buttom of screen */
        for (i = Y; i <700; i=i+9) {
            [CardTwo moveTo:(X):(i)];}
/* Move window upwards */
       
  
        for (i = X; i > -440; i=i-10) {
            [CardTwo moveTo:(i):(700)];}
 /* Move window to the left 
*/
    
      [CardTwo close]; /* Closes the window (Even if theres no close button on the window) */
      [CardTwo moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
      
/* end of Drop CardTwo panel */

       return self;
}

- ThreeYes:sender
/* CardThree answer yes */
{
    [self DropCardThree:sender]; /* Drop the card method */
    TOTAL=TOTAL + 4;
    [CardFour orderFront:sender];
    return self;
}

- ThreeNo:sender
/* CardOne answer no */
{
    [self DropCardThree:sender]; /* Drop the card method */
    [CardFour orderFront:sender];
    return self;
}

-DropCardThree:sender
/* drop CardThree */
{
/* Drop CardThree window at the bottom of the screen. */
     
      X= 260;
      Y= 319;
 
      [CardThree makeKeyWindow]; /* Selects the window */
      [CardThree orderFront:sender]; /* Places the window in front */
        
      for (i = X; i < 1300; i=i+20) {
            [CardThree moveTo:(i):(Y)];} /* move window to the right */
        
      
     [CardThree close];  /* Closes the window (Even if theres no close button on the window) */
     [CardThree moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
      
/* end of Drop CardThree panel */

       return self;
}


- FourYes:sender
/* CardFour answer yes */
{
    [self DropCardFour:sender]; /* Drop the card method */
    TOTAL=TOTAL + 8;
    [self WhichImage:sender];
    return self;
}

- FourNo:sender
/* CardFour answer no */
{
    [self DropCardFour:sender]; /* Drop the card method */
    [self WhichImage:sender];
    return self;
}

-DropCardFour:sender
/* drop CardFour */
{
/* Drop CardFour window at the bottom of the screen. */
     
      X= 260;
      Y= 319;
 
      [CardFour makeKeyWindow]; /* Selects the window */
      [CardFour orderFront:sender]; /* Places the window in front */
        
      for (i = Y; i > -435; i=i-10) 
      {
 [CardFour moveTo:(X):(i)];  /* move window down */
         [CardFour moveTo:(X=X-10):(i)]; }
 /* Move window to the left 
*/
        
            
         [CardFour close]; /* Closes the window (Even if theres no close button on the window) */
         [CardFour moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
      
/* end of Drop CardFour panel */

       return self;
}



- WhichImage:sender
/* assigns the number total with the proper image */
{
     
      X= 370;
      Y= 330;

      [Result makeKeyWindow]; /* Selects the window */
      [Result orderFront:sender]; /* Places the window in front */
        
       [ResultImage setIcon:"Wizard.tiff"];
       
      for (i = Y; i > 4; i=i-10) {
            [Result moveTo:(X):(i)];
} /* moves window down */
    
       [ResultImage setIcon:"Safe.tiff"];
       
      for (i = X; i > 5; i=i-10) {
            [Result moveTo:(i):(4)];}
 /* Move window to the left 
*/

    [self ResultAnimation:sender];

     for (i = 5; i < 370; i=i+10) {
            [Result moveTo:(i):(4)];} /* move window to the right */

      Y = 4; /* window is at buttom of screen */
      for (i = Y; i <330; i=i+10) {
            [Result moveTo:(370):(i)];}
/* Move window upwards */

	 
   switch (TOTAL)  { /* start switch */
   
   case 1:
          [ResultImage setIcon:"Wizard.tiff"];
	  break;
	  
   case 2:
          [ResultImage setIcon:"Dino.tiff"];
          break;
	  
   case 3:
           [ResultImage setIcon:"Karate.tiff"];
	    break;

   case 4:
           [ResultImage setIcon:"Light.tiff"];
	    break;

   case 5:
           [ResultImage setIcon:"Safe.tiff"];
	    break;

   case 6:
           [ResultImage setIcon:"PC.tiff"];
	    break;

   case 7:
           [ResultImage setIcon:"Moto.tiff"];
	    break;

   case 8:
           [ResultImage setIcon:"Boat.tiff"];
	    break;

   case 9:
           [ResultImage setIcon:"Flag.tiff"];
	    break;

   case 10:
           [ResultImage setIcon:"Cow.tiff"];
	    break;

   case 11:
           [ResultImage setIcon:"Ghost.tiff"];
	    break;
 
   case 12:
           [ResultImage setIcon:"Jolly.tiff"];
	    break;

   case 13:
           [ResultImage setIcon:"Porshe.tiff"];
	    break;

   case 14:
           [ResultImage setIcon:"Juptier.tiff"];
	    break;

   case 15:
           [ResultImage setIcon:"Elvis.tiff"];
	    break;

   default:
           [ResultImage setIcon:"MindLess.tiff"]; /* if the user does not answer properly */
	   break;

	                        } /* end switch */

    
    
    
    return self;
}


- ResultButton:sender
/* Secret button in the result panel */
{
          if (TOTAL == 1) /* Wizard selected, display the MoreInfo panel */
	  [MoreInfo orderFront:sender];
	  
	  
	  if (TOTAL == 15) /* Elvis select, do the result animation one more time. */
	  [self WhichImage:sender];
	  
	  return self;
}

- ResultAnimation:sender
/* This is the amimation for the Result panel */
{

       [ResultImage setIcon:"Dino.tiff"];
  
        Y = 4; /* window is at buttom of screen */
        for (i = Y; i <620; i=i+10) {
            [Result moveTo:(5):(i)];}
/* Move window upwards */
     
       [ResultImage setIcon:"Jolly.tiff"];

        for (i = 5; i < 770; i=i+10) {
            [Result moveTo:(i):(620)];} /* move window to the right */

       [ResultImage setIcon:"Porshe.tiff"];
	
        Y=620; /* window is at the top of the screen */
        for (i = Y; i > 4; i=i-10) {
            [Result moveTo:(770):(i)];
} /* moves window down */

        [ResultImage setIcon:"Wizard.tiff"];
	
        for (i = 770; i > 5; i=i-10) {
            [Result moveTo:(i):(4)];}
 /* Move window to the left 
*/
      
        [ResultImage setIcon:"Boat.tiff"];
	
         return self;
}
  


- closeInfo:sender
/* This method closes the Info panel and opens and displays the MoreInfo panel */
{
      [Info performClose:sender]; /* This closes the Info panel */
      [MoreInfo orderFront:sender]; /* This displays the MoreInfo panel */
      return self; /* End of closeInfo method */
 }


@end
