exit;
}
// Require the PASSWORDS file for this player
if (!defined('MMRPG_SCRIPT_REQUEST')) {
    require 'prototype_dr-xxx_passwords.php';
}
// Require the MISSIONS file for this player
require 'prototype_dr-xxx_missions.php';
// Define the robot options and counter for this mode
if (empty($_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options'])) {
    $this_prototype_data['robot_options'] = !empty($mmrpg_index['players'][$this_prototype_data['this_player_token']]['player_robots']) ? $mmrpg_index['players'][$this_prototype_data['this_player_token']]['player_robots'] : array();
    foreach ($this_prototype_data['robot_options'] as $key => $info) {
        if (!rpg_game::robot_unlocked($this_prototype_data['this_player_token'], $info['robot_token'])) {
            unset($this_prototype_data['robot_options'][$key]);
        } else {
            $temp_settings = rpg_game::robot_settings($this_prototype_data['this_player_token'], $info['robot_token']);
            $this_prototype_data['robot_options'][$key]['original_player'] = !empty($temp_settings['original_player']) ? $temp_settings['original_player'] : $this_prototype_data['this_player_token'];
            $this_prototype_data['robot_options'][$key]['robot_abilities'] = !empty($temp_settings['robot_abilities']) ? $temp_settings['robot_abilities'] : array();
            $this_prototype_data['robot_options'][$key]['robot_item'] = !empty($temp_settings['robot_item']) ? $temp_settings['robot_item'] : '';
        }
    }
    $this_prototype_data['robot_options'] = array_values($this_prototype_data['robot_options']);
    usort($this_prototype_data['robot_options'], array('rpg_prototype', 'sort_robots_position'));
    $_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options'] = $this_prototype_data['robot_options'];
} else {
    $this_prototype_data['robot_options'] = $_SESSION['PROTOTYPE_TEMP'][$this_prototype_data['this_player_token'] . '_robot_options'];
}
// Generate the markup for this player's robot select screen
$this_prototype_data['robots_markup'] = rpg_prototype::robot_select_markup($this_prototype_data);
// Generate the markup for any leftover player missions
$this_prototype_data['missions_markup'] .= rpg_prototype::options_markup($this_prototype_data['battle_options'], $this_prototype_data['this_player_token']);
 public static function robot_select_markup($this_prototype_data)
 {
     // Refence the global config and index objects for easy access
     global $db;
     // Define the temporary robot markup string
     $this_robots_markup = '';
     // Collect the robot index for calculation purposes
     $this_robot_index = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token');
     // Collect the ability index for calculation purposes
     $this_ability_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
     // Loop through and display the available robot options for this player
     $temp_robot_option_count = count($this_prototype_data['robot_options']);
     $temp_player_favourites = rpg_game::robot_favourites();
     foreach ($this_prototype_data['robot_options'] as $key => $info) {
         $info = array_merge($this_robot_index[$info['robot_token']], $info);
         if (!isset($info['original_player'])) {
             $info['original_player'] = $this_prototype_data['this_player_token'];
         }
         $this_option_class = 'option option_this-robot-select option_this-' . $info['original_player'] . '-robot-select option_' . ($temp_robot_option_count == 1 ? '1x4' : ($this_prototype_data['robots_unlocked'] <= 2 ? '1x2' : '1x1')) . ' option_' . $info['robot_token'] . ' block_' . ($key + 1);
         $this_option_style = '';
         $this_option_token = $info['robot_id'] . '_' . $info['robot_token'];
         $this_option_image = !empty($info['robot_image']) ? $info['robot_image'] : $info['robot_token'];
         $this_option_size = !empty($info['robot_image_size']) ? $info['robot_image_size'] : 40;
         $temp_size = $this_option_size;
         $temp_size_text = $temp_size . 'x' . $temp_size;
         $temp_top = -2 + (40 - $temp_size);
         $temp_right_inc = $temp_size > 40 ? ceil($temp_size * 0.5 - 60) : 0;
         $temp_right = 15 + $temp_right_inc;
         $this_robot_name = $info['robot_name'];
         $this_robot_rewards = rpg_game::robot_rewards($this_prototype_data['this_player_token'], $info['robot_token']);
         $this_robot_settings = rpg_game::robot_settings($this_prototype_data['this_player_token'], $info['robot_token']);
         $this_robot_experience = rpg_game::robot_experience($this_prototype_data['this_player_token'], $info['robot_token']);
         $this_robot_level = rpg_game::robot_level($this_prototype_data['this_player_token'], $info['robot_token']);
         $this_experience_required = rpg_prototype::calculate_experience_required($this_robot_level);
         $this_robot_abilities = rpg_game::abilities_unlocked($this_prototype_data['this_player_token'], $info['robot_token']);
         $text_robot_special = $this_robot_level >= 100 || !empty($this_robot_rewards['flags']['reached_max_level']) ? true : false;
         $this_robot_experience = $this_robot_level >= 100 ? '<span style="position: relative; bottom: 0; font-size: 120%;">&#8734;</span>' : $this_robot_experience;
         $this_robot_experience_title = $this_robot_level >= 100 ? '&#8734;' : $this_robot_experience;
         $this_robot_favourite = in_array($info['robot_token'], $temp_player_favourites) ? true : false;
         $this_robot_name .= $this_robot_favourite ? ' <span style="position: relative; bottom: 2px; font-size: 11px;">&hearts;</span>' : '';
         $this_robot_name .= $text_robot_special ? ' <span style="position: relative; bottom: 2px; font-size: 9px;" title="Congratulations!!! :D">&#9733;</span>' : '';
         $this_robot_item = !empty($info['robot_item']) ? $info['robot_item'] : '';
         $this_robot_energy = $info['robot_energy'];
         $this_robot_attack = $info['robot_attack'];
         $this_robot_defense = $info['robot_defense'];
         $this_robot_speed = $info['robot_speed'];
         $this_robot_core = !empty($info['robot_core']) ? $info['robot_core'] : '';
         $this_robot_core2 = !empty($info['robot_core2']) ? $info['robot_core2'] : '';
         $temp_level = $this_robot_level - 1;
         $this_robot_energy += ceil($temp_level * (0.05 * $this_robot_energy));
         $this_robot_attack += ceil($temp_level * (0.05 * $this_robot_attack));
         $this_robot_defense += ceil($temp_level * (0.05 * $this_robot_defense));
         $this_robot_speed += ceil($temp_level * (0.05 * $this_robot_speed));
         if (!empty($this_robot_settings['robot_item'])) {
             $this_robot_item = $this_robot_settings['robot_item'];
         }
         if (!empty($this_robot_rewards['robot_energy'])) {
             $this_robot_energy += $this_robot_rewards['robot_energy'];
         }
         if (!empty($this_robot_rewards['robot_attack'])) {
             $this_robot_attack += $this_robot_rewards['robot_attack'];
         }
         if (!empty($this_robot_rewards['robot_defense'])) {
             $this_robot_defense += $this_robot_rewards['robot_defense'];
         }
         if (!empty($this_robot_rewards['robot_speed'])) {
             $this_robot_speed += $this_robot_rewards['robot_speed'];
         }
         if ($this_prototype_data['this_player_token'] == 'dr-light') {
             $this_robot_defense += ceil(0.25 * $this_robot_defense);
         }
         if ($this_prototype_data['this_player_token'] == 'dr-wily') {
             $this_robot_attack += ceil(0.25 * $this_robot_attack);
         }
         if ($this_prototype_data['this_player_token'] == 'dr-cossack') {
             $this_robot_speed += ceil(0.25 * $this_robot_speed);
         }
         $this_robot_energy = $this_robot_energy > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_energy;
         $this_robot_attack = $this_robot_attack > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_attack;
         $this_robot_defense = $this_robot_defense > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_defense;
         $this_robot_speed = $this_robot_speed > MMRPG_SETTINGS_STATS_MAX ? MMRPG_SETTINGS_STATS_MAX : $this_robot_speed;
         if (!empty($this_robot_settings['robot_image'])) {
             $this_option_image = $this_robot_settings['robot_image'];
         }
         if (!empty($this_robot_item) && preg_match('/^item-core-/i', $this_robot_item)) {
             $item_core_type = preg_replace('/^item-core-/i', '', $this_robot_item);
             if (empty($this_robot_core2)) {
                 //$this_robot_core != 'copy' &&
                 $this_robot_core2 = $item_core_type;
             }
         }
         $this_robot_abilities_current = !empty($info['robot_abilities']) ? array_keys($info['robot_abilities']) : array('buster-shot');
         $this_option_title = '';
         //-- Basics -------------------------------  <br />';
         $this_option_title .= $info['robot_name'];
         //''.$info['robot_number'].' '.$info['robot_name'];
         $this_option_title .= ' (' . (!empty($this_robot_core) ? ucfirst($this_robot_core) . ' Core' : 'Neutral Core') . ')';
         $this_option_title .= ' <br />Level ' . $this_robot_level . ' | ' . $this_robot_experience_title . ' / ' . $this_experience_required . ' Exp' . (!empty($this_robot_favourite_title) ? ' ' . $this_robot_favourite_title : '');
         if (!empty($this_robot_item) && isset($this_ability_index[$this_robot_item])) {
             $this_option_title .= ' | + ' . $this_ability_index[$this_robot_item]['ability_name'] . ' ';
         }
         $this_option_title .= ' <br />E : ' . $this_robot_energy . ' | A : ' . $this_robot_attack . ' | D : ' . $this_robot_defense . ' | S: ' . $this_robot_speed;
         if (!empty($this_robot_abilities_current)) {
             $this_option_title .= ' <hr />';
             // <hr />-- Abilities ------------------------------- <br />';
             $temp_counter = 1;
             foreach ($this_robot_abilities_current as $token) {
                 if (empty($token) || !isset($this_ability_index[$token])) {
                     continue;
                 }
                 $temp_info = rpg_ability::parse_index_info($this_ability_index[$token]);
                 $this_option_title .= $temp_info['ability_name'];
                 if ($temp_counter % 4 == 0) {
                     $this_option_title .= ' <br />';
                 } elseif ($temp_counter < count($this_robot_abilities_current)) {
                     $this_option_title .= ' | ';
                 }
                 $temp_counter++;
             }
         }
         $this_option_title_plain = strip_tags(str_replace('<br />', '&#10;', $this_option_title));
         $this_option_title_tooltip = htmlentities($this_option_title, ENT_QUOTES, 'UTF-8');
         $this_option_label = '<span class="sprite sprite_' . $temp_size_text . ' sprite_' . $temp_size_text . '_base" style="background-image: url(i/r/' . $this_option_image . '/sr' . $temp_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '); top: ' . $temp_top . 'px; right: ' . $temp_right . 'px;">' . $info['robot_name'] . '</span>';
         $this_option_label .= '<span class="multi">';
         $this_option_label .= '<span class="maintext">' . $this_robot_name . '</span>';
         $this_option_label .= '<span class="subtext">Level ' . $this_robot_level . '</span>';
         $this_option_label .= '<span class="subtext2">' . $this_robot_experience . '/' . $this_experience_required . ' Exp</span>';
         $this_option_label .= '</span>';
         $this_option_label .= '<span class="arrow">&#9658;</span>';
         //$this_robots_markup .= '<a class="'.$this_option_class.'" data-child="true" data-token="'.$this_option_token.'" title="'.$this_option_title_plain.'" data-tooltip="'.$this_option_title_tooltip.'" style="'.$this_option_style.'">';
         $this_robots_markup .= '<a class="' . $this_option_class . '" data-child="true" data-token="' . $this_option_token . '" style="' . $this_option_style . '">';
         $this_robots_markup .= '<div class="chrome chrome_type robot_type_' . (!empty($this_robot_core) ? $this_robot_core : 'none') . (!empty($this_robot_core2) ? '_' . $this_robot_core2 : '') . '" data-tooltip="' . $this_option_title_tooltip . '"><div class="inset"><label class="has_image">' . $this_option_label . '</label></div></div>';
         $this_robots_markup .= '</a>' . "\r\n";
     }
     // Loop through and display any option padding cells
     //if ($this_prototype_data['robots_unlocked'] >= 3){
     if ($temp_robot_option_count >= 3) {
         //$this_prototype_data['padding_num'] = $this_prototype_data['robots_unlocked'] <= 8 ? 4 : 2;
         $this_prototype_data['padding_num'] = 4;
         $this_prototype_data['robots_padding'] = $temp_robot_option_count % $this_prototype_data['padding_num'];
         if (!empty($this_prototype_data['robots_padding'])) {
             $counter = $temp_robot_option_count % $this_prototype_data['padding_num'] + 1;
             for ($counter; $counter <= $this_prototype_data['padding_num']; $counter++) {
                 $this_option_class = 'option option_this-robot-select option_this-' . $this_prototype_data['this_player_token'] . '-robot-select option_1x1 option_disabled block_' . $counter;
                 $this_option_style = '';
                 $this_robots_markup .= '<a class="' . $this_option_class . '" style="' . $this_option_style . '">';
                 $this_robots_markup .= '<div class="platform"><div class="chrome"><div class="inset"><label>&nbsp;</label></div></div></div>';
                 $this_robots_markup .= '</a>' . "\r\n";
             }
         }
     }
     // Return the generated markup
     return $this_robots_markup;
 }
<?php

// Collect the ability variables from the request header, if they exist
$temp_key = !empty($_REQUEST['key']) ? $_REQUEST['key'] : 0;
$temp_player = !empty($_REQUEST['player']) ? $_REQUEST['player'] : '';
$temp_robot = !empty($_REQUEST['robot']) ? $_REQUEST['robot'] : '';
$temp_ability = !empty($_REQUEST['ability']) ? $_REQUEST['ability'] : '';
// If key variables are not provided, kill the script in error
if (empty($temp_player) || empty($temp_robot)) {
    die('error|request-error|' . preg_replace('/\\s+/', ' ', print_r($_REQUEST, true)));
}
// Collect the current settings for the requested robot
$temp_settings = rpg_game::robot_settings($temp_player, $temp_robot);
// Create a key-based array to hold the ability settings in and populate it
$temp_abilities = array();
foreach ($temp_settings['robot_abilities'] as $temp_info) {
    $temp_abilities[] = $temp_info['ability_token'];
}
// Crop the ability settings if they've somehow exceeded the eight limit
if (count($temp_abilities) > 8) {
    $temp_abilities = array_slice($temp_abilities, 0, 8, true);
}
// If requested new ability was an empty string, remove the previous value
if (empty($temp_ability)) {
    // If this was the last ability, do nothing with this request
    if (count($temp_abilities) <= 1) {
        die('success|remove-last|' . implode(',', $temp_abilities));
    }
    // Unset the requested key in the array
    unset($temp_abilities[$temp_key]);
    // Create a new array to hold the full ability settings and populate
Esempio n. 4
0
    public static function print_editor_markup($player_info, $robot_info)
    {
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url, $db;
        global $allowed_edit_players, $allowed_edit_robots, $allowed_edit_abilities;
        global $allowed_edit_data_count, $allowed_edit_player_count, $allowed_edit_robot_count, $first_robot_token, $global_allow_editing;
        global $key_counter, $player_rewards, $player_ability_rewards, $player_robot_favourites, $player_robot_database, $temp_robot_totals, $player_options_markup, $item_options_markup;
        global $mmrpg_database_players, $mmrpg_database_abilities, $mmrpg_database_items, $mmrpg_database_fields, $mmrpg_database_types;
        global $session_token;
        // Collect values for potentially missing global variables
        if (!isset($session_token)) {
            $session_token = rpg_game::session_token();
        }
        // If either fo empty, return error
        if (empty($player_info)) {
            return 'error:player-empty';
        }
        if (empty($robot_info)) {
            return 'error:robot-empty';
        }
        // Collect the approriate database indexes
        if (empty($mmrpg_database_players)) {
            $mmrpg_database_players = rpg_player::get_index(true);
        }
        if (empty($mmrpg_database_abilities)) {
            $mmrpg_database_abilities = rpg_ability::get_index(true);
        }
        if (empty($mmrpg_database_items)) {
            $mmrpg_database_items = rpg_item::get_index(true);
        }
        if (empty($mmrpg_database_fields)) {
            $mmrpg_database_fields = rpg_field::get_index(true);
        }
        if (empty($mmrpg_database_types)) {
            $mmrpg_database_types = rpg_type::get_index();
        }
        // Define the quick-access variables for later use
        $player_token = $player_info['player_token'];
        $robot_token = $robot_info['robot_token'];
        if (!isset($first_robot_token)) {
            $first_robot_token = $robot_token;
        }
        // Start the output buffer
        ob_start();
        // Check how many robots this player has and see if they should be able to transfer
        $counter_player_robots = !empty($player_info['player_robots']) ? count($player_info['player_robots']) : false;
        $counter_player_missions = rpg_prototype::battles_complete($player_info['player_token']);
        $allow_player_selector = $allowed_edit_player_count > 1 ? true : false;
        // Update the robot key to the current counter
        $robot_key = $key_counter;
        // Make a backup of the player selector
        $allow_player_selector_backup = $allow_player_selector;
        // Collect or define the image size
        $robot_info['robot_image_size'] = !empty($robot_info['robot_image_size']) ? $robot_info['robot_image_size'] : 40;
        $robot_image_offset = $robot_info['robot_image_size'] > 40 ? ceil(($robot_info['robot_image_size'] - 40) * 0.5) : 0;
        $robot_image_size_text = $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
        $robot_image_offset_top = -1 * $robot_image_offset;
        // Collect the robot level and experience
        $robot_info['robot_level'] = rpg_game::robot_level($player_info['player_token'], $robot_info['robot_token']);
        $robot_info['robot_experience'] = rpg_game::robot_experience($player_info['player_token'], $robot_info['robot_token']);
        // Collect the rewards for this robot
        $robot_rewards = rpg_game::robot_rewards($player_token, $robot_token);
        // Collect the settings for this robot
        $robot_settings = rpg_game::robot_settings($player_token, $robot_token);
        // Collect the database for this robot
        $robot_database = !empty($player_robot_database[$robot_token]) ? $player_robot_database[$robot_token] : array();
        //rpg_game::robot_database($robot_token);
        // Collect the robot ability core if it exists
        $robot_ability_core = !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : false;
        // Check if this robot has the copy shot ability
        $robot_flag_copycore = $robot_ability_core == 'copy' ? true : false;
        // Make backups of the robot's original stats before rewards
        $robot_info['robot_energy_index'] = $robot_info['robot_energy'];
        $robot_info['robot_weapons_index'] = $robot_info['robot_weapons'];
        $robot_info['robot_attack_index'] = $robot_info['robot_attack'];
        $robot_info['robot_defense_index'] = $robot_info['robot_defense'];
        $robot_info['robot_speed_index'] = $robot_info['robot_speed'];
        // Collect this robot's ability rewards and add them to the dropdown
        $robot_ability_rewards = !empty($robot_rewards['robot_abilities']) ? $robot_rewards['robot_abilities'] : array();
        $robot_ability_settings = !empty($robot_settings['robot_abilities']) ? $robot_settings['robot_abilities'] : array();
        foreach ($robot_ability_settings as $token => $info) {
            if (empty($robot_ability_rewards[$token])) {
                $robot_ability_rewards[$token] = $info;
            }
        }
        // If the robot's level is greater than one, apply stat boosts
        if ($robot_info['robot_level'] > 1) {
            // Create the temp level by subtracting one (so we don't have level 1 boosts)
            $temp_level = $robot_info['robot_level'] - 1;
            // Update the robot energy with a small boost based on experience level
            $robot_info['robot_energy'] = $robot_info['robot_energy'] + ceil($temp_level * (0.05 * $robot_info['robot_energy']));
            // Update the robot attack with a small boost based on experience level
            $robot_info['robot_attack'] = $robot_info['robot_attack'] + ceil($temp_level * (0.05 * $robot_info['robot_attack']));
            // Update the robot defense with a small boost based on experience level
            $robot_info['robot_defense'] = $robot_info['robot_defense'] + ceil($temp_level * (0.05 * $robot_info['robot_defense']));
            // Update the robot speed with a small boost based on experience level
            $robot_info['robot_speed'] = $robot_info['robot_speed'] + ceil($temp_level * (0.05 * $robot_info['robot_speed']));
        }
        // Make backups of the robot's original stats before rewards
        $robot_info['robot_energy_base'] = $robot_info['robot_energy'];
        $robot_info['robot_attack_base'] = $robot_info['robot_attack'];
        $robot_info['robot_defense_base'] = $robot_info['robot_defense'];
        $robot_info['robot_speed_base'] = $robot_info['robot_speed'];
        // Apply any stat rewards for the robot's attack
        if (!empty($robot_rewards['robot_attack'])) {
            $robot_info['robot_attack'] += $robot_rewards['robot_attack'];
        }
        // Apply any stat rewards for the robot's defense
        if (!empty($robot_rewards['robot_defense'])) {
            $robot_info['robot_defense'] += $robot_rewards['robot_defense'];
        }
        // Apply any stat rewards for the robot's speed
        if (!empty($robot_rewards['robot_speed'])) {
            $robot_info['robot_speed'] += $robot_rewards['robot_speed'];
        }
        // Make backups of the robot's original stats before rewards
        $robot_info['robot_attack_rewards'] = $robot_info['robot_attack'] - $robot_info['robot_attack_base'];
        $robot_info['robot_defense_rewards'] = $robot_info['robot_defense'] - $robot_info['robot_defense_base'];
        $robot_info['robot_speed_rewards'] = $robot_info['robot_speed'] - $robot_info['robot_speed_base'];
        // Only apply player bonuses if the robot is with it's original player
        //if (!empty($robot_info['original_player']) && $robot_info['original_player'] == $player_info['player_token']){}
        // Apply stat bonuses to this robot based on its current player's own stats
        if (true) {
            // Apply any player special for the robot's attack
            if (!empty($player_info['player_attack'])) {
                $robot_info['robot_attack'] += ceil($robot_info['robot_attack'] * ($player_info['player_attack'] / 100));
            }
            // Apply any player special for the robot's defense
            if (!empty($player_info['player_defense'])) {
                $robot_info['robot_defense'] += ceil($robot_info['robot_defense'] * ($player_info['player_defense'] / 100));
            }
            // Apply any player special for the robot's speed
            if (!empty($player_info['player_speed'])) {
                $robot_info['robot_speed'] += ceil($robot_info['robot_speed'] * ($player_info['player_speed'] / 100));
            }
        }
        // Make backups of the robot's original stats before rewards
        $robot_info['robot_attack_player'] = $robot_info['robot_attack'] - $robot_info['robot_attack_rewards'] - $robot_info['robot_attack_base'];
        $robot_info['robot_defense_player'] = $robot_info['robot_defense'] - $robot_info['robot_defense_rewards'] - $robot_info['robot_defense_base'];
        $robot_info['robot_speed_player'] = $robot_info['robot_speed'] - $robot_info['robot_speed_rewards'] - $robot_info['robot_speed_base'];
        // Limit stat digits for display purposes
        if ($robot_info['robot_energy'] > MMRPG_SETTINGS_STATS_MAX) {
            $robot_info['robot_energy'] = MMRPG_SETTINGS_STATS_MAX;
        }
        if ($robot_info['robot_attack'] > MMRPG_SETTINGS_STATS_MAX) {
            $robot_info['robot_attack'] = MMRPG_SETTINGS_STATS_MAX;
        }
        if ($robot_info['robot_defense'] > MMRPG_SETTINGS_STATS_MAX) {
            $robot_info['robot_defense'] = MMRPG_SETTINGS_STATS_MAX;
        }
        if ($robot_info['robot_speed'] > MMRPG_SETTINGS_STATS_MAX) {
            $robot_info['robot_speed'] = MMRPG_SETTINGS_STATS_MAX;
        }
        // Collect the summon count from the session if it exists
        $robot_info['robot_summoned'] = !empty($robot_database['robot_summoned']) ? $robot_database['robot_summoned'] : 0;
        // Collect the alt images if there are any that are unlocked
        $robot_alt_count = 1 + (!empty($robot_info['robot_image_alts']) ? count($robot_info['robot_image_alts']) : 0);
        $robot_alt_options = array();
        if (!empty($robot_info['robot_image_alts'])) {
            foreach ($robot_info['robot_image_alts'] as $alt_key => $alt_info) {
                if ($robot_info['robot_summoned'] < $alt_info['summons']) {
                    continue;
                }
                $robot_alt_options[] = $alt_info['token'];
            }
        }
        // Collect the current unlock image token for this robot
        $robot_image_unlock_current = 'base';
        if (!empty($robot_settings['robot_image']) && strstr($robot_settings['robot_image'], '_')) {
            list($token, $robot_image_unlock_current) = explode('_', $robot_settings['robot_image']);
        }
        // Define the offsets for the image tokens based on count
        $token_first_offset = 2;
        $token_other_offset = 6;
        if ($robot_alt_count == 1) {
            $token_first_offset = 17;
        } elseif ($robot_alt_count == 3) {
            $token_first_offset = 10;
        }
        // Loop through and generate the robot image display token markup
        $robot_image_unlock_tokens = '';
        $temp_total_alts_count = 0;
        for ($i = 0; $i < 6; $i++) {
            $temp_enabled = true;
            $temp_active = false;
            if ($i + 1 > $robot_alt_count) {
                break;
            }
            if ($i > 0 && !isset($robot_alt_options[$i - 1])) {
                $temp_enabled = false;
            }
            if ($temp_enabled && $i == 0 && $robot_image_unlock_current == 'base') {
                $temp_active = true;
            } elseif ($temp_enabled && $i >= 1 && $robot_image_unlock_current == $robot_alt_options[$i - 1]) {
                $temp_active = true;
            }
            $robot_image_unlock_tokens .= '<span class="token token_' . ($temp_enabled ? 'enabled' : 'disabled') . ' ' . ($temp_active ? 'token_active' : '') . '" style="left: ' . ($token_first_offset + $i * $token_other_offset) . 'px;">&bull;</span>';
            $temp_total_alts_count += 1;
        }
        $temp_unlocked_alts_count = count($robot_alt_options) + 1;
        $temp_image_alt_title = '';
        if ($temp_total_alts_count > 1) {
            $temp_image_alt_title = '<strong>' . $temp_unlocked_alts_count . ' / ' . $temp_total_alts_count . ' Outfits Unlocked</strong><br />';
            //$temp_image_alt_title .= '<span style="font-size: 90%;">';
            $temp_image_alt_title .= '&#8226; <span style="font-size: 90%;">' . $robot_info['robot_name'] . '</span><br />';
            foreach ($robot_info['robot_image_alts'] as $alt_key => $alt_info) {
                if ($robot_info['robot_summoned'] >= $alt_info['summons']) {
                    $temp_image_alt_title .= '&#8226; <span style="font-size: 90%;">' . $alt_info['name'] . '</span><br />';
                } else {
                    $temp_image_alt_title .= '&#9702; <span style="font-size: 90%;">???</span><br />';
                }
            }
            //$temp_image_alt_title .= '</span>';
            $temp_image_alt_title = htmlentities($temp_image_alt_title, ENT_QUOTES, 'UTF-8', true);
        }
        // Define whether or not this robot has coreswap enabled
        $temp_allow_coreswap = $robot_info['robot_level'] >= 100 ? true : false;
        //echo $robot_info['robot_token'].' robot_image_unlock_current = '.$robot_image_unlock_current.' | robot_alt_options = '.implode(',',array_keys($robot_alt_options)).'<br />';
        ?>
            <div class="event event_double event_<?php 
        echo $robot_key == $first_robot_token ? 'visible' : 'hidden';
        ?>
 <?php 
        echo false && $robot_info['robot_level'] >= 100 && $robot_info['robot_core'] != 'copy' ? 'event_has_subcore' : '';
        ?>
" data-token="<?php 
        echo $player_info['player_token'] . '_' . $robot_info['robot_token'];
        ?>
" data-player="<?php 
        echo $player_info['player_token'];
        ?>
" data-robot="<?php 
        echo $robot_info['robot_token'];
        ?>
" data-types="<?php 
        echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] . (!empty($robot_info['robot_core2']) ? '_' . $robot_info['robot_core2'] : '') : 'none';
        ?>
">

                <div class="this_sprite sprite_left event_robot_mugshot" style="">
                    <?php 
        $temp_offset = $robot_info['robot_image_size'] == 80 ? '-20px' : '0';
        ?>
                    <div class="sprite_wrapper robot_type robot_type_<?php 
        echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none';
        ?>
" style="width: 33px;">
                        <div class="sprite_wrapper robot_type robot_type_empty" style="position: absolute; width: 27px; height: 34px; left: 2px; top: 2px;"></div>
                        <div style="left: <?php 
        echo $temp_offset;
        ?>
; bottom: <?php 
        echo $temp_offset;
        ?>
; background-image: url(i/r/<?php 
        echo !empty($robot_info['robot_image']) ? $robot_info['robot_image'] : $robot_info['robot_token'];
        ?>
/mr<?php 
        echo $robot_info['robot_image_size'];
        ?>
.png?<?php 
        echo MMRPG_CONFIG_CACHE_DATE;
        ?>
); " class="sprite sprite_robot sprite_robot_sprite sprite_<?php 
        echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
        ?>
 sprite_<?php 
        echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
        ?>
_mug robot_status_active robot_position_active"><?php 
        echo $robot_info['robot_name'];
        ?>
</div>
                    </div>
                </div>

                <?php 
        if (false && $robot_info['robot_level'] >= 100 && $robot_info['robot_core'] != 'copy') {
            ?>
                    <div class="this_sprite sprite_left event_robot_core2 ability_type ability_type_<?php 
            echo !empty($robot_info['robot_core2']) ? $robot_info['robot_core2'] : 'none';
            ?>
" style="" >
                        <div class="sprite_wrapper" style="">
                            <?php 
            if ($global_allow_editing) {
                ?>
                                <a class="robot_core2 <?php 
                echo in_array($robot_token, $player_robot_favourites) ? 'robot_core_active ' : '';
                ?>
" data-player="<?php 
                echo $player_token;
                ?>
" data-robot="<?php 
                echo $robot_token;
                ?>
" title="Equip Subcore?">
                                    <?php 
                if (!empty($robot_info['robot_core2'])) {
                    ?>
                                        <span class="sprite sprite_40x40 sprite_40x40_00" style="background-image: url(i/i/<?php 
                    echo !empty($robot_info['robot_core2']) ? $robot_info['robot_core2'] : 'none';
                    ?>
-core/il40.png);"></span>
                                    <?php 
                }
                ?>
                                </a>
                            <?php 
            } else {
                ?>
                                <span class="robot_core2 <?php 
                echo in_array($robot_token, $player_robot_favourites) ? 'robot_core_active ' : '';
                ?>
">
                                    <span class="sprite sprite_40x40 sprite_40x40_00" style="background-image: url(i/i/<?php 
                echo !empty($robot_info['robot_core2']) ? $robot_info['robot_core2'] : 'none';
                ?>
-core/il40.png);"></span>
                                </span>
                            <?php 
            }
            ?>
                        </div>
                    </div>
                <?php 
        }
        ?>

                <div class="this_sprite sprite_left event_robot_images" style="">
                    <?php 
        if ($global_allow_editing && !empty($robot_alt_options)) {
            ?>
                        <a class="robot_image_alts" data-player="<?php 
            echo $player_token;
            ?>
" data-robot="<?php 
            echo $robot_token;
            ?>
" data-alt-index="base<?php 
            echo !empty($robot_alt_options) ? ',' . implode(',', $robot_alt_options) : '';
            ?>
" data-alt-current="<?php 
            echo $robot_image_unlock_current;
            ?>
" data-tooltip="<?php 
            echo $temp_image_alt_title;
            ?>
">
                            <?php 
            $temp_offset = $robot_info['robot_image_size'] == 80 ? '-20px' : '0';
            ?>
                            <span class="sprite_wrapper" style="">
                                <?php 
            echo $robot_image_unlock_tokens;
            ?>
                                <div style="left: <?php 
            echo $temp_offset;
            ?>
; bottom: 0; background-image: url(i/r/<?php 
            echo !empty($robot_info['robot_image']) ? $robot_info['robot_image'] : $robot_info['robot_token'];
            ?>
/sr<?php 
            echo $robot_info['robot_image_size'];
            ?>
.png?<?php 
            echo MMRPG_CONFIG_CACHE_DATE;
            ?>
); " class="sprite sprite_robot sprite_robot_sprite sprite_<?php 
            echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
            ?>
 sprite_<?php 
            echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
            ?>
_base robot_status_active robot_position_active"><?php 
            echo $robot_info['robot_name'];
            ?>
</div>
                            </span>
                        </a>
                    <?php 
        } else {
            ?>
                        <span class="robot_image_alts" data-player="<?php 
            echo $player_token;
            ?>
" data-robot="<?php 
            echo $robot_token;
            ?>
" data-alt-index="base<?php 
            echo !empty($robot_alt_options) ? ',' . implode(',', $robot_alt_options) : '';
            ?>
" data-alt-current="<?php 
            echo $robot_image_unlock_current;
            ?>
" data-tooltip="<?php 
            echo $temp_image_alt_title;
            ?>
">
                            <?php 
            $temp_offset = $robot_info['robot_image_size'] == 80 ? '-20px' : '0';
            ?>
                            <span class="sprite_wrapper" style="">
                                <?php 
            echo $robot_image_unlock_tokens;
            ?>
                                <div style="left: <?php 
            echo $temp_offset;
            ?>
; bottom: 0; background-image: url(i/r/<?php 
            echo !empty($robot_info['robot_image']) ? $robot_info['robot_image'] : $robot_info['robot_token'];
            ?>
/sr<?php 
            echo $robot_info['robot_image_size'];
            ?>
.png?<?php 
            echo MMRPG_CONFIG_CACHE_DATE;
            ?>
); " class="sprite sprite_robot sprite_robot_sprite sprite_<?php 
            echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
            ?>
 sprite_<?php 
            echo $robot_info['robot_image_size'] . 'x' . $robot_info['robot_image_size'];
            ?>
_base robot_status_active robot_position_active"><?php 
            echo $robot_info['robot_name'];
            ?>
</div>
                            </span>
                        </span>
                    <?php 
        }
        ?>
                </div>

                <div class="this_sprite sprite_left event_robot_summons" style="">
                    <div class="robot_summons">
                        <span class="summons_count"><?php 
        echo $robot_info['robot_summoned'];
        ?>
