// Yura Mamyrin

package risk.engine.ai;

import risk.engine.*;
import risk.engine.core.*;

import java.util.*;

/**
 * <p> Class for AIEasyPlayer </p>
 * @author Yura Mamyrin
 */

public class AIEasy extends AICrap {

    public String getAttack() {

		Vector t = player.getTerritoriesOwned();
		Vector n;

		Vector outputs = new Vector();

		for (int a=0; a< t.size() ; a++) {

		    if ( ((Country)t.elementAt(a)).getArmies() > 1 ) {

			n = ((Country)t.elementAt(a)).getNeighbours();

			for (int b=0; b< n.size() ; b++) {
			    if ( ((Country)n.elementAt(b)).getOwner() != player ) {
				outputs.add( "attack " + ((Country)t.elementAt(a)).getColor() + " " + ((Country)n.elementAt(b)).getColor() );
			    }
			}

		    }

		}

		if (outputs.size() > 0) {

			return (String)outputs.elementAt( (int)Math.round(Math.random() * (outputs.size()-1) ) );

		}

		return "endattack";

    }

}
