Difference between revisions of "Module/SelectEnemy/LastScanned"

From Robowiki
Jump to navigation Jump to search
(Module SelectEnemy: LastScanned)
 
m (Using <syntaxhighlight>.)
 
Line 1: Line 1:
<pre>
+
<syntaxhighlight>
 
package jab.selectEnemy;
 
package jab.selectEnemy;
  
Line 28: Line 28:
 
}
 
}
 
}
 
}
</pre>
+
</syntaxhighlight>

Latest revision as of 09:29, 1 July 2010

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;
	}
}