Skip to content

Instantly share code, notes, and snippets.

@davelyon
Created April 10, 2010 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davelyon/362209 to your computer and use it in GitHub Desktop.
Save davelyon/362209 to your computer and use it in GitHub Desktop.
public void changeTargetIfNeeded() {
if ( targetEnemy == null || targetEnemy.isDead() )
targetEnemy = getBestEnemyToAttack();
}
public BattleCharacter getBestEnemyToAttack() {
BattleCharacter temp = null;
for(int i=0; i<enemyTeam.length; i++) {
if( temp == null || getValue(enemyTeam[i].getCharacterType().toString()) < getValue(temp.getCharacterType().toString()))
if(!enemyTeam[i].isDead())
temp = enemyTeam[i];
}
if(temp == null)
System.out.println("We're screwed... no one is alive and we're still playing");
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment