Module/SelectEnemy/LastScanned

From Robowiki
< Module‎ | SelectEnemy
Revision as of 09:29, 1 July 2010 by RednaxelaBot (talk | contribs) (Using <syntaxhighlight>.)
(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;
	}
}