} elseif (empty($target_robot)) { die('<pre>$target_robot is empty on line ' . __LINE__ . '! :' . print_r($target_robot, true) . '</pre>'); } // Refresh the backed up target robot //$target_robot->robot_load(array('robot_id' => $backup_target_robot_id, 'robot_token' => $backup_target_robot_token)); // Back up this temp robot's abilities for later $temp_active_target_robot_abilities = $active_target_robot->robot_abilities; // Loop through the target robot's current abilities and check weapon energy $temp_abilities_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token'); $temp_abilities_backup = $active_target_robot->robot_abilities; foreach ($active_target_robot->robot_abilities as $key => $token) { // Collect the data for this ability from the index $temp_info = array('ability_id' => $key, 'ability_token' => $token); $temp_ability = new rpg_ability($target_player, $active_target_robot, $temp_info); // Determine how much weapon energy this should take $temp_ability_energy = $active_target_robot->calculate_weapon_energy($temp_ability); // If this robot does not have enough energy for the move, remove it if ($active_target_robot->robot_weapons < $temp_ability_energy) { unset($active_target_robot->robot_abilities[$key]); continue; } } // If there are no abilities left to use, the robot will automatically enter a recharge state if (empty($active_target_robot->robot_abilities)) { $active_target_robot->robot_abilities[] = 'action-noweapons'; } // Update the robot's session with ability changes $active_target_robot->update_session(); // Collect the ability choice from the robot $temp_token = $active_target_robot->robot_choices_abilities($this_player, $this_robot); $temp_id = array_search($temp_token, $active_target_robot->robot_abilities);