Module/SelectEnemy/LastScanned

From Robowiki
< Module‎ | SelectEnemy
Revision as of 18:28, 23 March 2008 by Jab (talk | contribs) (Module SelectEnemy: LastScanned)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;
	}
}