private function check_for_target($id, $sector, $email) { /*This has been altered, as before when xenobes where targeting players they where targeting in sequence depending on the users ID. Therfore if the xenobe attacked the first player and survived, it would then move on to attack the next player with less force*/ $sql_manager = new manage_table(); $find_me = "sector='" . $sector . "' AND email!='" . $email . "' AND email NOT LIKE '%@xenobe' AND planet_id=0 AND ship_id > 1"; $found_player = $sql_manager->find_player("*", "ships", $find_me); //return $found_player; $potential_targets = array(); $n = 0; if ($found_player) { foreach ($found_player as $found_row) { /*Now build an array of targets for the xenobe to pick from*/ array_push($potential_targets, $found_row['ship_id']); $n++; } } /*Randomly select a target*/ $selected = array_rand($potential_targets, 1); return $potential_targets[$selected]; }