
import java.io.*;
import java.util.*;


public class MissionCard
{
   /**
     * Holds the ID of the certain Mission Card
     */
    public int ID;
    /**
     * Holds the String of letters to describe what Missions succeeded in the Urban Environ
     */
    public String urban_succeed;
    /**
     * Holds the String of letters to describe what Missions succeeded in the Wild Environ
     */
    public String wild_succeed;
    /**
     * Holds the String of letters to describe what Missions succeeded in the Special Environ
     */
    public String special_succeed;
    /**
     * Holds the String to describe the Action Event that happened inside an Urban Environ
     */
    public String urban_info;
    /**
     * Holds the String to describe the Action Event that happened inside a Wild Environ
     */
    public String wild_info;
    /**
     * Holds the String to describe the Action Event that happened inside a Special Environ
     */
    public String special_info;
    /**
     * The array of all 30 Mission Cards
     */
    private static MissionCard [] mcard;
    /**
     * Constructs a Mission Card instance
     */
    public MissionCard(int IDval, String us, String ws, String ss, 
		       String ui, String wi, String si)
    {
	ID=IDval;
	urban_succeed=us;
	wild_succeed=ws;
	special_succeed=ss;
	urban_info=ui;
	wild_info=wi;
	special_info=si;
    }

    /**
     *Initializes the static mcard array--the deck of mission action cards
     */
    public static void init()
    {
	mcard=new MissionCard[30];
	mcard[0]=new MissionCard(68, "RH", "P", "B", "Creature attacks one mission group if a creature exists in the environ.",
            "Locals shelter characters from enemy.  No enemy searches may be conducted in this environ for the remainder of this mission phase.", 
            "Locals raid enemy forces.  Nonphasing player must eliminate one of his military units in the environ or if he controls a PDB that is up on the planet, place it down (non-Phasing player's choice)");

	mcard[1]=new MissionCard(69, "D", "PI", "CS", "Creature attacks one mission group.  If no creature exists, attack is by a sentry robot.", 
            "Coup mission aborted; characters detected (random effects).", 
            "Weather disturbances hamper enemy operation.  The nonphasing player may conduct no searches in this environ this mission phase.");

	mcard[2]=new MissionCard(70, "PI", "RG", "SC", "Creature attacks one Mission Group.  If no creature exists, attack is by two sentry robots.", 
            "Locals raid Enemy forces.  Non-Phasing Player must eliminate one of his military units in the Environ, or, If he controls a PDB that is Up on the planet, place it Down (non-Phasing Player's choice)", 
            "Characters detected.");

	mcard[3]=new MissionCard(71, "CJ", "PG", "BT", "Irate locals attack one Mission Group.", 
            "Weather disturbances hamper Enemy operations.  The non-Phasing Player may conduct no searches this Environ this Mission Phase", 
            "Would-be rebels chicken out.  Start Rebellion mission aborted.  Characters detected.");

	mcard[4]=new MissionCard(72, "PG", "DH", "C", "Irate locals attack one Mission Group.", 
            "The Imperial Player may commit an Atrocity this planet (Galactic Game only, otherwise ignore event).", 
            "Controversial political matters argued.  If a Diplomacy mission is being performed, and no character in the Mission Group has a Diplomacy Rating of two or more, the mission is aborted.");

	mcard[5]=new MissionCard(73, "D", "RS", "GI", "Would-be rebels chicken out.  Start Rebellion mission aborted.  Characters detected.", 
            "Wrong soldier contacted.  If a Subvert Troops mission is being performed, it is aborted.  Mission group found by Enemy squad.  If an Enemy leader is stacked with the Enemy military units, the entire Mission Group is captured.", 
            "Weather disturbances hamper Enemy operations.  The non-Phasing Player may conduct no searches in this Environ this Mission Phase.");

	mcard[6]=new MissionCard(74, "P", "C", "BH", "Enemy agent reveals mission.  The non-Phasing Player randomly chooses one mission that the Phasing player is currently performed in the Environ; that mission is aborted.  Characters detected.", 
            "Creature attacks one Mission Group.  If no creature exists, ignore event.", 
            "Irate locals attack one Mission Group.");

	mcard[7]=new MissionCard(75, "FG", "AH", "D", "Characters detected.", 
            "Creature attacks one Mission Group.  If no creature exists, attack is by a sentry robot.", 
            "Populace goes wild.  If the planet is placed into rebellion during this Mission Phase, the Rebel Player recieves double the resource value in this Environ.");

	mcard[8]=new MissionCard(76, "A", "FB", "BE", "Locals shelter characters from enemy.  No enemy searches may be conducted in this Environ for the remainder of this Mission Phase.", 
            "Coup Mission aborted; Characters detected (random effects)", 
            "Creature attacks one Mission Group.  If no creature exists, attack is by a sentry robot.");

	mcard[9]=new MissionCard(77, "C", "FI", "SE", "Weather disturbances hamper Enemy operations.  The non-Phasing Player may conduct no searches in this Environ this Mission Phase.", 
            "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.", 
            "Coup mission aborted; characters detected. (random effects)");

	mcard[10]=new MissionCard(78, "CS", "FP", "DG", "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.", 
            "Characters are delayed by rumors.  No bonus draws may be taken in this Environ this Mission Phase.", 
            "Coup mission aborted; characters detected (random effects)");

	mcard[11]=new MissionCard(79, "SH", "B", "GP", "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.", 
            "Civil war breaks out.  The populace blames the Phasing Player.  If the Loyalty marker is currently at 1 or 2 in the Player's favor, it will move to Neutral.  If the Planet is in rebellion or not in the Player's favor, ignore event.", 
            "Creature attacks one Mission Group.  If a creature does not exist, attack is by a sentry robot.");

	mcard[12]=new MissionCard(80, "RE", "CS", "FP", "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.", 
            "One Mission Group stumbles on Enemy squad.  If the Enemy Player controls the planet and has military units in the environ, character combat is initiated.", 
            "Confusing local protocol aborts a Diplomacy mission.  If one is being performed in the Environ, the loyalty marker will move 1 space in favor for the non-phasing player.");

	mcard[13]=new MissionCard(81, "FI", "E", "CT", "Wrong soldier contacted.  If a Subvert Troops mission is being performed, it is aborted.  Mission Group found by enemy squad.  If an Enemy leader is stacked with the enemy military units, entire mission group is captured.", 
            "Controversial political matters argued.  If a Diplomacy mission is being performed, and no character in the Mission Group has a Diplomacy rating of two or more, the mission is aborted.", 
            "Accidents will happen, especially in an unfamiliar Environ.  Any one character performing a mission in the Environ must recieve a wound.");

	mcard[14]=new MissionCard(82, "G", "D", "RS", "Civil war breaks out.  The populace blames the Phasing Player.  If the loyalty marker is currently at 1 or 2 in the Player's favor, the marker will change to 0 (Neutral).  If the planet is in rebellion or not in the Player's favor, ignore event.", 
            "Populace goes wild!  If the planet is placed into rebellion during this Mission Phase, the Rebel Player recieves double the resource value in this Environ.", 
            "Weather disturbances hamper Enemy operations.  The Non-Phasing Player may conduct no searches in this Environ this Mission Phase.");

	mcard[15]=new MissionCard(83, "DS", "F", "RQ", "Locals raid Enemy forces.  Non-Phasing Player must eliminate one of his military units in the Environ, or if he controls a PDB that is Up on the planet, place it Down (Non-Phasing Player's choice)", 
            "Would-be rebels chicken out.  Start Rebellion mission aborted.  Characters detected.", 
            "Characters detected.  Enemy Player may conduct a search for one Mission Group in the Environ. (randomly selected if more than 1 exist in the Environ)");

	mcard[16]=new MissionCard(84, "FP", "SH", "R", "Locals raid Enemy forces.  Non-Phasing Player must eliminate one of his military units in the Environ, or, if he controls a PDB that is Up on the planet, place it Down (Non-Phasing Player's choice).", 
            "Characters detected.", 
            "Creature attacks one Mission Group. If no creature is named, attack is by two sentry robots.");

	mcard[17]=new MissionCard(85, "GI", "SE", "R", "Populace goes wild!  If a planet is placed into rebellion during this Mission Phase, the Rebel Player recieves double the resource value in this Environ.", 
            "Creature attacks one Mission Group.  If no creature exists, mission group is attacks by two sentry robots.", 
            "Characters detected.  Enemy Player may conduct search for one Mission Group in Environ.");

	mcard[18]=new MissionCard(86, "FI", "CT", "AJ", "Characters detected.  Enemy Player may conduct search for one Mission Group in Environ.", 
            "Characters detected.  Enemy Player may conduct search for one Mission Group in Environ.", 
            "Characters are delayed by rumors.  No bonus draws may be taken in this Environ this Mission Phase.");

	mcard[19]=new MissionCard(87, "SC", "FG", "R", "Disagreeable food substance hampers characters.  No bonus draws may be taken in this Environ this Mission Phase.", 
            "Characters detected.  Enemy player may conduct search for one Mission Group in Environ (Group randomly selected).", 
            "Coup mission aborted; (Random effects 1,2 no effect 3,4 loyalty down 1 space 5,6 shift loyalty and mission group found by enemy squad or characters (non-phasing players choice).");

	mcard[20]=new MissionCard(88, "T", "BJ", "F", "Characters are delayed by rumors.  No bonus draws may be taken in this Environ this Mission Phase.", 
            "Weather disturbances hamper Enemy operations.  The Non-Phasing Player may conduct no searches in this Environ this Mission Phase.", 
            "One Mission Group stumbles on Enemy squad.  If the Enemy Player controls the planet and has military units in the Environ, character combat is initiated.");

	mcard[21]=new MissionCard(89, "CE", "R", "P", "The Imperial Player may commit an Atrocity on this planet. (Galactic game only, otherwise ignore event).", 
            "Local connections expedite mission.  All missions recieve one extra bonus draw in this Environ this Mission Phase.", 
            "Civil war breaks out.  The populace blames the Phasing Player.  If the Loyalty marker is currently at 1 or 2 in the Players favor, the marker will change to 0 (Neutral).  If planet is in Rebellion or not in the Player's favor, ignore event.");

	mcard[22]=new MissionCard(90, "B", "GI", "CH", "Confusing local protocol aborts a Diplomacy mission.  If one is being performed in the Environ, the Loyalty marker will shift one space in the Non-Phasing Player's favor.", 
            "Confusing local protocol aborts Diplomacy mission.  If one is being performed in the Environ, shift the Loyalty marker will shift one space in the Non-Phasing Player's favor.", 
            "Enemy agent reveals mission.  The Non-Phasing Player randomly chooses one mission that the Phasing Player is currently performing in the Environ; that mission is aborted.  Characters detected.");

	mcard[23]=new MissionCard(91, "BE", "RQ", "P", "Controversial political matters argued.  If a Diplomacy mission is being performed, and no character in the Mission Group has a Diplomacy rating of two or more, the Mission is Aborted.", 
            "Irate Locals attack one Mission Group.", 
            "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.");

	mcard[24]=new MissionCard(92, "SG", "RT", "FI", "Coup mission aborted; (random effects to mission group with Coup Mission)", 
            "It's the off-season for the local creatures.  Ignore all \"Creature Attacks\" events in this Environ this Mission Phase.", 
            "Local connections expedite missions.  All missions recieve one extra bonus draw in this Environ this Mission Phase.");

	mcard[25]=new MissionCard(93, "RB", "SC", "F", "Coup mission aborted; (random effects to mission group with Coup Mission)", 
            "Confusing local protocol aborts a Diplomacy mission.  If one is being performed in the Environ, the loyalty marker will shift one space in the Non-Phasing Player's favor.", 
            "The Imperial Player may commit an Atrocity on this planet. (Galactic game only, otherwise ignore event).");

	//This one is not comlete (see si argument)
	mcard[26]=new MissionCard(94, "DQ", "BE", "FG", "Coup mission aborted; (random effects 1-3 loyalty down one 4-6 loyalty changed and mission group found by enemy squad or characters (non-phasing players choice)", 
            "Populace goes wild!  If the planet is placed into rebellion during this Mission Phase, the Rebel Player recieves double the resource value in this Environ.", 
            "Disagreeable food substance hampers characters.  No bonus draws may be taken in this Environ this mission phase");

	mcard[27]=new MissionCard(95, "RH", "B", "FI", "Characters detected.  Enemy Player may conduct search for one Mission Group in Environ (Randomly selected).", 
            "Creature attacks one Mission Group.  If no creature exists, attack is by two sentry robots.", 
            "Populace goes wild!  If a planet is placed into rebellion during this Mission Phase, the Rebel Player recieves double the resource value in this Environ.");

	mcard[28]=new MissionCard(96, "AT", "P", "DE", "Characters detected.  Enemy player may conduct search for one Mission Group in Environ (Randomly selected).", 
            "Dissagreeable food substance hampers characters.  No bonus draws may be taken in this Environ this Mission Phase.", 
            "Wrong soldier contacted.  If a Subvert Troops mission is being performed, it is aborted.  Mission Group found by Enemy squad.  If an Enemy leader is stacked with Enemy military units, entire Mission Group is captured.");

	mcard[29]=new MissionCard(97, "F", "D", "SH", "Populace goes wild!  If the planet is placed into rebellion during the Mission Phase, the Rebel Player recieves double the resource value in this Environ.", 
            "Enemy agent reveals mission.  The non-phasing player chooses one mission that the Phasing Player is currently performing in the Environ; that mission is aborted.  Characters detected.", 
            "Creature attacks one Mission Group.  If no creature exists, ignore event.");
    }
    /**
     *Shuffles the mcard deck
     */
    public static void shuffle()
    {
        int i, j;
        Vector mcard_s=new Vector();
        for(i=0;i<30;i++)
            mcard_s.add(mcard[i]);
        for(i=0;i<30;i++)
        {
            j=(int)(mcard_s.size()*Math.random());
            mcard[i]=(MissionCard)(mcard_s.elementAt(j));
            mcard_s.removeElementAt(j);
        }
    }
    /**
     *returns the 0'th mission action card from the deck (mcard) and puts it on the bottom of the deck.
     */
    public static MissionCard Draw()
    {
        MissionCard temp=mcard[0];
        for(int i=0;i<29;i++)
            mcard[i]=mcard[i+1];
        mcard[29]=temp;
        return temp;
    }
    
    /**
     * The Event of a card depending on what ID is entered
     */
    public void Event(MissionAction MA)
    {
        char etype=MA.currenv.getType();
        MA.InfoPanel.removeAll();
        javax.swing.JTextArea CardInfo=new javax.swing.JTextArea();
        MA.InfoPanel.add(CardInfo);
        CardInfo.setBounds(5, 5, 345, 30);
        CardInfo.setEditable(false);
        CardInfo.setLineWrap(true);
        CardInfo.setBackground(java.awt.Color.black);
        CardInfo.setForeground(java.awt.Color.white);
        MA.InfoPanel.repaint();
        switch(etype)   //Sets the info field on the MissionAction GUI
        {
            case 'u':
            case 'U':
                CardInfo.setText(urban_info);
                break;
            case 'w':
            case 'W':
                CardInfo.setText(wild_info);
                break;
            default:
                CardInfo.setText(special_info);
        }
        switch(ID-68)  //Performs the operations dictated by the particular card drawn
        {
            case 0:
                if(etype=='u' || etype=='U')    //implements "Creature attacks one mission group if a creature exists in the environ."
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 0))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else if(etype=='w' || etype=='W')   //implements "Locals shelter characters from enemy.  No enemy searches may be conducted in this environ for the remainder of this mission phase."
                {
                    LocalsShelterCharacters(MA.MissionGroups, MA.currenv);
                }
                else    //implements "Locals raid enemy forces.  Nonphasing player must eliminate one of his military units in the environ or if he controls a PDB that is up on the planet, place it down (non-Phasing player's choice)"
                {
                    LocalsRaidEnemy(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 1:
                if(etype=='u' || etype=='U')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 1))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else if(etype=='w' || etype=='W')
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 2:
                if(etype=='u' || etype=='U')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 2))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else if(etype=='w' || etype=='W')
                {
                    LocalsRaidEnemy(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 3:
                if(etype=='u' || etype=='U')
                {
                     if(IrateLocalsAttack(MA.MissionGroups, MA.currenv))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else if(etype=='w' || etype=='W')
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    RebelsChickenOut(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 4:
                if(etype=='u' || etype=='U')
                {
                     if(IrateLocalsAttack(MA.MissionGroups, MA.currenv))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else if(etype=='w' || etype=='W')
                {
                    ImperialAtrocity(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    PoliticalArgument(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 5:
                if(etype=='u' || etype=='U')
                {
                    RebelsChickenOut(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    WrongSoldierContacted(MA.MissionGroups, MA.currenv);
                    FoundByEnemySquad(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 6:
                if(etype=='u' || etype=='U')
                {
                    EnemyAgentRevealsMission(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 0))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else
                {
                     if(IrateLocalsAttack(MA.MissionGroups, MA.currenv))
			{ MA.numdrawn = MA.currenv.getSize(); };
                }
                break;
                
            case 7:
                if(etype=='u' || etype=='U')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 1))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 8:
                if(etype=='u' || etype=='U')
                {
                    LocalsShelterCharacters(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 1))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                break;
                
            case 9:
                if(etype=='u' || etype=='U')
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 10:
                if(etype=='u' || etype=='U')
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    DelayedByRumors(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 11:
                if(etype=='u' || etype=='U')
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CivilWar(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 1))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                break;
                
            case 12:
                if(etype=='u' || etype=='U')
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    MGStumblesEnemySquad(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    ConfusingLocalProtocol(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 13:
                if(etype=='u' || etype=='U')
                {
                    WrongSoldierContacted(MA.MissionGroups, MA.currenv);
                    FoundByEnemySquad(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    PoliticalArgument(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    AccidentsWillHappen(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 14:
                if(etype=='u' || etype=='U')
                {
                    CivilWar(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 15:
                if(etype=='u' || etype=='U')
                {
                    LocalsRaidEnemy(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    RebelsChickenOut(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                else
                {
                   CharactersDetected(MA.MissionGroups, MA.currenv); 
                }
                break;
                
            case 16:
                if(etype=='u' || etype=='U')
                {
                    LocalsRaidEnemy(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 2))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                break;
                
            case 17:
                if(etype=='u' || etype=='U')
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 2))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 18:
                if(etype=='u' || etype=='U')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    DelayedByRumors(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 19:
                if(etype=='u' || etype=='U')
                {
                    DisagreeableFoodSubstance(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 20:
                if(etype=='u' || etype=='U')
                {
                    DelayedByRumors(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    WeatherDisturbances(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    MGStumblesEnemySquad(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 21:
                if(etype=='u' || etype=='U')
                {
                    ImperialAtrocity(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    CivilWar(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 22:
                if(etype=='u' || etype=='U')
                {
                    ConfusingLocalProtocol(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    ConfusingLocalProtocol(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    EnemyAgentRevealsMission(MA.MissionGroups, MA.currenv);
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 23:
                if(etype=='u' || etype=='U')
                {
                    PoliticalArgument(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    if(IrateLocalsAttack(MA.MissionGroups, MA.currenv))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                else
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 24:
                if(etype=='u' || etype=='U')
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    CreatureOffSeason(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    LocalConnections(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 25:
                if(etype=='u' || etype=='U')
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    ConfusingLocalProtocol(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    ImperialAtrocity(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 26:
                if(etype=='u' || etype=='U')
                {
                    CoupAborted(MA.MissionGroups, MA.currenv);
//This one is special!!!
                }
                else if(etype=='w' || etype=='W')
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                else
                {
//Needs to be implemented
                }
                break;
                
            case 27:
                if(etype=='u' || etype=='U')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 2))
			{  MA.numdrawn = MA.currenv.getSize(); }
                }
                else
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 28:
                if(etype=='u' || etype=='U')
                {
                    CharactersDetected(MA.MissionGroups, MA.currenv);
                    EnemyMaySearch(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    DisagreeableFoodSubstance(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    WrongSoldierContacted(MA.MissionGroups, MA.currenv);
                    FoundByEnemySquad(MA.MissionGroups, MA.currenv);
                }
                break;
                
            case 29:
                if(etype=='u' || etype=='U')
                {
                    PopulaceGoesWild(MA.MissionGroups, MA.currenv);
                }
                else if(etype=='w' || etype=='W')
                {
                    EnemyAgentRevealsMission(MA.MissionGroups, MA.currenv);
                }
                else
                {
                    if(CreatureAttack(MA.MissionGroups, MA.currenv, 0))
			{ MA.numdrawn = MA.currenv.getSize(); }
                }
                break;
                
        }
        MA.EnvironCombo.setSelectedIndex(MA.EnvironCombo.getSelectedIndex());
    }
    //some of these methods may need other parameters and some may not even need the missiongroup vector argument
    /**
     *to be called when "Creature attacks a mission group" is called for
     */
    public boolean CreatureAttack(Vector MGs, Environ env, int sentrys)
    {
	boolean dead;
        MissionGroup randomgroup=((MissionGroup)(MGs.elementAt((int)(Math.random()*MGs.size()))));
        if(randomgroup.creatureoffseason)
            return false;
	System.out.println(env.getCreature() + "\n");
        if(env.getCreature().equals(""))
        {
            dead = randomgroup.SentryCombat(sentrys);
        }
        else
        {
            dead = randomgroup.MonsterCombat();
        }
	if(dead)
        {
	    randomgroup.NoBonusDraws();
            randomgroup.missionover=true;
        }
	return dead;
    }
    public void LocalsShelterCharacters(Vector MGs, Environ env)
    {
        ((MissionGroup)(MGs.elementAt(0))).nosearches=true;
    }
    public void LocalsRaidEnemy(Vector MGs, Environ env)
    {
    }
    public void CoupAborted(Vector MGs, Environ env)
    {
        int i;
        for(i=0;i<MGs.size() && ((MissionGroup)(MGs.elementAt(i))).getMissionType()!='C';i++);
        if(i==MGs.size())
            return;
        int diceroll=(int)(Math.random()*6);
        switch(diceroll)
        {
            case 1:
            case 2:
                break;
            case 3:
            case 4:
                switch(fitg.thisGame.getPhasingPlayer())
                {
                    case 0:
                        ((MissionGroup)(MGs.elementAt(0))).getPlanet().setLoyalty(-1);
                        break;
                    case 1:
                        ((MissionGroup)(MGs.elementAt(0))).getPlanet().setLoyalty(1);
                        break;
                }
                break;
            case 5:
            case 6:
                for(i=0;i<MGs.size() && ((MissionGroup)(MGs.elementAt(i))).getMissionType()!='C';i++)
                {
                    ((MissionGroup)(MGs.elementAt(i))).setcapture(true);
                }
        }
                
        for(i=0;i<MGs.size();i++)
        {
            if(((MissionGroup)(MGs.elementAt(i))).getMissionType()=='C')
                ((MissionGroup)(MGs.elementAt(i))).AbortMission();
        }
    }
    public void WeatherDisturbances(Vector MGs, Environ env)
    {
        for(int i=0;i<MGs.size();i++)
            ((MissionGroup)(MGs.elementAt(i))).nosearches=true;
    }
    public void CharactersDetected(Vector MGs, Environ env)
    {
        MissionGroup mgtemp;
        Charactr ctemp;
        for(int i = 0; i < MGs.size(); i++)
        {
            mgtemp=(MissionGroup)(MGs.elementAt(i));
            for(int j = 0; j < mgtemp.getGroup().size(); j++)
            {
               ctemp=(Charactr)(mgtemp.getGroup().elementAt(j));
               ctemp.setIsDetected(true);
            }
        }
    }
    public boolean IrateLocalsAttack(Vector MGs, Environ env)
    {
	boolean dead;
        MissionGroup randomgroup=((MissionGroup)(MGs.elementAt((int)(Math.random()*MGs.size()))));
        if(randomgroup.creatureoffseason)
            return false;
	System.out.println(env.getCreature() + "\n");
	dead = randomgroup.IrateLocals();
	if(dead)
	      randomgroup.NoBonusDraws();
	return dead;
	  
    }
    public void RebelsChickenOut(Vector MGs, Environ env)
    {
        for(int i=0;i<MGs.size();i++)
        {
            if(((MissionGroup)(MGs.elementAt(i))).getMissionType()=='R')
                ((MissionGroup)(MGs.elementAt(i))).AbortMission();
        }
    }
    public void ImperialAtrocity(Vector MGs, Environ env)
    {
    }
    public void PoliticalArgument(Vector MGs, Environ env)
    {
        int i, j;
        for(i=0;i<MGs.size();i++)
        {
            MissionGroup mgtemp=(MissionGroup)(MGs.elementAt(i));
            for(j=0;j<mgtemp.getGroup().size();j++)
            {
                if(((Charactr)((mgtemp.getGroup()).elementAt(j))).getDiplomacy()>=2)
                    break;
            }
            if(j==mgtemp.getGroup().size())
                mgtemp.AbortMission();
        }
    }
    public void WrongSoldierContacted(Vector MGs, Environ env)
    {
        for(int i=0;i<MGs.size();i++)
        {
            if(((MissionGroup)(MGs.elementAt(i))).getMissionType()=='T')
                ((MissionGroup)(MGs.elementAt(i))).AbortMission();
        }
    }
    public void FoundByEnemySquad(Vector MGs, Environ env)
    {
    }
    public void EnemyAgentRevealsMission(Vector MGs, Environ env)
    {
    }
    public void PopulaceGoesWild(Vector MGs, Environ env)
    {
    }
    public void LocalConnections(Vector MGs, Environ env)
    {
        for(int i=0;i<MGs.size();i++)
            ((MissionGroup)(MGs.elementAt(i))).extrabonusdraws++;
    }
    public void DelayedByRumors(Vector MGs, Environ env)
    {
        int i;
        for(i=0;i<MGs.size();i++)
            ((MissionGroup)(MGs.elementAt(i))).NoBonusDraws();
        javax.swing.JOptionPane.showMessageDialog(null, "No Bonus Draws in this environ");
    }
    public void CivilWar(Vector MGs, Environ env)
    {
    }
    public void MGStumblesEnemySquad(Vector MGs, Environ env)
    {
    }
    public void ConfusingLocalProtocol(Vector MGs, Environ env)
    {
        int i;
        int check;
        for(i=0;i<MGs.size();i++)
        {
            if(((MissionGroup)(MGs.elementAt(i))).getMissionType()=='D')
                ((MissionGroup)(MGs.elementAt(i))).AbortMission();
        }
        for(i=0;i<MGs.size() && ((MissionGroup)(MGs.elementAt(i))).getMissionType()!='D';i++);
        if(i!=MGs.size())
        {
            switch(fitg.thisGame.getPhasingPlayer())
            {
                case 0:
                    check = ((MissionGroup)(MGs.elementAt(0))).getPlanet().getLoyalty();
                    ((MissionGroup)(MGs.elementAt(0))).getPlanet().setLoyalty(check-1);
                case 1:
                    check = ((MissionGroup)(MGs.elementAt(0))).getPlanet().getLoyalty();
                    ((MissionGroup)(MGs.elementAt(0))).getEnviron().getPlanet().setLoyalty(check+1);
            }
        }
    }
    public void AccidentsWillHappen(Vector MGs, Environ env)
    {
    }
    public void EnemyMaySearch(Vector MGs, Environ env)
    {
        MissionGroup randomgroup=((MissionGroup)(MGs.elementAt((int)(Math.random()*MGs.size()))));
        if(MGs!=null && MGs.size()>0 && ((MissionGroup)(MGs.elementAt(0))).nosearches==true)
            return;
        randomgroup.getEnviron().search(fitg.thisGame.getPlayerTurn(), randomgroup);
    }
    public void DisagreeableFoodSubstance(Vector MGs, Environ env)
    {
        for(int i=0;i<MGs.size();i++)
        {
            ((MissionGroup)(MGs.elementAt(i))).NoBonusDraws();
        }
        javax.swing.JOptionPane.showMessageDialog(null, "No Bonus Draws in this environ");
    }
    public void CreatureOffSeason(Vector MGs, Environ env)
    {
        ((MissionGroup)(MGs.elementAt(0))).creatureoffseason=true;
    }
};