</span>
                        <span class="summons_label"><?php 
        echo $robot_info['robot_summoned'] == 1 ? 'Summon' : 'Summons';
        ?>
</span>
                    </div>
                </div>

                <div class="this_sprite sprite_left event_robot_favourite" style="" >
                    <?php 
        if ($global_allow_editing) {
            ?>
                        <a class="robot_favourite <?php 
            echo in_array($robot_token, $player_robot_favourites) ? 'robot_favourite_active ' : '';
            ?>
" data-player="<?php 
            echo $player_token;
            ?>
" data-robot="<?php 
            echo $robot_token;
            ?>
" title="Toggle Favourite?">&hearts;</a>
                    <?php 
        } else {
            ?>
                        <span class="robot_favourite <?php 
            echo in_array($robot_token, $player_robot_favourites) ? 'robot_favourite_active ' : '';
            ?>
">&hearts;</span>
                    <?php 
        }
        ?>
                </div>

                <?php 
        // Define the placehodler cells for the empty column in case it's needed
        ob_start();
        ?>
                <td class="right">
                    <label style="display: block; float: left; color: #696969;">??? :</label>
                    <span class="robot_stat" style="color: #696969; font-weight: normal;">???</span>
                </td>
                <?php 
        $empty_column_placeholder = ob_get_clean();
        // Define an array to hold all the data in the left and right columns
        $left_column_markup = array();
        $right_column_markup = array();
        // Check to see if the player has unlocked the ability to swap players
        $temp_player_swap_unlocked = rpg_game::player_unlocked('dr-wily');
        // && rpg_prototype::event_unlocked('dr-wily', 'chapter_one_complete');
        // If this player has unlocked the ability to let robots swap players
        if ($temp_player_swap_unlocked) {
            ob_start();
            ?>
                    <td class="player_select_block right">
                        <?php 
            $player_style = '';
            $robot_info['original_player'] = !empty($robot_info['original_player']) ? $robot_info['original_player'] : $player_info['player_token'];
            if ($player_info['player_token'] != $robot_info['original_player']) {
                if ($counter_player_robots > 1) {
                    $allow_player_selector = true;
                }
            }
            ?>
                        <?php 
            if ($robot_info['original_player'] != $player_info['player_token']) {
                ?>
                            <label title="<?php 
                echo 'Transferred from Dr. ' . ucfirst(str_replace('dr-', '', $robot_info['original_player']));
                ?>
"  class="original_player original_player_<?php 
                echo $robot_info['original_player'];
                ?>
" data-tooltip-type="player_type player_type_<?php 
                echo str_replace('dr-', '', $robot_info['original_player']);
                ?>
" style="display: block; float: left; <?php 
                echo $player_style;
                ?>
"><span class="current_player current_player_<?php 
                echo $player_info['player_token'];
                ?>
">Player</span> :</label>
                        <?php 
            } else {
                ?>
                            <label class="original_player original_player_<?php 
                echo $robot_info['original_player'];
                ?>
" data-tooltip-type="player_type player_type_<?php 
                echo str_replace('dr-', '', $robot_info['original_player']);
                ?>
" style="display: block; float: left; <?php 
                echo $player_style;
                ?>
"><span class="current_player current_player_<?php 
                echo $player_info['player_token'];
                ?>
">Player</span> :</label>
                        <?php 
            }
            ?>

                        <?if($global_allow_editing && $allow_player_selector):?>
                            <a class="player_name player_type player_type_<?php 
            echo str_replace('dr-', '', $player_info['player_token']);
            ?>
"><label style="background-image: url(i/p/<?php 
            echo $player_info['player_token'];
            ?>
/ml40.png?<?php 
            echo MMRPG_CONFIG_CACHE_DATE;
            ?>
);"><?php 
            echo $player_info['player_name'];
            ?>
<span class="arrow">&#8711;</span></label></a>
                        <?elseif(!$global_allow_editing && $allow_player_selector):?>
                            <a class="player_name player_type player_type_<?php 
            echo str_replace('dr-', '', $player_info['player_token']);
            ?>
" style="cursor: default; "><label style="background-image: url(i/p/<?php 
            echo $player_info['player_token'];
            ?>
/ml40.png?<?php 
            echo MMRPG_CONFIG_CACHE_DATE;
            ?>
); cursor: default; "><?php 
            echo $player_info['player_name'];
            ?>
</label></a>
                        <?else:?>
                            <a class="player_name player_type player_type_<?php 
            echo str_replace('dr-', '', $player_info['player_token']);
            ?>
" style="opacity: 0.5; filter: alpha(opacity=50); cursor: default;"><label style="background-image: url(i/p/<?php 
            echo $player_info['player_token'];
            ?>
/ml40.png?<?php 
            echo MMRPG_CONFIG_CACHE_DATE;
            ?>
);"><?php 
            echo $player_info['player_name'];
            ?>
</label></a>
                        <?endif;?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Check to see if the player has unlocked the ability to hold items
        $temp_item_hold_unlocked = rpg_prototype::event_complete('completed-chapter_dr-cossack_one');
        $current_item_token = '';
        // If this player has unlocked the ability to let robots hold items
        if ($temp_item_hold_unlocked) {
            // Collect the currently held item and token, if available
            $current_item_token = !empty($robot_info['robot_item']) ? $robot_info['robot_item'] : '';
            $current_item_info = !empty($mmrpg_database_items[$current_item_token]) ? $mmrpg_database_items[$current_item_token] : array();
            $current_item_name = !empty($current_item_info['ability_name']) ? $current_item_info['ability_name'] : 'No Item';
            $current_item_image = !empty($current_item_info['ability_image']) ? $current_item_info['ability_image'] : $current_item_token;
            $current_item_type = !empty($current_item_info['ability_type']) ? $current_item_info['ability_type'] : 'none';
            if (!empty($current_item_info['ability_type2'])) {
                $current_item_type = $current_item_type != 'none' ? $current_item_type . '_' . $current_item_info['ability_type2'] : $current_item_info['ability_type2'];
            }
            if (empty($current_item_info)) {
                $current_item_token = '';
                $current_item_image = 'ability';
            }
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Item:</label>
                        <?php 
            if ($global_allow_editing) {
                ?>
                            <a title="Change Item?" class="item_name type <?php 
                echo $current_item_type;
                ?>
"><label style="background-image: url(i/a/<?php 
                echo $current_item_image;
                ?>
/il40.png?<?php 
                echo MMRPG_CONFIG_CACHE_DATE;
                ?>
);"><?php 
                echo $current_item_name;
                ?>
<span class="arrow">&#8711;</span></label></a>
                        <?php 
            } else {
                ?>
                            <a class="item_name type <?php 
                echo $current_item_type;
                ?>
" style="opacity: 0.5; filter: alpha(opacity=50); cursor: default;"><label style="background-image: url(i/a/<?php 
                echo $current_item_image;
                ?>
/il40.png?<?php 
                echo MMRPG_CONFIG_CACHE_DATE;
                ?>
);"><?php 
                echo $current_item_name;
                ?>
</label></a>
                        <?php 
            }
            ?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Define the markup for the weakness
        if (true) {
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Weaknesses :</label>
                        <?php 
            if (!empty($robot_info['robot_weaknesses'])) {
                $temp_string = array();
                foreach ($robot_info['robot_weaknesses'] as $robot_weakness) {
                    $temp_string[] = '<span class="robot_weakness robot_type robot_type_' . (!empty($robot_weakness) ? $robot_weakness : 'none') . '">' . $mmrpg_database_types[$robot_weakness]['type_name'] . '</span>';
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_weakness">None</span>';
            }
            ?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Define the markup for the resistance
        if (true) {
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Resistances :</label>
                        <?php 
            if (!empty($robot_info['robot_resistances'])) {
                $temp_string = array();
                foreach ($robot_info['robot_resistances'] as $robot_resistance) {
                    $temp_string[] = '<span class="robot_resistance robot_type robot_type_' . (!empty($robot_resistance) ? $robot_resistance : 'none') . '">' . $mmrpg_database_types[$robot_resistance]['type_name'] . '</span>';
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_resistance">None</span>';
            }
            ?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Define the markup for the affinity
        if (true) {
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Affinities :</label>
                        <?php 
            if (!empty($robot_info['robot_affinities'])) {
                $temp_string = array();
                foreach ($robot_info['robot_affinities'] as $robot_affinity) {
                    $temp_string[] = '<span class="robot_affinity robot_type robot_type_' . (!empty($robot_affinity) ? $robot_affinity : 'none') . '">' . $mmrpg_database_types[$robot_affinity]['type_name'] . '</span>';
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_affinity">None</span>';
            }
            ?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Define the markup for the immunity
        if (true) {
            ob_start();
            ?>
                    <td class="right">
                        <label style="display: block; float: left;">Immunities :</label>
                        <?php 
            if (!empty($robot_info['robot_immunities'])) {
                $temp_string = array();
                foreach ($robot_info['robot_immunities'] as $robot_immunity) {
                    $temp_string[] = '<span class="robot_immunity robot_type robot_type_' . (!empty($robot_immunity) ? $robot_immunity : 'none') . '">' . $mmrpg_database_types[$robot_immunity]['type_name'] . '</span>';
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_immunity">None</span>';
            }
            ?>
                    </td>
                    <?php 
            $left_column_markup[] = ob_get_clean();
        }
        // Define the markup for the level
        if (true) {
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Level :</label>
                        <?php 
            if ($robot_info['robot_level'] >= 100) {
                ?>
                            <a data-tooltip-align="center" data-tooltip="<?php 
                echo htmlentities('Congratulations! ' . $robot_info['robot_name'] . ' has reached Level 100!<br /> <span style="font-size: 90%;">Stat bonuses will now be awarded immediately when this robot lands the finishing blow on a target! Try to max out each stat to its full potential!</span>', ENT_QUOTES, 'UTF-8');
                ?>
" class="robot_stat robot_type_electric"><?php 
                echo $robot_info['robot_level'];
                ?>
 <span>&#9733;</span></a>
                        <?php 
            } else {
                ?>
                            <span class="robot_stat robot_level_reset robot_type_<?php 
                echo !empty($robot_rewards['flags']['reached_max_level']) ? 'electric' : 'none';
                ?>
"><?php 
                echo !empty($robot_rewards['flags']['reached_max_level']) ? '<span>&#9733;</span>' : '';
                ?>
 <?php 
                echo $robot_info['robot_level'];
                ?>
</span>
                        <?php 
            }
            ?>
                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        // Define the markup for the experience
        if (true) {
            ob_start();
            ?>
                    <td  class="right">
                        <label style="display: block; float: left;">Experience :</label>
                        <?php 
            if ($robot_info['robot_level'] >= MMRPG_SETTINGS_LEVEL_MAX) {
                ?>
                            <span class="robot_stat robot_type_cutter">&#8734; / &#8734;</span>
                        <?php 
            } else {
                ?>
                            <span class="robot_stat"><?php 
                echo $robot_info['robot_experience'];
                ?>
 / <?php 
                echo rpg_prototype::calculate_experience_required($robot_info['robot_level']);
                ?>
</span>
                        <?php 
            }
            ?>
                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        // Define the markup for the energy
        if (true) {
            ob_start();
            ?>
                    <td class="right">
                        <label style="display: block; float: left;">Energy :</label>

                        <span class="robot_stat robot_type robot_type_energy" style="padding: 0 6px; margin-right: 3px;"><?php 
            echo MMRPG_SETTINGS_STATS_GET_ROBOTMIN($robot_info['robot_energy_index'], $robot_info['robot_level']);
            ?>
<span style="font-weight: normal; font-size: 9px; position: relative; bottom: 1px;"> LE</span></span>

                        <span class="robot_stat robot_type robot_type_weapons" style="padding: 0 6px;"><?php 
            echo $robot_info['robot_weapons_index'];
            ?>
<span style="font-weight: normal; font-size: 9px; position: relative; bottom: 1px;"> WE</span></span>

                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        // Define the markup for the attack
        if (true) {
            ob_start();
            ?>
                    <td class="right">
                        <?php 
            // Print out the ATTACK stat
            $temp_stat = 'attack';
            $temp_stat_max = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($robot_info['robot_' . $temp_stat . '_index'], $robot_info['robot_level']);
            $temp_stat_maxed = $robot_info['robot_' . $temp_stat] >= $temp_stat_max ? true : false;
            $temp_title = $robot_info['robot_level'] >= 100 ? $robot_info['robot_' . $temp_stat] . ' / ' . $temp_stat_max . ' Max' . ($temp_stat_maxed ? ' &#9733;' : '') : '';
            $temp_data_type = $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
                        <label class="<?php 
            echo !empty($player_info['player_' . $temp_stat]) ? 'statboost_player_' . $player_info['player_token'] : '';
            ?>
" style="display: block; float: left;"><?php 
            echo ucfirst($temp_stat);
            ?>
 :</label>
                        <span class="robot_stat <?php 
            echo $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
"><?php 
            echo '<span style="font-weight: normal; font-size: 9px; position: relative; bottom: 1px;">';
            echo '<span title="Base ' . ucfirst($temp_stat) . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_base'] . '</span> ';
            echo !empty($robot_info['robot_' . $temp_stat . '_rewards']) ? '+ <span title="Knockout Bonuses" class="statboost_robot"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_rewards'] . '</span> ' : '';
            echo !empty($robot_info['robot_' . $temp_stat . '_player']) ? '+ <span title="Player Bonuses" class="statboost_player_' . $player_info['player_token'] . ($temp_stat_maxed ? '2' : '') . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_player'] . '</span> ' : '';
            echo ' = </span>';
            echo '<span' . (!empty($temp_title) ? ' title="' . $temp_title . '"' : '') . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>';
            echo preg_replace('/^(0+)/', '<span style="color: rgba(255, 255, 255, 0.05); text-shadow: 0 0 0 transparent; ">$1</span>', str_pad($robot_info['robot_' . $temp_stat], 4, '0', STR_PAD_LEFT));
            if ($temp_stat_maxed) {
                echo '<span>&nbsp;&#9733;</span>';
            }
            echo '</span>';
            ?>
</span>
                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        // Define the markup for the defense
        if (true) {
            ob_start();
            ?>
                    <td class="right">
                        <?php 
            // Print out the DEFENSE stat
            $temp_stat = 'defense';
            $temp_stat_max = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($robot_info['robot_' . $temp_stat . '_index'], $robot_info['robot_level']);
            $temp_stat_maxed = $robot_info['robot_' . $temp_stat] >= $temp_stat_max ? true : false;
            $temp_title = $robot_info['robot_level'] >= 100 ? $robot_info['robot_' . $temp_stat] . ' / ' . $temp_stat_max . ' Max' . ($temp_stat_maxed ? ' &#9733;' : '') : '';
            $temp_data_type = $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
                        <label class="<?php 
            echo !empty($player_info['player_' . $temp_stat]) ? 'statboost_player_' . $player_info['player_token'] : '';
            ?>
" style="display: block; float: left;"><?php 
            echo ucfirst($temp_stat);
            ?>
 :</label>
                        <span class="robot_stat <?php 
            echo $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
"><?php 
            echo '<span style="font-weight: normal; font-size: 9px; position: relative; bottom: 1px;">';
            echo '<span title="Base ' . ucfirst($temp_stat) . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_base'] . '</span> ';
            echo !empty($robot_info['robot_' . $temp_stat . '_rewards']) ? '+ <span title="Knockout Bonuses" class="statboost_robot"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_rewards'] . '</span> ' : '';
            echo !empty($robot_info['robot_' . $temp_stat . '_player']) ? '+ <span title="Player Bonuses" class="statboost_player_' . $player_info['player_token'] . ($temp_stat_maxed ? '2' : '') . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_player'] . '</span> ' : '';
            echo ' = </span>';
            echo '<span' . (!empty($temp_title) ? ' title="' . $temp_title . '"' : '') . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>';
            echo preg_replace('/^(0+)/', '<span style="color: rgba(255, 255, 255, 0.05); text-shadow: 0 0 0 transparent; ">$1</span>', str_pad($robot_info['robot_' . $temp_stat], 4, '0', STR_PAD_LEFT));
            if ($temp_stat_maxed) {
                echo '<span>&nbsp;&#9733;</span>';
            }
            echo '</span>';
            ?>
</span>
                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        // Define the markup for the speed
        if (true) {
            ob_start();
            ?>
                    <td class="right">
                        <?php 
            // Print out the SPEED stat
            $temp_stat = 'speed';
            $temp_stat_max = MMRPG_SETTINGS_STATS_GET_ROBOTMAX($robot_info['robot_' . $temp_stat . '_index'], $robot_info['robot_level']);
            $temp_stat_maxed = $robot_info['robot_' . $temp_stat] >= $temp_stat_max ? true : false;
            $temp_title = $robot_info['robot_level'] >= 100 ? $robot_info['robot_' . $temp_stat] . ' / ' . $temp_stat_max . ' Max' . ($temp_stat_maxed ? ' &#9733;' : '') : '';
            $temp_data_type = $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
                        <label class="<?php 
            echo !empty($player_info['player_' . $temp_stat]) ? 'statboost_player_' . $player_info['player_token'] : '';
            ?>
" style="display: block; float: left;"><?php 
            echo ucfirst($temp_stat);
            ?>
 :</label>
                        <span class="robot_stat <?php 
            echo $temp_stat_maxed ? 'robot_type robot_type_' . $temp_stat : '';
            ?>
"><?php 
            echo '<span style="font-weight: normal; font-size: 9px; position: relative; bottom: 1px;">';
            echo '<span title="Base ' . ucfirst($temp_stat) . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_base'] . '</span> ';
            echo !empty($robot_info['robot_' . $temp_stat . '_rewards']) ? '+ <span title="Knockout Bonuses" class="statboost_robot"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_rewards'] . '</span> ' : '';
            echo !empty($robot_info['robot_' . $temp_stat . '_player']) ? '+ <span title="Player Bonuses" class="statboost_player_' . $player_info['player_token'] . ($temp_stat_maxed ? '2' : '') . '"' . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>' . $robot_info['robot_' . $temp_stat . '_player'] . '</span> ' : '';
            echo ' = </span>';
            echo '<span' . (!empty($temp_title) ? ' title="' . $temp_title . '"' : '') . (!empty($temp_data_type) ? ' data-tooltip-type="' . $temp_data_type . '"' : '') . '>';
            echo preg_replace('/^(0+)/', '<span style="color: rgba(255, 255, 255, 0.05); text-shadow: 0 0 0 transparent; ">$1</span>', str_pad($robot_info['robot_' . $temp_stat], 4, '0', STR_PAD_LEFT));
            if ($temp_stat_maxed) {
                echo '<span>&nbsp;&#9733;</span>';
            }
            echo '</span>';
            ?>
</span>
                    </td>
                    <?php 
            $right_column_markup[] = ob_get_clean();
        }
        ?>

                <div class="header header_left robot_type robot_type_<?php 
        echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none';
        ?>
" style="margin-right: 0;">
                    <span class="title robot_type"><?php 
        echo $robot_info['robot_name'];
        ?>
</span>
                    <span class="core robot_type">
                        <span class="wrap"><span class="sprite sprite_40x40 sprite_40x40_00" style="background-image: url(i/i/<?php 
        echo !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : 'none';
        ?>
-core/il40.png);"></span></span>
                        <span class="text"><?php 
        echo !empty($robot_info['robot_core']) ? ucfirst($robot_info['robot_core']) : 'Neutral';
        ?>
 Core</span>
                    </span>
                </div>
                <div class="body body_left" style="margin-right: 0; padding: 2px 3px; height: auto;">
                    <table class="full" style="margin-bottom: 5px;">
                        <colgroup>
                            <col width="64%" />
                            <col width="1%" />
                            <col width="35%" />
                        </colgroup>
                        <tbody>
                            <tr>
                                <?php 
        if (!empty($left_column_markup[0])) {
            echo $left_column_markup[0];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[0])) {
            echo $right_column_markup[0];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>
                            <tr>
                                <?php 
        if (!empty($left_column_markup[1])) {
            echo $left_column_markup[1];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[1])) {
            echo $right_column_markup[1];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>

                            <tr>
                                <?php 
        if (!empty($left_column_markup[2])) {
            echo $left_column_markup[2];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[2])) {
            echo $right_column_markup[2];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>
                            <tr>
                                <?php 
        if (!empty($left_column_markup[3])) {
            echo $left_column_markup[3];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[3])) {
            echo $right_column_markup[3];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>
                            <tr>
                                <?php 
        if (!empty($left_column_markup[4])) {
            echo $left_column_markup[4];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[4])) {
            echo $right_column_markup[4];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>
                            <tr>
                                <?php 
        if (!empty($left_column_markup[5])) {
            echo $left_column_markup[5];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                                <td class="center">&nbsp;</td>
                                <?php 
        if (!empty($right_column_markup[5])) {
            echo $right_column_markup[5];
        } else {
            echo $empty_column_placeholder;
        }
        ?>
                            </tr>
                        </tbody>
                    </table>

                    <table class="full">
                        <colgroup>
                            <col width="100%" />
                        </colgroup>
                        <tbody>
                            <tr>
                                <td class="right" style="padding-top: 4px;">
                                    <?/*<label style="display: block; float: left; font-size: 12px;">Abilities :</label>*/?>
                                    <?php 
        // Loop through all the abilities collected by the player and collect IDs
        $allowed_ability_ids = array();
        if (!empty($player_ability_rewards)) {
            foreach ($player_ability_rewards as $ability_token => $ability_info) {
                if (empty($ability_info['ability_token'])) {
                    continue;
                } elseif ($ability_info['ability_token'] == '*') {
                    continue;
                } elseif ($ability_info['ability_token'] == 'ability') {
                    continue;
                } elseif (!isset($mmrpg_database_abilities[$ability_info['ability_token']])) {
                    continue;
                } elseif (!self::has_ability_compatibility($robot_info['robot_token'], $ability_token, $current_item_token)) {
                    continue;
                }
                $ability_info['ability_id'] = $mmrpg_database_abilities[$ability_info['ability_token']]['ability_id'];
                $allowed_ability_ids[] = $ability_info['ability_id'];
            }
        }
        ?>
                                    <div class="ability_container" data-compatible="<?php 
        echo implode(',', $allowed_ability_ids);
        ?>
">
                                        <?php 
        // Sort the player ability index based on ability number
        uasort($player_ability_rewards, array('rpg_functions', 'abilities_sort_for_editor'));
        // Sort the robot ability index based on ability number
        sort($robot_ability_rewards);
        // Collect the ability reward options to be used on all selects
        $ability_rewards_options = $global_allow_editing ? rpg_ability::print_editor_options_list_markup($player_ability_rewards, $robot_ability_rewards, $player_info, $robot_info) : '';
        // Loop through the robot's current abilities and list them one by one
        $empty_ability_counter = 0;
        if (!empty($robot_info['robot_abilities'])) {
            $temp_string = array();
            $temp_inputs = array();
            $ability_key = 0;
            // DEBUG
            //echo 'robot-ability:';
            foreach ($robot_info['robot_abilities'] as $robot_ability) {
                if (empty($robot_ability['ability_token'])) {
                    continue;
                } elseif ($robot_ability['ability_token'] == '*') {
                    continue;
                } elseif ($robot_ability['ability_token'] == 'ability') {
                    continue;
                } elseif (!isset($mmrpg_database_abilities[$robot_ability['ability_token']])) {
                    continue;
                } elseif ($ability_key > 7) {
                    continue;
                }
                $ability_token = $robot_ability['ability_token'];
                $this_ability = rpg_ability::parse_index_info($mmrpg_database_abilities[$ability_token]);
                if (empty($ability_token) || empty($this_ability)) {
                    continue;
                } elseif (!self::has_ability_compatibility($robot_info['robot_token'], $ability_token, $current_item_token)) {
                    continue;
                }
                $temp_select_markup = rpg_ability::print_editor_select_markup($ability_rewards_options, $player_info, $robot_info, $this_ability, $ability_key);
                $temp_string[] = $temp_select_markup;
                $ability_key++;
            }
            if ($ability_key <= 7) {
                for ($ability_key; $ability_key <= 7; $ability_key++) {
                    $empty_ability_counter++;
                    if ($empty_ability_counter >= 2) {
                        $empty_ability_disable = true;
                    } else {
                        $empty_ability_disable = false;
                    }
                    //$temp_select_options = str_replace('value=""', 'value="" selected="selected" disabled="disabled"', $ability_rewards_options);
                    $this_ability_title_html = '<label>-</label>';
                    //if ($global_allow_editing){ $this_ability_title_html .= '<select class="ability_name" data-key="'.$ability_key.'" data-player="'.$player_info['player_token'].'" data-robot="'.$robot_info['robot_token'].'" '.($empty_ability_disable ? 'disabled="disabled" ' : '').'>'.$temp_select_options.'</select>'; }
                    $temp_string[] = '<a class="ability_name " style="' . ($empty_ability_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-id="0" data-key="' . $ability_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-ability="" title="" data-tooltip="">' . $this_ability_title_html . '</a>';
                }
            }
        } else {
            for ($ability_key = 0; $ability_key <= 7; $ability_key++) {
                $empty_ability_counter++;
                if ($empty_ability_counter >= 2) {
                    $empty_ability_disable = true;
                } else {
                    $empty_ability_disable = false;
                }
                //$temp_select_options = str_replace('value=""', 'value="" selected="selected"', $ability_rewards_options);
                $this_ability_title_html = '<label>-</label>';
                //if ($global_allow_editing){ $this_ability_title_html .= '<select class="ability_name" data-key="'.$ability_key.'" data-player="'.$player_info['player_token'].'" data-robot="'.$robot_info['robot_token'].'" '.($empty_ability_disable ? 'disabled="disabled" ' : '').'>'.$temp_select_options.'</select>'; }
                $temp_string[] = '<a class="ability_name " style="' . ($empty_ability_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-id="0" data-key="' . $ability_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-ability="">' . $this_ability_title_html . '</a>';
            }
        }
        // DEBUG
        //echo 'temp-string:';
        echo !empty($temp_string) ? implode(' ', $temp_string) : '';
        // DEBUG
        //echo '<br />temp-inputs:';
        echo !empty($temp_inputs) ? implode(' ', $temp_inputs) : '';
        // DEBUG
        //echo '<br />';
        ?>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php 
        $key_counter++;
        // Return the backup of the player selector
        $allow_player_selector = $allow_player_selector_backup;
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
Esempio n. 5
0
    /**
     * Generate the markup for the in-game battle menu given environment variables
     * @param $objects array
     * @param $kind string (battle, ability, scan, item, option, switch, target_this, target_target, target_this_disabled)
     * @return array
     */
    public static function get_menu_markup($objects, $menu_kind)
    {
        // Extract global objects into local scope
        extract($objects);
        // Count the total number of robots
        $num_robots = count($this_player->player_robots);
        $robot_direction = $this_player->player_side == 'left' ? 'right' : 'left';
        // Collect this and target robot options and sort them
        $this_player_robots = $this_player->player_robots;
        $target_player_robots = $target_player->player_robots;
        usort($this_player_robots, array('rpg_functions', 'robot_sort_by_active'));
        usort($target_player_robots, array('rpg_functions', 'robot_sort_by_active'));
        // Collect required item and ability tokens to display
        $temp_item_tokens = array();
        $temp_ability_tokens = array();
        if (!empty($this_player->player_items)) {
            $temp_item_tokens = array_merge($temp_item_tokens, $this_player->player_items);
        }
        if (!empty($target_player->player_items)) {
            $temp_item_tokens = array_merge($temp_item_tokens, $target_player->player_items);
        }
        foreach (array($this_player_robots, $target_player_robots) as $player_robots) {
            foreach ($player_robots as $robot_key => $robot_info) {
                if (!empty($robot_info['robot_item'])) {
                    $temp_item_tokens[] = $robot_info['robot_item'];
                }
                if (!empty($robot_info['robot_abilities'])) {
                    $temp_ability_tokens = array_merge($temp_ability_tokens, $robot_info['robot_abilities']);
                }
            }
        }
        $temp_item_tokens = array_unique($temp_item_tokens);
        $temp_ability_tokens = array_unique($temp_ability_tokens);
        // Generate custom ability and item indexes for reference
        $temp_items_index = rpg_item::get_index_custom($temp_item_tokens);
        $temp_abilities_index = rpg_ability::get_index_custom($temp_ability_tokens);
        // Generate the markup for the action battle panel
        ob_start();
        // Generate different markup for the different menu kinds
        switch ($menu_kind) {
            // If this was a BATTLE menu request
            case 'battle':
                // If the current robot is not disabled and is active
                if ($this_robot->robot_energy > 0 && $this_robot->robot_position == 'active') {
                    // Define the order counter and start at one
                    $dataOrder = 1;
                    // Display available main actions
                    ?>
<div class="main_actions"><?php 
                    if (!empty($temp_player_ability_actions) || $this_robot->robot_class == 'mecha') {
                        ?>
<a class="button action_ability" type="button" data-panel="ability" data-order="<?php 
                        echo $dataOrder;
                        ?>
"><label>Ability</label></a><?php 
                    } else {
                        ?>
<a class="button button_disabled action_ability" type="button" data-action="ability_8_action-noweapons" data-order="<?php 
                        echo $dataOrder;
                        ?>
"><label style="text-decoration: line-through;">Ability</label></a><?php 
                    }
                    $dataOrder++;
                    ?>
</div><?php 
                    // Display the available sub options
                    ?>
<div class="sub_actions"><?php 
                    // Display the SCAN option
                    if ($target_player->counters['robots_active'] > 1) {
                        ?>
<a class="button action_scan" type="button" <?php 
                        echo $target_player->counters['robots_active'] > 1 ? 'data-panel="scan"' : 'data-action="scan_' . $target_robot->robot_id . '_' . $target_robot->robot_token . '"';
                        ?>
 data-order="<?php 
                        echo $dataOrder;
                        ?>
"><label>Scan</label></a><?php 
                    } else {
                        foreach ($target_player->values['robots_active'] as $key => $info) {
                            if ($info['robot_position'] != 'active') {
                                continue;
                            }
                            ?>
<a class="button action_scan" type="button" data-action="scan_<?php 
                            echo $info['robot_id'] . '_' . $info['robot_token'];
                            ?>
" data-order="<?php 
                            echo $dataOrder;
                            ?>
"><label>Scan</label></a><?php 
                            break;
                        }
                    }
                    $dataOrder++;
                    // Display the ITEM option
                    $temp_disabled = false;
                    ?>
<a class="button action_item <?php 
                    echo $temp_disabled ? 'button_disabled' : '';
                    ?>
" type="button" <?php 
                    echo !$temp_disabled ? 'data-panel="item"' : '';
                    ?>
 <?php 
                    echo !$temp_disabled ? 'data-order="' . $dataOrder . '"' : '';
                    ?>
><label>Item</label></a><?php 
                    if (!$temp_disabled) {
                        $dataOrder++;
                    }
                    // Display the OPTION option
                    ?>
<a class="button action_option" type="button" data-panel="option" data-order="<?php 
                    echo $dataOrder;
                    ?>
"><label>Option</label></a><?php 
                    $dataOrder++;
                    // Display the SWITCH option
                    ?>
<a class="button action_switch" type="button" data-panel="switch" data-order="<?php 
                    echo $dataOrder;
                    ?>
"><label>Switch</label></a><?php 
                    $dataOrder++;
                    ?>
</div><?php 
                } else {
                    // Display available main actions
                    ?>
<div class="main_actions"><?php 
                    ?>
<a class="button action_ability button_disabled" type="button"><label>Ability</label></a><?php 
                    ?>
</div><?php 
                    // Display the available sub options
                    ?>
<div class="sub_actions"><?php 
                    ?>
<a class="button action_scan button_disabled" type="button"><label>Scan</label></a><?php 
                    ?>
<a class="button action_item button_disabled" type="button"><label>Item</label></a><?php 
                    ?>
<a class="button action_option" type="button" data-panel="option" data-order="1"><label>Option</label></a><?php 
                    ?>
<a class="button action_switch" type="button" data-panel="switch" data-order="2"><label>Switch</label></a><?php 
                    ?>
</div><?php 
                }
                break;
                // If this was a ABILITY menu request
            // If this was a ABILITY menu request
            case 'ability':
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select Ability</span><?php 
                // Collect the abilities for this robot, by whatever means
                if ($this_robot->robot_class == 'master') {
                    $this_robot_settings = rpg_game::robot_settings($this_player->player_token, $this_robot->robot_token);
                    if (!empty($this_robot_settings['robot_abilities'])) {
                        $current_robot_abilities = $this_robot_settings['robot_abilities'];
                    } else {
                        $current_robot_abilities = array();
                    }
                    // If this robot has more than eight abilities, slice to only eight
                    if (count($current_robot_abilities) > 8) {
                        $current_robot_abilities = array_slice($current_robot_abilities, 0, 8);
                        $_SESSION['GAME']['values']['battle_settings'][$this_player->player_token]['player_robots'][$this_robot->robot_token]['robot_abilities'] = $current_robot_abilities;
                    }
                    // Collect the robot's held item if any
                    if (!empty($_SESSION['GAME']['values']['battle_settings'][$this_player->player_token]['player_robots'][$this_robot->robot_token]['robot_item'])) {
                        $current_robot_item = $_SESSION['GAME']['values']['battle_settings'][$this_player->player_token]['player_robots'][$this_robot->robot_token]['robot_item'];
                    } else {
                        $current_robot_item = '';
                    }
                } elseif ($this_robot->robot_class == 'mecha') {
                    // Collect the temp ability index
                    $temp_index_info = rpg_robot::get_index_info($this_robot->robot_token);
                    $current_robot_abilities = array();
                    foreach ($temp_index_info['robot_abilities'] as $token) {
                        $current_robot_abilities[$token] = array('ability_token' => $token);
                    }
                    $current_robot_item = '';
                }
                // Ensure this robot has abilities to display
                if (!empty($current_robot_abilities)) {
                    // Count the total number of abilities
                    $num_abilities = count($this_robot->robot_abilities);
                    $robot_direction = $this_player->player_side == 'left' ? 'right' : 'left';
                    // Define the ability display counter
                    $unlocked_abilities_count = 0;
                    // Collect the temp ability index
                    $temp_abilities_index = rpg_ability::get_index_custom(array_keys($current_robot_abilities));
                    $temp_robotinfo = rpg_robot::get_index_info($this_robot->robot_token);
                    if ($temp_robotinfo['robot_core'] != $this_robot->robot_core) {
                        $temp_robotinfo['robot_core'] = $this_robot->robot_core;
                    }
                    $temp_robotinfo['robot_core2'] = preg_match('/^item-core-/i', $current_robot_item) ? preg_replace('/^item-core-/i', '', $current_robot_item) : '';
                    if ($temp_robotinfo['robot_core2'] == 'none') {
                        $temp_robotinfo['robot_core2'] = '';
                    }
                    // Loop through each ability and display its button
                    $ability_key = 0;
                    //$temp_robot_array = $this_robot->export_array();
                    foreach ($current_robot_abilities as $ability_token => $ability_info) {
                        if (empty($ability_token) || !isset($temp_abilities_index[$ability_token])) {
                            continue;
                        }
                        // Check if this ability has been unlocked
                        $this_ability_unlocked = true;
                        if ($this_ability_unlocked) {
                            $unlocked_abilities_count++;
                        } else {
                            continue;
                        }
                        // Create the ability object using the session/index data
                        $temp_abilityinfo = $temp_abilities_index[$ability_token];
                        $temp_abilityinfo['ability_id'] = $this_robot->robot_id . str_pad($temp_abilityinfo['ability_id'], 3, '0', STR_PAD_LEFT);
                        $temp_ability = $this_battle->get_ability($temp_abilityinfo['ability_id']);
                        $temp_type = $temp_ability->ability_type;
                        $temp_type2 = $temp_ability->ability_type2;
                        $temp_damage = $temp_ability->ability_damage;
                        $temp_damage2 = $temp_ability->ability_damage2;
                        $temp_damage_unit = $temp_ability->ability_damage_percent ? '%' : '';
                        $temp_damage2_unit = $temp_ability->ability_damage2_percent ? '%' : '';
                        $temp_recovery = $temp_ability->ability_recovery;
                        $temp_recovery2 = $temp_ability->ability_recovery2;
                        $temp_recovery_unit = $temp_ability->ability_recovery_percent ? '%' : '';
                        $temp_recovery2_unit = $temp_ability->ability_recovery2_percent ? '%' : '';
                        $temp_accuracy = $temp_ability->ability_accuracy;
                        $temp_kind = !empty($temp_damage) && empty($temp_recovery) ? 'damage' : (!empty($temp_recovery) && empty($temp_damage) ? 'recovery' : (!empty($temp_damage) && !empty($temp_recovery) ? 'multi' : ''));
                        $temp_target = 'auto';
                        $temp_target_text = '';
                        if ($temp_ability->ability_target == 'select_target' && $target_player->counters['robots_active'] > 1) {
                            $temp_target = 'select_target';
                            $temp_target_text = 'Select Target';
                        } elseif ($temp_ability->ability_target == 'select_this') {
                            $temp_target = 'select_this';
                            $temp_target_text = 'Select Target';
                        }
                        $temp_multiplier = 1;
                        if (!empty($this_robot->robot_core) && ($this_robot->robot_core == $temp_type || $this_robot->robot_core == $temp_type2)) {
                            $temp_multiplier = $temp_multiplier * 1.5;
                        }
                        if (!empty($temp_type) && !empty($this_battle->battle_field->field_multipliers[$temp_type])) {
                            $temp_multiplier = $temp_multiplier * $this_battle->battle_field->field_multipliers[$temp_type];
                        } elseif (!empty($this_battle->battle_field->field_multipliers['none'])) {
                            $temp_multiplier = $temp_multiplier * $this_battle->battle_field->field_multipliers['none'];
                        }
                        if (!empty($temp_type2) && !empty($this_battle->battle_field->field_multipliers[$temp_type2])) {
                            $temp_multiplier = $temp_multiplier * $this_battle->battle_field->field_multipliers[$temp_type2];
                        }
                        $temp_damage = ceil($temp_damage * $temp_multiplier);
                        if (!preg_match('/-(booster|breaker)$/i', $ability_token) && !empty($this_battle->battle_field->field_multipliers['damage'])) {
                            $temp_damage = ceil($temp_damage * $this_battle->battle_field->field_multipliers['damage']);
                        }
                        if ($temp_damage_unit == '%' && $temp_damage > 100) {
                            $temp_damage = 100;
                        }
                        $temp_damage2 = ceil($temp_damage2 * $temp_multiplier);
                        if (!preg_match('/-(booster|breaker)$/i', $ability_token) && !empty($this_battle->battle_field->field_multipliers['damage'])) {
                            $temp_damage2 = ceil($temp_damage2 * $this_battle->battle_field->field_multipliers['damage']);
                        }
                        if ($temp_damage2_unit == '%' && $temp_damage2 > 100) {
                            $temp_damage2 = 100;
                        }
                        $temp_recovery = ceil($temp_recovery * $temp_multiplier);
                        if (!preg_match('/-(booster|breaker)$/i', $ability_token) && !empty($this_battle->battle_field->field_multipliers['recovery'])) {
                            $temp_recovery = ceil($temp_recovery * $this_battle->battle_field->field_multipliers['recovery']);
                        }
                        if ($temp_recovery_unit == '%' && $temp_recovery > 100) {
                            $temp_recovery = 100;
                        }
                        $temp_recovery2 = ceil($temp_recovery2 * $temp_multiplier);
                        if (!preg_match('/-(booster|breaker)$/i', $ability_token) && !empty($this_battle->battle_field->field_multipliers['recovery'])) {
                            $temp_recovery2 = ceil($temp_recovery2 * $this_battle->battle_field->field_multipliers['recovery']);
                        }
                        if ($temp_recovery2_unit == '%' && $temp_recovery2 > 100) {
                            $temp_recovery2 = 100;
                        }
                        // Define the amount of weapon energy for this ability
                        $temp_robot_weapons = $this_robot->robot_weapons;
                        $temp_ability_energy = $this_robot->calculate_weapon_energy($temp_ability, $temp_ability_energy_base, $temp_ability_energy_mods);
                        // Collect the type info for this ability if it exists
                        $temp_type_info = !empty($temp_ability->ability_type) ? rpg_type::get_index_info($temp_ability->ability_type) : false;
                        $temp_type_info2 = !empty($temp_ability->ability_type2) ? rpg_type::get_index_info($temp_ability->ability_type2) : false;
                        // Define the ability title details text
                        $temp_ability_details = $temp_ability->ability_name;
                        $temp_ability_details .= ' (' . (!empty($temp_type_info) ? $temp_type_info['type_name'] : 'Neutral');
                        if (!empty($temp_type_info2)) {
                            $temp_ability_details .= ' / ' . $temp_type_info2['type_name'];
                        } else {
                            $temp_ability_details .= ' Type';
                        }
                        $temp_ability_details .= ') <br />';
                        if ($temp_kind == 'damage') {
                            $temp_ability_details .= $temp_damage . $temp_damage_unit . ' Damage';
                        } elseif ($temp_kind == 'recovery') {
                            $temp_ability_details .= $temp_recovery . $temp_recovery_unit . ' Recovery';
                        } elseif ($temp_kind == 'multi') {
                            $temp_ability_details .= $temp_damage . $temp_damage_unit . ' Damage / ' . ($temp_multiplier != 1 ? '<del>' . $temp_ability->ability_recovery . '</del> ' : '') . $temp_recovery . $temp_recovery_unit . ' Recovery';
                        } else {
                            $temp_ability_details .= 'Support';
                        }
                        $temp_ability_details .= ' | ' . $temp_ability->ability_accuracy . '% Accuracy';
                        if (!empty($temp_ability_energy)) {
                            $temp_ability_details .= ' | ' . $temp_ability_energy . ' Energy';
                        }
                        if (!empty($temp_target_text)) {
                            $temp_ability_details .= ' | ' . $temp_target_text;
                        }
                        $temp_ability_description = $temp_ability->ability_description;
                        $temp_ability_description = str_replace('{DAMAGE}', $temp_damage, $temp_ability_description);
                        $temp_ability_description = str_replace('{RECOVERY}', $temp_recovery, $temp_ability_description);
                        $temp_ability_description = str_replace('{DAMAGE2}', $temp_damage2, $temp_ability_description);
                        $temp_ability_description = str_replace('{RECOVERY2}', $temp_recovery2, $temp_ability_description);
                        $temp_ability_details .= ' <br />' . $temp_ability_description;
                        $temp_ability_details_plain = strip_tags(str_replace('<br />', '&#10;', $temp_ability_details));
                        $temp_ability_details_tooltip = htmlentities($temp_ability_details, ENT_QUOTES, 'UTF-8');
                        // Define the ability button text variables
                        $temp_ability_label = '<span class="multi">';
                        $temp_ability_label .= '<span class="maintext">' . $temp_ability->ability_name . '</span>';
                        $temp_ability_label .= '<span class="subtext">';
                        $temp_ability_label .= !empty($temp_type_info) ? $temp_type_info['type_name'] . ' ' : 'Neutral ';
                        if (!empty($temp_type_info2)) {
                            $temp_ability_label .= ' / ' . $temp_type_info2['type_name'];
                        } else {
                            $temp_ability_label .= $temp_kind == 'damage' ? 'Damage' : ($temp_kind == 'recovery' ? 'Recovery' : ($temp_kind == 'multi' ? 'Effects' : 'Special'));
                        }
                        $temp_ability_label .= '</span>';
                        $temp_ability_label .= '<span class="subtext">';
                        $temp_ability_label .= '<span style="' . ($temp_multiplier != 1 ? $temp_multiplier > 1 ? 'color: rgb(161, 255, 124); ' : 'color: rgb(255, 150, 150); ' : '') . '">P:' . ($temp_kind == 'damage' ? $temp_damage . $temp_damage_unit . ' ' : ($temp_kind == 'recovery' ? $temp_recovery . $temp_recovery_unit . ' ' : ($temp_kind == 'multi' ? $temp_damage . $temp_damage_unit . '/' . $temp_recovery . $temp_recovery_unit . ' ' : '0'))) . '</span>';
                        $temp_ability_label .= '&nbsp;';
                        $temp_ability_label .= 'A:' . $temp_accuracy . '%';
                        $temp_ability_label .= '</span>';
                        $temp_ability_label .= '</span>';
                        // Define whether or not this ability button should be enabled
                        $temp_button_enabled = $temp_robot_weapons >= $temp_ability_energy ? true : false;
                        // If the ability is not actually compatible with this robot, disable it
                        $temp_button_compatible = rpg_robot::has_ability_compatibility($temp_robotinfo, $temp_abilityinfo, $current_robot_item);
                        if (!$temp_button_compatible) {
                            $temp_button_enabled = false;
                        }
                        // If this button is enabled, add it to the global ability options array
                        if ($temp_button_enabled) {
                            $temp_player_ability_actions[] = $temp_ability->ability_token;
                        }
                        // Define the ability sprite variables
                        $temp_ability_sprite = array();
                        $temp_ability_sprite['name'] = $temp_ability->ability_name;
                        if ($this_robot->robot_class == 'master') {
                            $temp_ability_sprite['image'] = $temp_ability->ability_image;
                            $temp_ability_sprite['image_size'] = $temp_ability->ability_image_size;
                            $temp_ability_sprite['image_size_text'] = $temp_ability_sprite['image_size'] . 'x' . $temp_ability_sprite['image_size'];
                            $temp_ability_sprite['image_size_zoom'] = $temp_ability->ability_image_size * 2;
                            $temp_ability_sprite['image_size_zoom_text'] = $temp_ability_sprite['image_size'] . 'x' . $temp_ability_sprite['image_size'];
                            $temp_ability_sprite['url'] = 'images/sprites/abilities/' . $temp_ability_sprite['image'] . '/icon_' . $robot_direction . '_' . $temp_ability_sprite['image_size_text'] . '.png';
                            $temp_ability_sprite['class'] = 'sprite size' . $temp_ability_sprite['image_size'] . ' base ';
                            $temp_ability_sprite['style'] = 'background-image: url(' . $temp_ability_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . '); top: 5px; left: 5px; ';
                            $temp_ability_sprite['markup'] = '<span class="' . $temp_ability_sprite['class'] . ' ability" style="' . $temp_ability_sprite['style'] . '">' . $temp_ability_sprite['name'] . '</span>';
                            $temp_ability_sprite['markup'] .= '<span class="' . $temp_ability_sprite['class'] . ' weapons" style="top: 35px; left: 5px; ' . ($temp_ability_energy == $temp_ability_energy_base ? '' : ($temp_ability_energy_mods <= 1 ? 'color: #80A280; ' : 'color: #68B968; ')) . '">' . $temp_ability_energy . ' WE</span>';
                        } elseif ($this_robot->robot_class == 'mecha') {
                            $temp_ability_sprite['image'] = $this_robot->robot_image;
                            $temp_ability_sprite['image_size'] = $this_robot->robot_image_size;
                            $temp_ability_sprite['image_size_text'] = $temp_ability_sprite['image_size'] . 'x' . $temp_ability_sprite['image_size'];
                            $temp_ability_sprite['image_size_zoom'] = $this_robot->robot_image_size * 2;
                            $temp_ability_sprite['image_size_zoom_text'] = $temp_ability_sprite['image_size'] . 'x' . $temp_ability_sprite['image_size'];
                            $temp_ability_sprite['url'] = 'images/sprites/robots/' . $temp_ability_sprite['image'] . '/mug_' . $robot_direction . '_' . $temp_ability_sprite['image_size_text'] . '.png';
                            $temp_ability_sprite['class'] = 'sprite size' . $temp_ability_sprite['image_size'] . ' base ';
                            $temp_ability_sprite['style'] = 'background-image: url(' . $temp_ability_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . '); top: 7px; left: 5px; height: 43px; background-position: center center !important; background-size: 50% 50% !important; ';
                            $temp_ability_sprite['markup'] = '<span class="' . $temp_ability_sprite['class'] . ' ability" style="' . $temp_ability_sprite['style'] . '">' . $temp_ability_sprite['name'] . '</span>';
                        }
                        $temp_ability_sprite['preload'] = 'images/sprites/abilities/' . $temp_ability_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_ability_sprite['image_size_zoom_text'] . '.png';
                        // Now use the new object to generate a snapshot of this ability button
                        if ($temp_button_enabled) {
                            ?>
<a data-order="<?php 
                            echo $temp_order_counter;
                            ?>
" class="button action_ability ability_<?php 
                            echo $temp_ability->ability_token;
                            ?>
 ability_type ability_type_<?php 
                            echo (!empty($temp_ability->ability_type) ? $temp_ability->ability_type : 'none') . (!empty($temp_ability->ability_type2) ? '_' . $temp_ability->ability_type2 : '');
                            ?>
 block_<?php 
                            echo $unlocked_abilities_count;
                            ?>
" type="button" data-action="ability_<?php 
                            echo $temp_ability->ability_id . '_' . $temp_ability->ability_token;
                            ?>
" data-tooltip="<?php 
                            echo $temp_ability_details_tooltip;
                            ?>
" data-target="<?php 
                            echo $temp_target;
                            ?>
"><label class=""><?php 
                            echo $temp_ability_sprite['markup'];
                            echo $temp_ability_label;
                            ?>
</label></a><?php 
                        } else {
                            ?>
<a data-order="<?php 
                            echo $temp_order_counter;
                            ?>
" class="button button_disabled action_ability ability_<?php 
                            echo $temp_ability->ability_token;
                            ?>
 ability_type ability_type_<?php 
                            echo (!empty($temp_ability->ability_type) ? $temp_ability->ability_type : 'none') . (!empty($temp_ability->ability_type2) ? '_' . $temp_ability->ability_type2 : '');
                            ?>
 block_<?php 
                            echo $unlocked_abilities_count;
                            ?>
" type="button"><label class=""><?php 
                            echo $temp_ability_sprite['markup'];
                            echo $temp_ability_label;
                            ?>
</label></a><?php 
                        }
                        // Increment the order counter
                        $temp_order_counter++;
                        $ability_key++;
                    }
                    // If there were less than 8 abilities, fill in the empty spaces
                    if ($unlocked_abilities_count < 8) {
                        for ($i = $unlocked_abilities_count; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_ability button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                //echo 'Abilities : ['.print_r($this_robot->robot_abilities, true).']';
                //echo preg_replace('#\s+#', ' ', print_r($this_robot_settings, true));
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="battle"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a ITEM menu request
            // If this was a ITEM menu request
            case 'item':
                // Define all the available player items in a handy index array
                $current_player_items = $this_player->player_items;
                foreach ($current_player_items as $key => $token) {
                    $info = !empty($temp_items_index[$token]) ? $temp_items_index[$token] : false;
                    if (empty($info) || $info['ability_subclass'] != 'consumable') {
                        unset($current_player_items[$key]);
                    }
                }
                $current_player_items_count = count($current_player_items);
                $current_player_items_pages = $current_player_items_count <= 8 ? 1 : ceil($current_player_items_count / 8);
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
                <div class="main_actions main_actions_hastitle">
                    <span class="main_actions_title <?php 
                echo $target_player->player_id != MMRPG_SETTINGS_TARGET_PLAYERID || !empty($this_player->flags['item_used_this_turn']) ? 'main_actions_title_disabled' : '';
                ?>
">
                        <?php 
                // If there were more than eight items, print the page numbers
                if ($current_player_items_count > 8) {
                    $temp_selected_page = 1;
                    //!empty($_SESSION['GAME']['battle_settings']['action_ability_page_num']) ? $_SESSION['GAME']['battle_settings']['action_ability_page_num'] : 1;
                    echo '<span class="float_title">Select Item</span>';
                    echo '<span class="float_links"><span class="page">Page</span>';
                    for ($i = 1; $i <= $current_player_items_pages; $i++) {
                        echo '<a class="num' . ($i == $temp_selected_page ? ' active' : '') . '" href="#' . $i . '">' . $i . '</a>';
                    }
                    echo '</span>';
                } else {
                    echo 'Select Item';
                }
                ?>
                    </span>
                    <?php 
                // Ensure this player has items to display
                if (!empty($current_player_items)) {
                    // Count the total number of items
                    $num_items = count($current_player_items);
                    $item_direction = $this_player->player_side == 'left' ? 'right' : 'left';
                    // Define the item display counter
                    $equipped_items_count = 0;
                    // Define the default button enabled option
                    if ($target_player->player_id != MMRPG_SETTINGS_TARGET_PLAYERID) {
                        $temp_button_enabled_base = false;
                    } else {
                        $temp_button_enabled_base = true;
                    }
                    // If this player has already used an item this turn
                    if (!empty($this_player->flags['item_used_this_turn'])) {
                        $temp_button_enabled_base = false;
                    }
                    // Loop through each ability and display its button
                    $item_key = 0;
                    $item_token_list = array_keys($temp_items_index);
                    foreach ($item_token_list as $item_key => $item_token) {
                        // Ensure this is an actual ability in the index
                        if (!empty($item_token) && in_array($item_token, $current_player_items)) {
                            // Define the amount of weapon energy for this ability
                            $temp_item_quantity = !empty($_SESSION['GAME']['values']['battle_items'][$item_token]) ? $_SESSION['GAME']['values']['battle_items'][$item_token] : 0;
                            // CHANGEME to zero!!! mt_rand(0, 10)
                            $temp_item_cost = 1;
                            // If this player has never aquired this item, do not display it
                            if (!isset($_SESSION['GAME']['values']['battle_items'][$item_token])) {
                                continue;
                            }
                            //$temp_item_quantity = 99; // CHANGEME! COMMENT ME OUT! TESTING ONLY!
                            // Increment the equipped items count
                            $equipped_items_count++;
                            // Define the button enabled flag
                            $temp_button_enabled = $temp_button_enabled_base;
                            // Create the ability object using the session/index data
                            $temp_iteminfo = $temp_items_index[$item_token];
                            //$temp_iteminfo['item_id'] = $this_player->player_id.str_pad($temp_iteminfo['item_id'], 3, '0', STR_PAD_LEFT);
                            $temp_item = new rpg_item($this_player, $this_robot, $temp_iteminfo);
                            $temp_type = $temp_item->item_type;
                            $temp_type2 = $temp_item->item_type2;
                            $temp_damage = $temp_item->item_damage;
                            $temp_damage2 = $temp_item->item_damage2;
                            $temp_damage_unit = $temp_item->item_damage_percent ? '%' : '';
                            $temp_damage2_unit = $temp_item->item_damage2_percent ? '%' : '';
                            $temp_recovery = $temp_item->item_recovery;
                            $temp_recovery2 = $temp_item->item_recovery2;
                            $temp_recovery_unit = $temp_item->item_recovery_percent ? '%' : '';
                            $temp_recovery2_unit = $temp_item->item_recovery2_percent ? '%' : '';
                            $temp_accuracy = $temp_item->item_accuracy;
                            $temp_kind = !empty($temp_damage) && empty($temp_recovery) ? 'damage' : (!empty($temp_recovery) && empty($temp_damage) ? 'recovery' : (!empty($temp_damage) && !empty($temp_recovery) ? 'multi' : ''));
                            if (preg_match('/-score-ball$/i', $item_token)) {
                                $temp_kind = 'score';
                            } elseif (preg_match('/-core$/i', $item_token)) {
                                $temp_kind = 'core';
                            }
                            $temp_target = 'select_this';
                            if ($temp_item->item_target == 'select_target' && $target_player->counters['robots_active'] > 1) {
                                $temp_target = 'select_target';
                            } elseif ($temp_item->item_target == 'select_this' && $this_player->counters['robots_active'] > 1) {
                                $temp_target = 'select_this';
                            } elseif ($temp_item->item_target == 'select_this_disabled') {
                                $temp_target = 'select_this_disabled';
                            } elseif ($temp_item->item_target == 'auto') {
                                $temp_target = 'auto';
                            }
                            $temp_multiplier = 1;
                            // Collect the type info for this item if it exists
                            $temp_type_info = !empty($temp_item->item_type) ? rpg_type::get_index_info($temp_item->item_type) : false;
                            $temp_type_info2 = !empty($temp_item->item_type2) ? rpg_type::get_index_info($temp_item->item_type2) : false;
                            // Define the ability title details text
                            $temp_item_details = $temp_item->item_name . ' <br />';
                            if ($temp_kind == 'damage') {
                                $temp_item_details .= $temp_damage . $temp_damage_unit . ' Damage';
                            } elseif ($temp_kind == 'recovery') {
                                $temp_item_details .= $temp_recovery . $temp_recovery_unit . ' Recovery';
                            } elseif ($temp_kind == 'multi') {
                                $temp_item_details .= $temp_damage . $temp_damage_unit . ' Damage / ' . $temp_recovery . $temp_recovery_unit . ' Recovery';
                            } elseif ($temp_kind == 'core') {
                                $temp_item_details .= '10% Damage';
                            } else {
                                $temp_item_details .= 'Support';
                            }
                            if (!empty($temp_item_quantity)) {
                                if ($temp_item_quantity != 1) {
                                    $temp_item_details .= ' | ' . $temp_item_quantity . ' Units';
                                } else {
                                    $temp_item_details .= ' | 1 Unit';
                                }
                            }
                            $temp_item_description = $temp_item->item_description;
                            $temp_item_description = str_replace('{DAMAGE}', $temp_damage, $temp_item_description);
                            $temp_item_description = str_replace('{RECOVERY}', $temp_recovery, $temp_item_description);
                            $temp_item_description = str_replace('{DAMAGE2}', $temp_damage2, $temp_item_description);
                            $temp_item_description = str_replace('{RECOVERY2}', $temp_recovery2, $temp_item_description);
                            $temp_item_details .= ' <br />' . $temp_item_description;
                            $temp_item_details_plain = strip_tags(str_replace('<br />', '&#10;', $temp_item_details));
                            $temp_item_details_tooltip = htmlentities($temp_item_details, ENT_QUOTES, 'UTF-8');
                            // Define the ability button text variables
                            $temp_item_label = '<span class="multi">';
                            $temp_item_label .= '<span class="maintext">' . $temp_item->item_name . '</span>';
                            $temp_item_label .= '<span class="subtext">';
                            if ($temp_kind == 'score') {
                                $temp_item_label .= 'Reward Booster';
                            } elseif ($temp_kind == 'core') {
                                $temp_item_label .= !empty($temp_type_info) ? $temp_type_info['type_name'] : 'Neutral';
                                $temp_item_label .= ' Damage';
                            } else {
                                $temp_item_label .= !empty($temp_type_info) ? $temp_type_info['type_name'] . ' ' : 'Neutral ';
                                if (!empty($temp_type_info) && !empty($temp_type_info2)) {
                                    $temp_item_label .= ' / ' . $temp_type_info2['type_name'];
                                } else {
                                    $temp_item_label .= $temp_kind == 'damage' ? 'Damage' : ($temp_kind == 'recovery' ? 'Recovery' : ($temp_kind == 'multi' ? 'Effects' : 'Special'));
                                }
                            }
                            $temp_item_label .= '</span>';
                            $temp_item_label .= '<span class="subtext">';
                            if ($temp_kind == 'score') {
                                $temp_item_label .= '<span>Value : +' . $temp_recovery . $temp_recovery_unit . '</span>';
                            } elseif ($temp_kind == 'core') {
                                $temp_item_label .= '<span>Power : 10%</span>';
                            } else {
                                $temp_item_label .= '<span style="' . ($temp_multiplier != 1 ? $temp_multiplier > 1 ? 'color: rgb(161, 255, 124); ' : 'color: rgb(255, 150, 150); ' : '') . '">Power : ' . ($temp_kind == 'damage' ? $temp_damage . $temp_damage_unit . ' ' : ($temp_kind == 'recovery' ? $temp_recovery . $temp_recovery_unit . ' ' : ($temp_kind == 'multi' ? $temp_damage . $temp_damage_unit . '/' . $temp_recovery . $temp_recovery_unit . ' ' : '0'))) . '</span>';
                            }
                            $temp_item_label .= '&nbsp;';
                            $temp_item_label .= '</span>';
                            $temp_item_label .= '</span>';
                            // Define whether or not this ability button should be enabled
                            if ($temp_item_quantity < $temp_item_cost) {
                                $temp_button_enabled = false;
                            }
                            // Define the ability sprite variables
                            $temp_item_sprite = array();
                            $temp_item_sprite['name'] = $temp_item->item_name;
                            $temp_item_sprite['image'] = $temp_item->item_image;
                            if ($temp_item->item_token == 'item-extra-life') {
                                // Automatically change this ability's image based on player
                                if ($this_player->player_token == 'dr-light') {
                                    $temp_item_sprite['image'] = 'item-extra-life';
                                } elseif ($this_player->player_token == 'dr-wily') {
                                    $temp_item_sprite['image'] = 'item-extra-life-2';
                                } elseif ($this_player->player_token == 'dr-cossack') {
                                    $temp_item_sprite['image'] = 'item-extra-life-3';
                                }
                            }
                            $temp_item_sprite['image_size'] = $temp_item->item_image_size;
                            $temp_item_sprite['image_size_text'] = $temp_item_sprite['image_size'] . 'x' . $temp_item_sprite['image_size'];
                            $temp_item_sprite['image_size_zoom'] = $temp_item->item_image_size * 2;
                            $temp_item_sprite['image_size_zoom_text'] = $temp_item_sprite['image_size'] . 'x' . $temp_item_sprite['image_size'];
                            $temp_item_sprite['url'] = 'images/sprites/items/' . $temp_item_sprite['image'] . '/icon_' . $item_direction . '_' . $temp_item_sprite['image_size_text'] . '.png';
                            $temp_item_sprite['preload'] = 'images/sprites/items/' . $temp_item_sprite['image'] . '/sprite_' . $item_direction . '_' . $temp_item_sprite['image_size_zoom_text'] . '.png';
                            $temp_item_sprite['class'] = 'sprite size' . $temp_item_sprite['image_size'] . ' base ';
                            // ability_type ability_type_'.(!empty($temp_item->item_type) ? $temp_item->item_type : 'none');
                            $temp_item_sprite['style'] = 'background-image: url(' . $temp_item_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 5px; left: 5px; ';
                            $temp_item_sprite['markup'] = '<span class="' . $temp_item_sprite['class'] . ' ability" style="' . $temp_item_sprite['style'] . '">' . $temp_item_sprite['name'] . '</span>';
                            $temp_item_sprite['markup'] .= '<span class="' . $temp_item_sprite['class'] . ' weapons" style="top: 35px; left: 5px; ' . ($temp_item_quantity > 1 ? '' : ($temp_item_quantity > 0 ? 'color: #AA9393; ' : 'color: #A77D7D; ')) . '"><sup style="position: relative: bottom: 1px;">x</sup> ' . $temp_item_quantity . '</span>';
                            $temp_type_class = !empty($temp_item->item_type) ? $temp_item->item_type : 'none';
                            if ($temp_type_class != 'none' && !empty($temp_item->item_type2)) {
                                $temp_type_class .= '_' . $temp_item->item_type2;
                            } elseif ($temp_type_class == 'none' && !empty($temp_item->item_type2)) {
                                $temp_type_class = $temp_item->item_type2;
                            }
                            // Now use the new object to generate a snapshot of this ability button
                            if ($temp_button_enabled) {
                                ?>
<a data-order="<?php 
                                echo $temp_order_counter;
                                ?>
" class="button action_item ability_<?php 
                                echo $temp_item->item_token;
                                ?>
 ability_type ability_type_<?php 
                                echo $temp_type_class;
                                ?>
 block_<?php 
                                echo $equipped_items_count;
                                ?>
" type="button" data-action="ability_<?php 
                                echo $temp_item->item_id . '_' . $temp_item->item_token;
                                ?>
" data-tooltip="<?php 
                                echo $temp_item_details_tooltip;
                                ?>
" data-preload="<?php 
                                echo $temp_item_sprite['preload'];
                                ?>
" data-actualtarget="<?php 
                                echo $temp_item->item_target;
                                ?>
" data-target="<?php 
                                echo $temp_target;
                                ?>
"><label class=""><?php 
                                echo $temp_item_sprite['markup'];
                                echo $temp_item_label;
                                ?>
</label></a><?php 
                            } else {
                                ?>
<a data-order="<?php 
                                echo $temp_order_counter;
                                ?>
" class="button button_disabled action_item ability_<?php 
                                echo $temp_item->item_token;
                                ?>
 ability_type ability_type_<?php 
                                echo $temp_type_class;
                                ?>
 block_<?php 
                                echo $equipped_items_count;
                                ?>
" type="button"><label class=""><?php 
                                echo $temp_item_sprite['markup'];
                                echo $temp_item_label;
                                ?>
</label></a><?php 
                            }
                            // Increment the order counter
                            $temp_order_counter++;
                        }
                        $item_key++;
                    }
                    // If there were less than 8 items, fill in the empty spaces
                    if ($equipped_items_count % 8 != 0) {
                        $temp_padding_amount = 8 - $equipped_items_count % 8;
                        $temp_last_key = $equipped_items_count + $temp_padding_amount;
                        for ($i = $equipped_items_count; $i < $temp_last_key; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_item button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                ?>
                </div>
                <?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="battle"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a OPTION menu request
            // If this was a OPTION menu request
            case 'option':
                // Define the markup for the option buttons
                $temp_options = array();
                // Display the option for returning to the main prototype menu
                $temp_options[] = '<a data-order="1" class="button action_option block_1 ability_type_space" type="button" data-action="prototype"><label><span class="multi">Return&nbsp;To<br />Main&nbsp;Menu</span></label></a>';
                // Display an option for restarting this battle from scratch
                $temp_options[] = '<a data-order="2" class="button action_option block_2 ability_type_space" type="button" data-action="restart"><label><span class="multi">Restart<br />Mission</span></label></a>';
                // Display an option for changing config settings
                //$temp_options[] = '<a class="button action_option block_3" type="button" data-panel="settings"><label><span class="multi">Settings<br />Menu</span></label></a>';
                $temp_options[] = '<a data-order="3" class="button action_option block_3 ability_type_space" type="button" data-panel="settings_eventTimeout"><label><span class="multi">Message<br />Speed</span></label></a>';
                $temp_options[] = '<a data-order="4" class="button action_option block_4 ability_type_space" type="button" onclick="parent.mmrpg_music_load(\'fields/' . $this_field->field_music . '/battle-field_background_music\', true);"><label><span class="multi">Restart<br />Music</span></label></a>';
                // Display the toggle options for debug mode and stuff
                $current_debug_value = !empty($_SESSION['GAME']['debug_mode']) ? 1 : 0;
                $temp_options[] = '<a data-order="5" class="button action_option block_5 ability_type_space" type="button" onclick="mmrpg_toggle_debug_mode(this);" data-value="' . $current_debug_value . '"><label><span class="multi"><span class="title">Toggle Debug</span><br /><span class="value type ' . ($current_debug_value ? 'nature' : 'flame') . '">' . ($current_debug_value ? 'ON' : 'OFF') . '</span></span></label></a>';
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select Option</span><?php 
                // Ensure there are options to display
                if (!empty($temp_options)) {
                    // Count the total number of options
                    $num_options = count($temp_options);
                    // Loop through each option and display its button markup
                    foreach ($temp_options as $key => $option_markup) {
                        // Display the option button's generated markup
                        echo $option_markup;
                    }
                    // If there were less than 6 options, fill in the empty spaces
                    if ($num_options < 8) {
                        for ($i = $num_options; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_option button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="7" class="button action_back" type="button" data-panel="battle"><label>Back</label></a></div><?php 
                break;
                // If this was a SCAN menu request
            // If this was a SCAN menu request
            case 'scan':
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select Scan Target</span><?php 
                // Ensure there are robots to display
                if (!empty($target_player->player_robots)) {
                    // Loop through each robot and display its target button
                    foreach ($target_player_robots as $robot_key => $robot_info) {
                        // Ensure this robot has an ID before attempting to load
                        if (!empty($robot_info['robot_id'])) {
                            // Create the scan object using the session/index data
                            $temp_robot = $this_battle->get_robot($robot_info['robot_id']);
                            // Default the allow button flag to true
                            $allow_button = true;
                            // If this robot is disabled, disable the button
                            if ($temp_robot->robot_status == 'disabled') {
                                $allow_button = false;
                            }
                            // If this robot is not active, disable the button
                            //if ($temp_robot->robot_position != 'active'){ $allow_button = false; }
                            // Define the title hover for the robot
                            $temp_robot_title = $temp_robot->robot_name . '  (Lv. ' . $temp_robot->robot_level . ')';
                            //$temp_robot_title .= ' | '.$temp_robot->robot_id.'';
                            $temp_robot_title .= ' <br />' . (!empty($temp_robot->robot_core) ? ucfirst($temp_robot->robot_core) . ' Core' : 'Neutral Core') . ' | ' . ucfirst($temp_robot->robot_position) . ' Position';
                            // Display the robot's item if it exists
                            if (!empty($temp_robot->robot_item)) {
                                $temp_item = $temp_items_index[$temp_robot->robot_item];
                                $temp_robot_title .= ' | + ' . $temp_item['ability_name'] . ' ';
                            }
                            // Display the robot's life and weapon energy current and base
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_energy . ' / ' . $temp_robot->robot_base_energy . ' LE';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_weapons . ' / ' . $temp_robot->robot_base_weapons . ' WE';
                            $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                            if ($robot_direction == 'right' && $temp_robot->robot_class != 'mecha') {
                                $temp_robot_title .= ' | ' . $temp_robot->robot_experience . ' / ' . $temp_required_experience . ' EXP';
                            }
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_attack . ' / ' . $temp_robot->robot_base_attack . ' AT';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_defense . ' / ' . $temp_robot->robot_base_defense . ' DF';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_speed . ' / ' . $temp_robot->robot_base_speed . ' SP';
                            // Generate alt formats for the robot title
                            $temp_robot_title_plain = strip_tags(str_replace('<br />', '&#10;', $temp_robot_title));
                            $temp_robot_title_tooltip = htmlentities($temp_robot_title, ENT_QUOTES, 'UTF-8');
                            // Collect the robot's core types for display
                            $temp_robot_core_type = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_core2_type = !empty($temp_robot->robot_core2) ? $temp_robot->robot_core2 : '';
                            if (!empty($temp_robot->robot_item) && preg_match('/^item-core-/', $temp_robot->robot_item)) {
                                $temp_item_core_type = preg_replace('/^item-core-/', '', $temp_robot->robot_item);
                                if (empty($temp_robot_core2_type) && $temp_robot_core_type != $temp_item_core_type) {
                                    $temp_robot_core2_type = $temp_item_core_type;
                                }
                            }
                            // Define the robot button text variables
                            $temp_robot_label = '<span class="multi">';
                            $temp_robot_label .= '<span class="maintext">' . $temp_robot->robot_name . '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= $temp_robot->robot_energy . '/' . $temp_robot->robot_base_energy . ' Energy';
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= 'A:' . $temp_robot->robot_attack;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'D:' . $temp_robot->robot_defense;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'S:' . $temp_robot->robot_speed;
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '</span>';
                            // Define the robot sprite variables
                            $temp_robot_sprite = array();
                            $temp_robot_sprite['name'] = $temp_robot->robot_name;
                            $temp_robot_sprite['core'] = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_sprite['image'] = $temp_robot->robot_image;
                            $temp_robot_sprite['image_size'] = $temp_robot->robot_image_size;
                            $temp_robot_sprite['image_size_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['image_size_zoom'] = $temp_robot->robot_image_size * 2;
                            $temp_robot_sprite['image_size_zoom_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['url'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_text'] . '.png';
                            $temp_robot_sprite['preload'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_zoom_text'] . '.png';
                            $temp_robot_sprite['class'] = 'sprite size' . $temp_robot_sprite['image_size'] . ' ' . ($temp_robot->robot_energy > 0 ? $temp_robot->robot_energy > $temp_robot->robot_base_energy / 2 ? 'base' : 'defend' : 'defeat') . ' ';
                            $temp_robot_sprite['style'] = 'background-image: url(' . $temp_robot_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 6px; left: 5px; ';
                            if ($temp_robot->robot_position == 'active') {
                                $temp_robot_sprite['style'] .= 'border-color: #ababab; ';
                            }
                            $temp_energy_percent = ceil($temp_robot->robot_energy / $temp_robot->robot_base_energy * 100);
                            if ($temp_energy_percent > 50) {
                                $temp_robot_sprite['class'] .= 'energy high ';
                            } elseif ($temp_energy_percent > 25) {
                                $temp_robot_sprite['class'] .= 'energy medium ';
                            } elseif ($temp_energy_percent > 0) {
                                $temp_robot_sprite['class'] .= 'energy low ';
                            }
                            $temp_robot_sprite['markup'] = '<span class="' . $temp_robot_sprite['class'] . '" style="' . $temp_robot_sprite['style'] . '">' . $temp_robot_sprite['name'] . '</span>';
                            // Update the order button if necessary
                            $order_button_markup = $allow_button ? 'data-order="' . $temp_order_counter . '"' : '';
                            $temp_order_counter += $allow_button ? 1 : 0;
                            // Now use the new object to generate a snapshot of this switch button
                            /*?><a <?= $order_button_markup?> title="<?= $temp_robot_title_plain?>" data-tooltip="<?= $temp_robot_title_tooltip?>" class="button <?= !$allow_button ? 'button_disabled' : '' ?> action_scan scan_<?= $temp_robot->robot_token ?> status_<?= $temp_robot->robot_status ?> robot_type robot_type_<?= !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none' ?> block_<?= $robot_key + 1 ?>" type="button" <?if($allow_button):?>data-action="scan_<?= $temp_robot->robot_id.'_'.$temp_robot->robot_token ?>"<?endif;?> data-preload="<?= $temp_robot_sprite['preload'] ?>"><label><?= $temp_robot_sprite['markup'] ?><?= $temp_robot_label ?></label></a><?*/
                            ?>
<a class="button <?php 
                            echo !$allow_button ? 'button_disabled' : '';
                            ?>
 action_scan scan_<?php 
                            echo $temp_robot->robot_token;
                            ?>
 status_<?php 
                            echo $temp_robot->robot_status;
                            ?>
 robot_type robot_type_<?php 
                            echo $temp_robot_core_type . (!empty($temp_robot_core2_type) ? '_' . $temp_robot_core2_type : '');
                            ?>
 block_<?php 
                            echo $robot_key + 1;
                            ?>
" type="button" data-tooltip="<?php 
                            echo $temp_robot_title_tooltip;
                            ?>
" <?php 
                            echo $order_button_markup;
                            ?>
 <?if($allow_button):?>data-action="scan_<?php 
                            echo $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                            ?>
"<?endif;?> data-preload="<?php 
                            echo $temp_robot_sprite['preload'];
                            ?>
"><label><?php 
                            echo $temp_robot_sprite['markup'];
                            echo $temp_robot_label;
                            ?>
</label></a><?php 
                        }
                    }
                    // If there were less than 8 robots, fill in the empty spaces
                    if ($num_robots < 8) {
                        for ($i = $num_robots; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_scan button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="battle"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a SWITCH menu request
            // If this was a SWITCH menu request
            case 'switch':
                // Check if the switch should be disabled
                $this_switch_disabled = false;
                if ($this_robot->robot_status != 'disabled' && $this_robot->robot_position == 'active' && !empty($this_robot->robot_attachments)) {
                    foreach ($this_robot->robot_attachments as $attachment_token => $attachment_info) {
                        if (isset($attachment_info['attachment_switch_disabled']) && $attachment_info['attachment_switch_disabled'] == 1) {
                            $this_switch_disabled = true;
                        }
                    }
                }
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title" style="<?php 
                echo !empty($this_player->flags['switch_used_this_turn']) ? 'text-decoration: line-through;' : '';
                ?>
">Select Switch Target <?php 
                echo $this_switch_disabled ? '(Disabled)' : '';
                ?>
</span><?php 
                // Ensure there are robots to display
                if (!empty($this_player_robots)) {
                    // Collect the target robot options and sort them
                    $switch_robots_count = $this_player->counters['robots_active'];
                    // Loop through each robot and display its switch button
                    foreach ($this_player_robots as $robot_key => $robot_info) {
                        // Ensure this robot has an ID before attempting to load
                        if (!empty($robot_info['robot_id'])) {
                            // Create the scan object using the session/index data
                            $temp_robot = $this_battle->get_robot($robot_info['robot_id']);
                            // Check if the switch should be disabled based on attachments on this robot
                            $temp_switch_disabled = false;
                            if ($temp_robot->robot_status != 'disabled' && !empty($temp_robot->robot_attachments)) {
                                foreach ($temp_robot->robot_attachments as $attachment_token => $attachment_info) {
                                    if (!empty($attachment_info['attachment_switch_disabled'])) {
                                        $temp_switch_disabled = true;
                                    }
                                }
                            }
                            // If the switch is not disabled yet and the robot status isn't disabled, disable it
                            if ($this_switch_disabled && $this_robot->robot_status != 'disabled') {
                                $temp_switch_disabled = true;
                            }
                            // If this player has already used a switch this turn
                            if (!empty($this_player->flags['switch_used_this_turn'])) {
                                $temp_switch_disabled = true;
                            }
                            // Default the allow button flag to true
                            $allow_button = true;
                            // If this robot is already out, disable the button
                            if ($temp_robot->robot_position == 'active') {
                                $allow_button = false;
                            }
                            // If this robot is disabled, disable the button
                            if ($temp_robot->robot_status == 'disabled') {
                                $allow_button = false;
                            }
                            // If this robot is the "active" one (maybe it was a force switch?)
                            if ($switch_robots_count >= 2 && $temp_robot->robot_id == $this_robot->robot_id) {
                                $allow_button = false;
                            }
                            // If the current robot has switching disabled
                            if ($temp_switch_disabled) {
                                $allow_button = false;
                            }
                            // Define the title hover for the robot
                            $temp_robot_title = $temp_robot->robot_name . '  (Lv. ' . $temp_robot->robot_level . ')';
                            $temp_robot_title .= ' <br />' . (!empty($temp_robot->robot_core) ? ucfirst($temp_robot->robot_core) . ' Core' : 'Neutral Core') . ' | ' . ucfirst($temp_robot->robot_position) . ' Position';
                            // Display the robot's item if it exists
                            if (!empty($temp_robot->robot_item)) {
                                $temp_item = $temp_items_index[$temp_robot->robot_item];
                                $temp_robot_title .= ' | + ' . $temp_item['ability_name'] . ' ';
                            }
                            // Display the robot's life and weapon energy current and base
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_energy . ' / ' . $temp_robot->robot_base_energy . ' LE';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_weapons . ' / ' . $temp_robot->robot_base_weapons . ' WE';
                            // Display the robot's experience points if on the player side
                            $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                            if ($robot_direction == 'right' && $temp_robot->robot_class != 'mecha') {
                                $temp_robot_title .= ' | ' . $temp_robot->robot_experience . ' / ' . $temp_required_experience . ' EXP';
                            }
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_attack . ' / ' . $temp_robot->robot_base_attack . ' AT';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_defense . ' / ' . $temp_robot->robot_base_defense . ' DF';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_speed . ' / ' . $temp_robot->robot_base_speed . ' SP';
                            // Loop through this robot's current abilities and list them as well
                            $temp_robot_title .= ' <br />';
                            foreach ($temp_robot->robot_abilities as $key => $token) {
                                if (!isset($temp_abilities_index[$token])) {
                                    continue;
                                }
                                if ($key > 0 && $key % 4 != 0) {
                                    $temp_robot_title .= '&nbsp;|&nbsp;';
                                }
                                if ($key > 0 && $key % 4 == 0) {
                                    $temp_robot_title .= '<br /> ';
                                }
                                $info = $temp_abilities_index[$token];
                                $temp_robot_title .= $info['ability_name'];
                            }
                            // Encode the tooltip for markup insertion and create a plain one too
                            $temp_robot_title_plain = strip_tags(str_replace('<br />', '//', $temp_robot_title));
                            $temp_robot_title_tooltip = htmlentities($temp_robot_title, ENT_QUOTES, 'UTF-8');
                            // Collect the robot's core types for display
                            $temp_robot_core_type = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_core2_type = !empty($temp_robot->robot_core2) ? $temp_robot->robot_core2 : '';
                            if (!empty($temp_robot->robot_item) && preg_match('/^item-core-/', $temp_robot->robot_item)) {
                                $temp_item_core_type = preg_replace('/^item-core-/', '', $temp_robot->robot_item);
                                if (empty($temp_robot_core2_type) && $temp_robot_core_type != $temp_item_core_type) {
                                    $temp_robot_core2_type = $temp_item_core_type;
                                }
                            }
                            // Define the robot button text variables
                            $temp_robot_label = '<span class="multi">';
                            $temp_robot_label .= '<span class="maintext">' . $temp_robot->robot_name . '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= $temp_robot->robot_energy . '/' . $temp_robot->robot_base_energy . ' Energy';
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= 'A:' . $temp_robot->robot_attack;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'D:' . $temp_robot->robot_defense;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'S:' . $temp_robot->robot_speed;
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '</span>';
                            // Define the robot sprite variables
                            $temp_robot_sprite = array();
                            $temp_robot_sprite['name'] = $temp_robot->robot_name;
                            $temp_robot_sprite['image'] = $temp_robot->robot_image;
                            $temp_robot_sprite['image_size'] = $temp_robot->robot_image_size;
                            $temp_robot_sprite['image_size_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['image_size_zoom'] = $temp_robot->robot_image_size * 2;
                            $temp_robot_sprite['image_size_zoom_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['url'] = 'images/sprites/robots/' . $temp_robot->robot_image . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_text'] . '.png';
                            $temp_robot_sprite['preload'] = 'images/sprites/robots/' . $temp_robot->robot_image . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_zoom_text'] . '.png';
                            $temp_robot_sprite['class'] = 'sprite size' . $temp_robot_sprite['image_size'] . ' ' . ($temp_robot->robot_energy > 0 ? $temp_robot->robot_energy > $temp_robot->robot_base_energy / 2 ? 'base' : 'defend' : 'defeat') . ' ';
                            $temp_robot_sprite['style'] = 'background-image: url(' . $temp_robot_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 5px; left: 5px; ';
                            if ($temp_robot->robot_position == 'active') {
                                $temp_robot_sprite['style'] .= 'border-color: #ababab; ';
                            }
                            $temp_energy_percent = ceil($temp_robot->robot_energy / $temp_robot->robot_base_energy * 100);
                            if ($temp_energy_percent > 50) {
                                $temp_robot_sprite['class'] .= 'energy high ';
                            } elseif ($temp_energy_percent > 25) {
                                $temp_robot_sprite['class'] .= 'energy medium ';
                            } elseif ($temp_energy_percent > 0) {
                                $temp_robot_sprite['class'] .= 'energy low ';
                            }
                            $temp_robot_sprite['markup'] = '<span class="' . $temp_robot_sprite['class'] . '" style="' . $temp_robot_sprite['style'] . '">' . $temp_robot_sprite['name'] . '</span>';
                            // Update the order button if necessary
                            $order_button_markup = $allow_button ? 'data-order="' . $temp_order_counter . '"' : '';
                            $temp_order_counter += $allow_button ? 1 : 0;
                            // Now use the new object to generate a snapshot of this switch button
                            /*?><a <?= $order_button_markup?> title="<?= $temp_robot_title_plain?>" data-tooltip="<?= $temp_robot_title_tooltip?>" class="button <?= !$allow_button ? 'button_disabled' : '' ?> action_switch switch_<?= $temp_robot->robot_token ?> status_<?= $temp_robot->robot_status ?> robot_type robot_type_<?= !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none' ?> block_<?= $robot_key + 1 ?>" type="button" <?if($allow_button):?>data-action="switch_<?= $temp_robot->robot_id.'_'.$temp_robot->robot_token ?>"<?endif;?> data-preload="<?= $temp_robot_sprite['preload'] ?>"><label><?= $temp_robot_sprite['markup'] ?><?= $temp_robot_label ?></label></a><?*/
                            ?>
<a <?php 
                            echo $order_button_markup;
                            ?>
 data-key="<?php 
                            echo $temp_robot->robot_key;
                            ?>
" data-tooltip="<?php 
                            echo $temp_robot_title_tooltip;
                            ?>
" class="button <?php 
                            echo !$allow_button ? 'button_disabled' : '';
                            ?>
 action_switch switch_<?php 
                            echo $temp_robot->robot_token;
                            ?>
 status_<?php 
                            echo $temp_robot->robot_status;
                            ?>
 robot_type robot_type_<?php 
                            echo $temp_robot_core_type . (!empty($temp_robot_core2_type) ? '_' . $temp_robot_core2_type : '');
                            ?>
 block_<?php 
                            echo $robot_key + 1;
                            ?>
" type="button" <?if($allow_button):?>data-action="switch_<?php 
                            echo $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                            ?>
"<?endif;?> data-preload="<?php 
                            echo $temp_robot_sprite['preload'];
                            ?>
"><label><?php 
                            echo $temp_robot_sprite['markup'];
                            echo $temp_robot_label;
                            ?>
</label></a><?php 
                        }
                    }
                    // If there were less than 8 robots, fill in the empty spaces
                    if ($num_robots < 8) {
                        for ($i = $num_robots; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_switch button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                $allow_back_button = $this_robot->robot_position == 'active' && $this_robot->robot_status != 'disabled' ? true : false;
                ?>
<div class="sub_actions"><a <?php 
                echo $allow_back_button ? 'data-order="' . $temp_order_counter . '"' : '';
                ?>
 class="button action_back <?php 
                echo !$allow_back_button ? 'button_disabled' : '';
                ?>
" type="button" <?php 
                echo $allow_back_button ? 'data-panel="battle"' : '';
                ?>
><?php 
                echo $allow_back_button ? '<label>Back</label>' : '&nbsp;';
                ?>
</a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a TARGET (THIS) menu request
            // If this was a TARGET (THIS) menu request
            case 'target_this':
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select {thisPanel} Target</span><?php 
                // Ensure there are robots to display
                if (!empty($this_player_robots)) {
                    // Loop through each robot and display its target button
                    foreach ($this_player_robots as $robot_key => $robot_info) {
                        // Ensure this robot has a lookup ID
                        if (!empty($robot_info['robot_id'])) {
                            // Create the scan object using the session/index data
                            $temp_robot = $this_battle->get_robot($robot_info['robot_id']);
                            // Default the allow button flag to true
                            $allow_button = true;
                            // If this robot is disabled, disable the button
                            if ($temp_robot->robot_status == 'disabled') {
                                $allow_button = false;
                            }
                            // If this robot is not active, disable the button
                            //if ($temp_robot->robot_position != 'active'){ $allow_button = false; }
                            // Define the title hover for the robot
                            $temp_robot_title = $temp_robot->robot_name . '  (Lv. ' . $temp_robot->robot_level . ')';
                            //$temp_robot_title .= ' | '.$temp_robot->robot_id.'';
                            $temp_robot_title .= ' <br />' . (!empty($temp_robot->robot_core) ? ucfirst($temp_robot->robot_core) . ' Core' : 'Neutral Core') . ' | ' . ucfirst($temp_robot->robot_position) . ' Position';
                            // Display the robot's item if it exists
                            if (!empty($temp_robot->robot_item)) {
                                $temp_item = $temp_items_index[$temp_robot->robot_item];
                                $temp_robot_title .= ' | + ' . $temp_item['ability_name'] . ' ';
                            }
                            // Display the robot's life and weapon energy current and base
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_energy . ' / ' . $temp_robot->robot_base_energy . ' LE';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_weapons . ' / ' . $temp_robot->robot_base_weapons . ' WE';
                            $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                            if ($robot_direction == 'right' && $temp_robot->robot_class != 'mecha') {
                                $temp_robot_title .= ' | ' . $temp_robot->robot_experience . ' / ' . $temp_required_experience . ' EXP';
                            }
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_attack . ' / ' . $temp_robot->robot_base_attack . ' AT';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_defense . ' / ' . $temp_robot->robot_base_defense . ' DF';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_speed . ' / ' . $temp_robot->robot_base_speed . ' SP';
                            // Loop through this robot's current abilities and list them as well
                            $temp_robot_title .= ' <br />';
                            foreach ($temp_robot->robot_abilities as $key => $token) {
                                if (!isset($temp_abilities_index[$token])) {
                                    continue;
                                }
                                if ($key > 0 && $key % 4 != 0) {
                                    $temp_robot_title .= '&nbsp;|&nbsp;';
                                }
                                if ($key > 0 && $key % 4 == 0) {
                                    $temp_robot_title .= '<br /> ';
                                }
                                $info = $temp_abilities_index[$token];
                                $temp_robot_title .= $info['ability_name'];
                            }
                            // Encode the tooltip for markup insertion and create a plain one too
                            $temp_robot_title_plain = strip_tags(str_replace('<br />', '//', $temp_robot_title));
                            $temp_robot_title_tooltip = htmlentities($temp_robot_title, ENT_QUOTES, 'UTF-8');
                            // Collect the robot's core types for display
                            $temp_robot_core_type = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_core2_type = !empty($temp_robot->robot_core2) ? $temp_robot->robot_core2 : '';
                            if (!empty($temp_robot->robot_item) && preg_match('/^item-core-/', $temp_robot->robot_item)) {
                                $temp_item_core_type = preg_replace('/^item-core-/', '', $temp_robot->robot_item);
                                if (empty($temp_robot_core2_type) && $temp_robot_core_type != $temp_item_core_type) {
                                    $temp_robot_core2_type = $temp_item_core_type;
                                }
                            }
                            // Define the robot button text variables
                            $temp_robot_label = '<span class="multi">';
                            $temp_robot_label .= '<span class="maintext">' . $temp_robot->robot_name . '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= $temp_robot->robot_energy . '/' . $temp_robot->robot_base_energy . ' Energy';
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= 'A:' . $temp_robot->robot_attack;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'D:' . $temp_robot->robot_defense;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'S:' . $temp_robot->robot_speed;
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '</span>';
                            // Define the robot sprite variables
                            $temp_robot_sprite = array();
                            $temp_robot_sprite['name'] = $temp_robot->robot_name;
                            $temp_robot_sprite['core'] = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_sprite['image'] = $temp_robot->robot_image;
                            $temp_robot_sprite['image_size'] = $temp_robot->robot_image_size;
                            $temp_robot_sprite['image_size_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['image_size_zoom'] = $temp_robot->robot_image_size * 2;
                            $temp_robot_sprite['image_size_zoom_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['url'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_text'] . '.png';
                            $temp_robot_sprite['class'] = 'sprite size' . $temp_robot_sprite['image_size'] . ' ' . ($temp_robot->robot_energy > 0 ? $temp_robot->robot_energy > $temp_robot->robot_base_energy / 2 ? 'base' : 'defend' : 'defeat') . ' ';
                            $temp_robot_sprite['style'] = 'background-image: url(' . $temp_robot_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 6px; left: 5px; ';
                            if ($temp_robot->robot_position == 'active') {
                                $temp_robot_sprite['style'] .= 'border-color: #ababab; ';
                            }
                            $temp_energy_percent = ceil($temp_robot->robot_energy / $temp_robot->robot_base_energy * 100);
                            if ($temp_energy_percent > 50) {
                                $temp_robot_sprite['class'] .= 'energy high ';
                            } elseif ($temp_energy_percent > 25) {
                                $temp_robot_sprite['class'] .= 'energy medium ';
                            } elseif ($temp_energy_percent > 0) {
                                $temp_robot_sprite['class'] .= 'energy low ';
                            }
                            $temp_robot_sprite['markup'] = '<span class="' . $temp_robot_sprite['class'] . '" style="' . $temp_robot_sprite['style'] . '">' . $temp_robot_sprite['name'] . '</span>';
                            // Update the order button if necessary
                            $order_button_markup = $allow_button ? 'data-order="' . $temp_order_counter . '"' : '';
                            $temp_order_counter += $allow_button ? 1 : 0;
                            // Now use the new object to generate a snapshot of this target button
                            ?>
<a <?php 
                            echo $order_button_markup;
                            ?>
 data-tooltip="<?php 
                            echo $temp_robot_title_tooltip;
                            ?>
" class="button <?php 
                            echo !$allow_button ? 'button_disabled' : '';
                            ?>
 action_target target_<?php 
                            echo $temp_robot->robot_token;
                            ?>
 status_<?php 
                            echo $temp_robot->robot_status;
                            ?>
 robot_type robot_type_<?php 
                            echo $temp_robot_core_type . (!empty($temp_robot_core2_type) ? '_' . $temp_robot_core2_type : '');
                            ?>
 block_<?php 
                            echo $robot_key + 1;
                            ?>
" type="button" <?if($allow_button):?>data-action="target_<?php 
                            echo $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                            ?>
"<?endif;?>><label><?php 
                            echo $temp_robot_sprite['markup'];
                            echo $temp_robot_label;
                            ?>
</label></a><?php 
                        }
                    }
                    // If there were less than 8 robots, fill in the empty spaces
                    if ($num_robots < 8) {
                        for ($i = $num_robots; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_target button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="ability"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a TARGET (TARGET) menu request
            // If this was a TARGET (TARGET) menu request
            case 'target_target':
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select {thisPanel} Target</span><?php 
                // Ensure there are robots to display
                if (!empty($target_player_robots)) {
                    // Loop through each robot and display its target button
                    foreach ($target_player_robots as $robot_key => $robot_info) {
                        // Ensure this robot has a lookup ID
                        if (!empty($robot_info['robot_id'])) {
                            // Create the scan object using the session/index data
                            $temp_robot = $this_battle->get_robot($robot_info['robot_id']);
                            // Default the allow button flag to true
                            $allow_button = true;
                            // If this robot is disabled, disable the button
                            if ($temp_robot->robot_status == 'disabled') {
                                $allow_button = false;
                            }
                            // If this robot is not active, disable the button
                            //if ($temp_robot->robot_position != 'active'){ $allow_button = false; }
                            // Define the title hover for the robot
                            $temp_robot_title = $temp_robot->robot_name . '  (Lv. ' . $temp_robot->robot_level . ')';
                            //$temp_robot_title .= ' | '.$temp_robot->robot_id.'';
                            $temp_robot_title .= ' <br />' . (!empty($temp_robot->robot_core) ? ucfirst($temp_robot->robot_core) . ' Core' : 'Neutral Core') . ' | ' . ucfirst($temp_robot->robot_position) . ' Position';
                            // Display the robot's item if it exists
                            if (!empty($temp_robot->robot_item)) {
                                $temp_item = $temp_items_index[$temp_robot->robot_item];
                                $temp_robot_title .= ' | + ' . $temp_item['ability_name'] . ' ';
                            }
                            // Display the robot's life and weapon energy current and base
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_energy . ' / ' . $temp_robot->robot_base_energy . ' LE';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_weapons . ' / ' . $temp_robot->robot_base_weapons . ' WE';
                            $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                            if ($robot_direction == 'right' && $temp_robot->robot_class != 'mecha') {
                                $temp_robot_title .= ' | ' . $temp_robot->robot_experience . ' / ' . $temp_required_experience . ' EXP';
                            }
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_attack . ' / ' . $temp_robot->robot_base_attack . ' AT';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_defense . ' / ' . $temp_robot->robot_base_defense . ' DF';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_speed . ' / ' . $temp_robot->robot_base_speed . ' SP';
                            $temp_robot_title_plain = strip_tags(str_replace('<br />', '&#10;', $temp_robot_title));
                            $temp_robot_title_tooltip = htmlentities($temp_robot_title, ENT_QUOTES, 'UTF-8');
                            // Collect the robot's core types for display
                            $temp_robot_core_type = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_core2_type = !empty($temp_robot->robot_core2) ? $temp_robot->robot_core2 : '';
                            if (!empty($temp_robot->robot_item) && preg_match('/^item-core-/', $temp_robot->robot_item)) {
                                $temp_item_core_type = preg_replace('/^item-core-/', '', $temp_robot->robot_item);
                                if (empty($temp_robot_core2_type) && $temp_robot_core_type != $temp_item_core_type) {
                                    $temp_robot_core2_type = $temp_item_core_type;
                                }
                            }
                            // Define the robot button text variables
                            $temp_robot_label = '<span class="multi">';
                            $temp_robot_label .= '<span class="maintext">' . $temp_robot->robot_name . '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= $temp_robot->robot_energy . '/' . $temp_robot->robot_base_energy . ' Energy';
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= 'A:' . $temp_robot->robot_attack;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'D:' . $temp_robot->robot_defense;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'S:' . $temp_robot->robot_speed;
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '</span>';
                            // Define the robot sprite variables
                            $temp_robot_sprite = array();
                            $temp_robot_sprite['name'] = $temp_robot->robot_name;
                            $temp_robot_sprite['core'] = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_sprite['image'] = $temp_robot->robot_image;
                            $temp_robot_sprite['image_size'] = $temp_robot->robot_image_size;
                            $temp_robot_sprite['image_size_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['image_size_zoom'] = $temp_robot->robot_image_size * 2;
                            $temp_robot_sprite['image_size_zoom_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['url'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_text'] . '.png';
                            $temp_robot_sprite['preload'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_zoom_text'] . '.png';
                            $temp_robot_sprite['class'] = 'sprite size' . $temp_robot_sprite['image_size'] . ' ' . ($temp_robot->robot_energy > 0 ? $temp_robot->robot_energy > $temp_robot->robot_base_energy / 2 ? 'base' : 'defend' : 'defeat') . ' ';
                            $temp_robot_sprite['style'] = 'background-image: url(' . $temp_robot_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 6px; left: 5px; ';
                            if ($temp_robot->robot_position == 'active') {
                                $temp_robot_sprite['style'] .= 'border-color: #ababab; ';
                            }
                            $temp_energy_percent = ceil($temp_robot->robot_energy / $temp_robot->robot_base_energy * 100);
                            if ($temp_energy_percent > 50) {
                                $temp_robot_sprite['class'] .= 'energy high ';
                            } elseif ($temp_energy_percent > 25) {
                                $temp_robot_sprite['class'] .= 'energy medium ';
                            } elseif ($temp_energy_percent > 0) {
                                $temp_robot_sprite['class'] .= 'energy low ';
                            }
                            $temp_robot_sprite['markup'] = '<span class="' . $temp_robot_sprite['class'] . '" style="' . $temp_robot_sprite['style'] . '">' . $temp_robot_sprite['name'] . '</span>';
                            // Update the order button if necessary
                            $order_button_markup = $allow_button ? 'data-order="' . $temp_order_counter . '"' : '';
                            $temp_order_counter += $allow_button ? 1 : 0;
                            // Now use the new object to generate a snapshot of this target button
                            /*?><a <?= $order_button_markup?> title="<?= $temp_robot_title_plain?>" data-tooltip="<?= $temp_robot_title_tooltip?>" class="button <?= !$allow_button ? 'button_disabled' : '' ?> action_target target_<?= $temp_robot->robot_token ?> status_<?= $temp_robot->robot_status ?> robot_type robot_type_<?= !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none' ?> block_<?= $robot_key + 1 ?>" type="button" <?if($allow_button):?>data-action="target_<?= $temp_robot->robot_id.'_'.$temp_robot->robot_token ?>"<?endif;?> data-preload="<?= $temp_robot_sprite['preload'] ?>"><label><?= $temp_robot_sprite['markup'] ?><?= $temp_robot_label ?></label></a><?*/
                            ?>
<a <?php 
                            echo $order_button_markup;
                            ?>
 data-tooltip="<?php 
                            echo $temp_robot_title_tooltip;
                            ?>
" class="button <?php 
                            echo !$allow_button ? 'button_disabled' : '';
                            ?>
 action_target target_<?php 
                            echo $temp_robot->robot_token;
                            ?>
 status_<?php 
                            echo $temp_robot->robot_status;
                            ?>
 robot_type robot_type_<?php 
                            echo $temp_robot_core_type . (!empty($temp_robot_core2_type) ? '_' . $temp_robot_core2_type : '');
                            ?>
 block_<?php 
                            echo $robot_key + 1;
                            ?>
" type="button" <?if($allow_button):?>data-action="target_<?php 
                            echo $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                            ?>
"<?endif;?> data-preload="<?php 
                            echo $temp_robot_sprite['preload'];
                            ?>
"><label><?php 
                            echo $temp_robot_sprite['markup'];
                            echo $temp_robot_label;
                            ?>
</label></a><?php 
                        }
                    }
                    // If there were less than 8 robots, fill in the empty spaces
                    if ($num_robots < 8) {
                        for ($i = $num_robots; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_target button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="ability"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a TARGET (THIS, DISABLED) menu request
            // If this was a TARGET (THIS, DISABLED) menu request
            case 'target_this_disabled':
                // Define and start the order counter
                $temp_order_counter = 1;
                // Display container for the main actions
                ?>
<div class="main_actions main_actions_hastitle"><span class="main_actions_title">Select {thisPanel} Target</span><?php 
                // Ensure there are robots to display
                if (!empty($this_player_robots)) {
                    // Loop through each robot and display its target button
                    foreach ($this_player_robots as $robot_key => $scan_robotinfo) {
                        // Ensure this is an actual switch in the index
                        if (!empty($switch_robotinfo['robot_token'])) {
                            // Create the scan object using the session/index data
                            $temp_robot = new rpg_robot($this_player, $scan_robotinfo);
                            // Default the allow button flag to true
                            $allow_button = false;
                            // If this robot is disabled, disable the button
                            if ($temp_robot->robot_status == 'disabled') {
                                $allow_button = true;
                            }
                            // If this robot is not active, disable the button
                            //if ($temp_robot->robot_position != 'active'){ $allow_button = false; }
                            // Define the title hover for the robot
                            $temp_robot_title = $temp_robot->robot_name . '  (Lv. ' . $temp_robot->robot_level . ')';
                            //$temp_robot_title .= ' | '.$temp_robot->robot_id.'';
                            $temp_robot_title .= ' <br />' . (!empty($temp_robot->robot_core) ? ucfirst($temp_robot->robot_core) . ' Core' : 'Neutral Core') . ' | ' . ucfirst($temp_robot->robot_position) . ' Position';
                            // Display the robot's item if it exists
                            if (!empty($temp_robot->robot_item)) {
                                $temp_item = $temp_items_index[$temp_robot->robot_item];
                                $temp_robot_title .= ' | + ' . $temp_item['ability_name'] . ' ';
                            }
                            // Display the robot's life and weapon energy current and base
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_energy . ' / ' . $temp_robot->robot_base_energy . ' LE';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_weapons . ' / ' . $temp_robot->robot_base_weapons . ' WE';
                            $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                            if ($robot_direction == 'right' && $temp_robot->robot_class != 'mecha') {
                                $temp_robot_title .= ' | ' . $temp_robot->robot_experience . ' / ' . $temp_required_experience . ' EXP';
                            }
                            $temp_robot_title .= ' <br />' . $temp_robot->robot_attack . ' / ' . $temp_robot->robot_base_attack . ' AT';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_defense . ' / ' . $temp_robot->robot_base_defense . ' DF';
                            $temp_robot_title .= ' | ' . $temp_robot->robot_speed . ' / ' . $temp_robot->robot_base_speed . ' SP';
                            // Loop through this robot's current abilities and list them as well
                            $temp_robot_title .= ' <br />';
                            foreach ($temp_robot->robot_abilities as $key => $token) {
                                if (!isset($temp_abilities_index[$token])) {
                                    continue;
                                }
                                if ($key > 0 && $key % 4 != 0) {
                                    $temp_robot_title .= '&nbsp;|&nbsp;';
                                }
                                if ($key > 0 && $key % 4 == 0) {
                                    $temp_robot_title .= '<br /> ';
                                }
                                $info = $temp_abilities_index[$token];
                                $temp_robot_title .= $info['ability_name'];
                            }
                            // Encode the tooltip for markup insertion and create a plain one too
                            $temp_robot_title_plain = strip_tags(str_replace('<br />', '//', $temp_robot_title));
                            $temp_robot_title_tooltip = htmlentities($temp_robot_title, ENT_QUOTES, 'UTF-8');
                            // Collect the robot's core types for display
                            $temp_robot_core_type = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_core2_type = !empty($temp_robot->robot_core2) ? $temp_robot->robot_core2 : '';
                            if (!empty($temp_robot->robot_item) && preg_match('/^item-core-/', $temp_robot->robot_item)) {
                                $temp_item_core_type = preg_replace('/^item-core-/', '', $temp_robot->robot_item);
                                if (empty($temp_robot_core2_type) && $temp_robot_core_type != $temp_item_core_type) {
                                    $temp_robot_core2_type = $temp_item_core_type;
                                }
                            }
                            // Define the robot button text variables
                            $temp_robot_label = '<span class="multi">';
                            $temp_robot_label .= '<span class="maintext">' . $temp_robot->robot_name . '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= $temp_robot->robot_energy . '/' . $temp_robot->robot_base_energy . ' Energy';
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '<span class="subtext">';
                            $temp_robot_label .= 'A:' . $temp_robot->robot_attack;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'D:' . $temp_robot->robot_defense;
                            $temp_robot_label .= '&nbsp;';
                            $temp_robot_label .= 'S:' . $temp_robot->robot_speed;
                            $temp_robot_label .= '</span>';
                            $temp_robot_label .= '</span>';
                            // Define the robot sprite variables
                            $temp_robot_sprite = array();
                            $temp_robot_sprite['name'] = $temp_robot->robot_name;
                            $temp_robot_sprite['core'] = !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none';
                            $temp_robot_sprite['image'] = $temp_robot->robot_image;
                            $temp_robot_sprite['image_size'] = $temp_robot->robot_image_size;
                            $temp_robot_sprite['image_size_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['image_size_zoom'] = $temp_robot->robot_image_size * 2;
                            $temp_robot_sprite['image_size_zoom_text'] = $temp_robot_sprite['image_size'] . 'x' . $temp_robot_sprite['image_size'];
                            $temp_robot_sprite['url'] = 'images/sprites/robots/' . $temp_robot_sprite['image'] . '/sprite_' . $robot_direction . '_' . $temp_robot_sprite['image_size_text'] . '.png';
                            $temp_robot_sprite['class'] = 'sprite size' . $temp_robot_sprite['image_size'] . ' ' . ($temp_robot->robot_energy > 0 ? $temp_robot->robot_energy > $temp_robot->robot_base_energy / 2 ? 'base' : 'defend' : 'defeat') . ' ';
                            $temp_robot_sprite['style'] = 'background-image: url(' . $temp_robot_sprite['url'] . '?' . MMRPG_CONFIG_CACHE_DATE . ');  top: 6px; left: 5px; ';
                            if ($temp_robot->robot_position == 'active') {
                                $temp_robot_sprite['style'] .= 'border-color: #ababab; ';
                            }
                            $temp_energy_percent = ceil($temp_robot->robot_energy / $temp_robot->robot_base_energy * 100);
                            if ($temp_energy_percent > 50) {
                                $temp_robot_sprite['class'] .= 'energy high ';
                            } elseif ($temp_energy_percent > 25) {
                                $temp_robot_sprite['class'] .= 'energy medium ';
                            } elseif ($temp_energy_percent > 0) {
                                $temp_robot_sprite['class'] .= 'energy low ';
                            }
                            $temp_robot_sprite['markup'] = '<span class="' . $temp_robot_sprite['class'] . '" style="' . $temp_robot_sprite['style'] . '">' . $temp_robot_sprite['name'] . '</span>';
                            // Update the order button if necessary
                            $order_button_markup = $allow_button ? 'data-order="' . $temp_order_counter . '"' : '';
                            $temp_order_counter += $allow_button ? 1 : 0;
                            // Now use the new object to generate a snapshot of this target button
                            /*?><a <?= $order_button_markup?> title="<?= $temp_robot_title_plain?>" data-tooltip="<?= $temp_robot_title_tooltip?>" class="button <?= !$allow_button ? 'button_disabled' : '' ?> action_target target_<?= $temp_robot->robot_token ?> status_<?= $temp_robot->robot_status ?> robot_type robot_type_<?= !empty($temp_robot->robot_core) ? $temp_robot->robot_core : 'none' ?> block_<?= $robot_key + 1 ?>" type="button" <?if($allow_button):?>data-action="target_<?= $temp_robot->robot_id.'_'.$temp_robot->robot_token ?>"<?endif;?>><label><?= $temp_robot_sprite['markup'] ?><?= $temp_robot_label ?></label></a><?*/
                            ?>
<a <?php 
                            echo $order_button_markup;
                            ?>
 data-tooltip="<?php 
                            echo $temp_robot_title_tooltip;
                            ?>
" class="button <?php 
                            echo !$allow_button ? 'button_disabled' : '';
                            ?>
 action_target target_<?php 
                            echo $temp_robot->robot_token;
                            ?>
 status_<?php 
                            echo $temp_robot->robot_status;
                            ?>
 robot_type robot_type_<?php 
                            echo $temp_robot_core_type . (!empty($temp_robot_core2_type) ? '_' . $temp_robot_core2_type : '');
                            ?>
 block_<?php 
                            echo $robot_key + 1;
                            ?>
" type="button" <?if($allow_button):?>data-action="target_<?php 
                            echo $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                            ?>
"<?endif;?>><label><?php 
                            echo $temp_robot_sprite['markup'];
                            echo $temp_robot_label;
                            ?>
</label></a><?php 
                        }
                    }
                    // If there were less than 8 robots, fill in the empty spaces
                    if ($num_robots < 8) {
                        for ($i = $num_robots; $i < 8; $i++) {
                            // Display an empty button placeholder
                            ?>
<a class="button action_target button_disabled block_<?php 
                            echo $i + 1;
                            ?>
" type="button">&nbsp;</a><?php 
                        }
                    }
                }
                // End the main action container tag
                ?>
</div><?php 
                // Display the back button by default
                ?>
<div class="sub_actions"><a data-order="<?php 
                echo $temp_order_counter;
                ?>
" class="button action_back" type="button" data-panel="ability"><label>Back</label></a></div><?php 
                // Increment the order counter
                $temp_order_counter++;
                break;
                // If this was a COMPLETE menu request
            // If this was a COMPLETE menu request
            case 'complete':
                // If the current robot is not disabled (WE WIN!)
                if ($this_player->counters['robots_active'] > 0) {
                    // Display available main actions
                    ?>
<div class="main_actions"><?php 
                    ?>
<a class="button action_ability" data-action="prototype" type="button" data-order="1"><label>Mission Complete!</label></a><?php 
                    ?>
</div><?php 
                    // Display the available sub options
                    ?>
<div class="sub_actions"><?php 
                    ?>
<a class="button action_scan button_disabled" type="button">&nbsp;</a><?php 
                    ?>
<a class="button action_item button_disabled" type="button">&nbsp;</a><?php 
                    ?>
<a class="button action_option button_disabled" type="button">&nbsp;</a><?php 
                    ?>
<a class="button action_switch button_disabled" type="button">&nbsp;</a><?php 
                    ?>
</div><?php 
                } else {
                    // Display available main actions
                    ?>
<div class="main_actions"><?php 
                    ?>
<a class="button action_ability button_disabled" type="button"><label>Mission Failure&hellip;</label></a><?php 
                    ?>
</div><?php 
                    // Display the available sub options
                    ?>
<div class="sub_actions"><?php 
                    ?>
<a class="button action_scan button_disabled" type="button">&nbsp;</a><?php 
                    ?>
<a class="button action_item" data-action="prototype" type="button" data-order="1"><label>Exit Mission</label></a><?php 
                    ?>
<a class="button action_option" data-action="restart" type="button" data-order="2"><label>Restart Mission</label></a><?php 
                    ?>
<a class="button action_switch button_disabled" type="button">&nbsp;</a><?php 
                    ?>
</div><?php 
                }
                break;
        }
        // Collect generated markup, compress, and return
        $menu_markup = trim(ob_get_clean());
        $menu_markup = preg_replace('#\\s+#', ' ', $menu_markup);
        return $menu_markup;
    }