/**
 * Player is the superclass to the HumanPlayer and AI classes, currently we
 * have documentation about Victory Points which will be in the HumanPlayer
 * class.  It can be found <a href="doc-files/GameGroup.html#use">here</a>.
 *  Also we have diagrams and charts for it
 * <a href="doc-files/GameGroup.html#chart">here</a> and
 * <a href="doc-files/GameGroup.html#coll">here</a>.
 */
public class Player{

   private char playerType; // a = AI, h = human
   
   /**
    * Just a guess at how we might reference the
    * units owned by the player
    */

   protected Group playerUnits;
   static protected int forcePoints;
   protected int victoryPoints;
   protected Planet planets[];

   // CONSTRUCTOR METHOD
   public void Player( char x ){
       if( x == 'a' ) playerType = 'a';
       else playerType = 'h';
   }


   // SET METHODS:

   // returns true if attempt to set player 
   // type is successful, false if it fails
   public boolean setPlayerType(char c){
       if( c != 'a' || c != 'h' )  return false;
       playerType = c;
       return true;
   }

   // set the force points with +/- (int) values
   // + for awarding,- for usage
   public static void setForcePoints(int fpoints) {
      if((forcePoints + fpoints) < 0)
	  	 forcePoints= 0;
	  else 
	     forcePoints += fpoints;
   }
   
   /**
    * method to go through all the Planets controlled
	*  by the Player, and collect forcePoints from the
	*  Environs on the Planet
	* @author Team Rebellion (Stan V)
	*/
   public void collectForcePoints() {
      Planet [] planet= Planet.getUnderworld();
	  Environ [] localEnvirons;
	  int tempPoints= 0;
	  int numEnvirons= 0;
	  
	  for(int i= 0; i<51; i++) {
	     if(planet[i].getPlanetControl() == 2) {
		 
		    numEnvirons= planet[i].getNumEnvirons();
			localEnvirons= planet[i].getPlanetEnvirons();
			
			for(int j= 0; j<numEnvirons; j++) {
			   tempPoints+= localEnvirons[j].getResourceRating();
			}
		 }
	  }
	  
	  forcePoints= tempPoints;
   }
   
   // GET METHODS:

   // returns a character to indicate whether
   // the player is human or ai
   public char getPlayerType(){
      return playerType;
   }

   // return the player force points
   public static int getForcePoints() {
      return forcePoints;
   }
   
   // probably unnecessary, but handy:
   public boolean isPlayerHuman(){
      if( playerType != 'h' ) return false;
      return true;
   }

   // again, probably unnecessary, but handy:
   public boolean isPlayerAI(){
      if( playerType != 'a' ) return false;
      return true;
   }

   /**
    * This method is needed by both but must be overridden
    * relates to how player behaves when reacting in enemy
    * players "enemy reacts" segment
    */
   public void react(){}

   /**
    * This method is needed by both but must be overridden
    * relates to player decision to search for detected enemy
    * characters
    */
   public void search(){}
 
   /**
    * This method is needed by both but must be overridden
    * relates to player decision to move units/characters
    */
   public void move(){}
}
