question: public Creature calculateNextCreature ( final int questLevel ) { final List < Creature > possibleCreaturesToSpawn = new ArrayList < Creature > ( ) ; int lastLevel = 0 ; for ( final Creature creature : sortedCreatures ) { if ( creature . getLevel ( ) > questLevel ) { break ; } if ( creature . getLevel ( ) > lastLevel ) { possibleCreaturesToSpawn . clear ( ) ; lastLevel = creature . getLevel ( ) ; } possibleCreaturesToSpawn . add ( creature ) ; } Creature creatureToSpawn = null ; if ( possibleCreaturesToSpawn . size ( ) == 0 ) { creatureToSpawn = sortedCreatures . get ( sortedCreatures . size ( ) - 1 ) ; } else { Collections . shuffle ( possibleCreaturesToSpawn ) ; creatureToSpawn = possibleCreaturesToSpawn . get ( 0 ) ; } return creatureToSpawn ; }
target:  Calculates which type of creature should be spawned next.