src/priestSkills.js
//// Monsters are then ordered by distance.

Monsters are then ordered by distance.
Monsters are then ordered by distance .
function find_viable_targets() {
	var monsters = Object.values(parent.entities).filter(
		mob => (mob.target == null
			|| parent.party_list.includes(mob.target)
			|| mob.target == character.name)
			&& (mob.type == "monster"
				&& (parent.party_list.includes(mob.target)
					|| mob.target == character.name))
			|| monster_targets.includes(mob.mtype));
	for (id in monsters) {
		var monster = monsters[id];
		if (parent.party_list.includes(monster.target) || monster.target == character.name) {
			monster.targeting_party = 1;
		}
		else {
			monster.targeting_party = 0;
		}
	}
	monsters.sort(function (current, next) {
		if (current.targeting_party > next.targeting_party) {
			return -1;
		}
		var dist_current = distance(character, current);
		var dist_next = distance(character, next);
		if (dist_current < dist_next) {
			return -1;
		}
		else if (dist_current > dist_next) {
			return 1
		}
		else {
			return 0;
		}
	});
	return monsters;
}
function find_viable_targets ( ) { var monsters = Object . values ( parent . entities ) . filter ( mob => ( mob . target == null || parent . party_list . includes ( mob . target ) || mob . target == character . name ) && ( mob . type == "monster" && ( parent . party_list . includes ( mob . target ) || mob . target == character . name ) ) || monster_targets . includes ( mob . mtype ) ) ; for ( id in monsters ) { var monster = monsters [ id ] ; if ( parent . party_list . includes ( monster . target ) || monster . target == character . name ) { monster . targeting_party = 1 ; } else { monster . targeting_party = 0 ; } } monsters . sort ( function ( current , next ) { if ( current . targeting_party > next . targeting_party ) { return - 1 ; } var dist_current = distance ( character , current ) ; var dist_next = distance ( character , next ) ; if ( dist_current < dist_next ) { return - 1 ; } else if ( dist_current > dist_next ) { return 1 } else { return 0 ; } } ) ; return monsters ; }
Monsters are then ordered by distance.
Monsters are then ordered by distance .
//Order monsters by whether they're attacking us, then by distance.
 // Else go to the 2nd item
