Module/SelectEnemy/LastScanned

From Robowiki
Jump to navigation Jump to search
package jab.selectEnemy;

import java.util.Iterator;

import jab.Enemy;
import jab.Module;
import jab.SelectEnemy;

public class LastScanned extends SelectEnemy {

	public LastScanned(Module bot) {
		super(bot);
	}

	public void select() {
		Iterator<Enemy> iterator= bot.enemies.values().iterator();
		int maxTime= Integer.MIN_VALUE;
		Enemy selected=null;
		while (iterator.hasNext()){
			Enemy e= iterator.next();
			if (maxTime<e.timeScanned){
				selected=e;
				maxTime=e.timeScanned;
			}				
		}
		bot.enemy=selected;
	}
}