예제 #1
0
 public static function formatting_decode($string)
 {
     // Define the static formatting array variable
     static $mmrpg_formatting_array = array();
     static $mmrpg_types_array_string = '';
     // If the formatting array has not been populated, do so
     if (empty($mmrpg_formatting_array)) {
         // Pull in global variables
         global $db;
         $mmrpg_types = rpg_type::get_index();
         // Collect the types array from the index
         $mmrpg_types_array = array_keys($mmrpg_types);
         $mmrpg_types_array_string = implode('|', $mmrpg_types_array);
         $mmrpg_types_array_string .= '|neutral';
         //die($mmrpg_types_array_string);
         // Collect the robot and ability index from the database
         $temp_robots_index = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token');
         $temp_abilities_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
         // Define the array to hold the images of larger size than default
         $mmrpg_large_robot_images = array();
         $mmrpg_large_ability_images = array();
         // Loop through robots and abilities and collect tokens of large ones
         if (!empty($temp_robots_index)) {
             foreach ($temp_robots_index as $token => $info) {
                 if ($info['robot_image_size'] == 80) {
                     $mmrpg_large_robot_images[] = $info['robot_token'];
                 }
             }
         }
         if (!empty($temp_abilities_index)) {
             foreach ($temp_abilities_index as $token => $info) {
                 if ($info['ability_image_size'] == 80) {
                     $mmrpg_large_ability_images[] = $info['ability_token'];
                 }
             }
         }
         // Create strings for the large robot and ability patterns by imploding the arrays
         $mmrpg_large_robot_images_string = implode('|', $mmrpg_large_robot_images);
         $mmrpg_large_ability_images_string = implode('|', $mmrpg_large_ability_images);
         // Pull in the global index formatting variables
         $mmrpg_formatting_array = array();
         $mmrpg_formatting_array += array('/\\[code\\]\\s?(.*?)\\s?\\[\\/code\\]/is' => '$1');
         $mmrpg_formatting_array += array('/\\[tab\\]/i' => '&nbsp;&nbsp;', '/\\s{2,}[-]{5,}\\s{2,}/i' => '<hr class="line_divider line_divider_bigger" />', '/\\s?[-]{5,}\\s?/i' => '<hr class="line_divider" />', '/\\s\\|\\s/i' => '&nbsp;<span class="pipe">|</span>&nbsp;');
         $mmrpg_formatting_array += array('/\\[image\\]\\((.*?).(jpg|jpeg|gif|png|bmp)\\)/i' => '<span class="link_image_inline"><img src="$1.$2" /></span>');
         $mmrpg_formatting_array += array('/\\[player\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/players/$1/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[player:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/players/$2/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[player:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/players/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[player:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/players/$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[player:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/players/$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[player:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/players/$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[player:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/players/$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[player:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/players/$3/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[player:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/players/$3/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[robot\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span data-test="1" class="sprite_image sprite_image_80x80"><img src="images/sprites/robots/$1_$2/mug_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[robot:(left|right)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span data-test="2" class="sprite_image sprite_image_80x80"><img src="images/sprites/robots/$2_$3/mug_$1_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[robot:(left|right):([a-z0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span data-test="3" class="sprite_image sprite_image_80x80 sprite_image_80x80_$2"><span><img src="images/sprites/robots/$3_$4/sprite_$1_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5_$6/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5_$6/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4_$5/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4_$5/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3_$4/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3_$4/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$1_$2/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[robot:(left|right)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$2_$3/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[robot:(left|right):([a-z0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/robots/$3_$4/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5_$6/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5_$6/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4_$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4_$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3_$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+)\\]\\{([-a-z0-9]+)_([-_a-z0-9]+)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3_$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80"><img src="images/sprites/robots/$1/mug_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[robot:(left|right)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80"><img src="images/sprites/robots/$2/mug_$1_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[robot:(left|right):([a-z0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$2"><span><img src="images/sprites/robots/$3/sprite_$1_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3/sprite_left_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(' . $mmrpg_large_robot_images_string . ')\\}/i' => '<span class="sprite_image sprite_image_80x80 sprite_image_80x80_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3/sprite_right_80x80.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$1/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[robot:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$2/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[robot:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/robots/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:(left|right):([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2" style="left: $3px; bottom: $4px; z-index: $5; transform: rotate($6deg);"><span><img src="images/sprites/robots/$7/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$7" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[robot:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[robot:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[mecha\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$1/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[mecha:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$2/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[mecha:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/robots/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[mecha:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[mecha:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[mecha:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[mecha:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[mecha:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[mecha:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[boss\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$1/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[boss:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/robots/$2/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[boss:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/robots/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[boss:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[boss:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/robots/$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[boss:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[boss:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/robots/$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[boss:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/robots/$3/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[boss:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/robots/$3/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[ability\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/abilities/$1/mug_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[ability:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/abilities/$2/mug_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[ability:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/abilities/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[ability:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/abilities/$5/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[ability:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px; z-index: $4;"><span><img src="images/sprites/abilities/$5/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$5" /></span></span>', '/\\[ability:left:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px; bottom: $3px;"><span><img src="images/sprites/abilities/$4/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[ability:right:([a-z0-9]+):(-?[0-9]+),(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px; bottom: $3px;"><span><img src="images/sprites/abilities/$4/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$4" /></span></span>', '/\\[ability:left:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="right: $2px;"><span><img src="images/sprites/abilities/$3/sprite_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>', '/\\[ability:right:([a-z0-9]+):(-?[0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$1" style="left: $2px;"><span><img src="images/sprites/abilities/$3/sprite_right_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[item\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/abilities/item-$1/icon_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[item:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/abilities/item-$2/icon_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[item:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/abilities/item-$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[shop\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/shops/$1/icon_left_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$1" /></span>', '/\\[shop:(left|right)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40"><img src="images/sprites/shops/$2/icon_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$2" /></span>', '/\\[shop:(left|right):([a-z0-9]+)\\]\\{(.*?)\\}/i' => '<span class="sprite_image sprite_image_40x40 sprite_image_40x40_$2"><span><img src="images/sprites/shops/$3/sprite_$1_40x40.png?' . MMRPG_CONFIG_CACHE_DATE . '" alt="$3" /></span></span>');
         $mmrpg_formatting_array += array('/\\[sprite\\]/i' => '<span class="sprite_image sprite_image_40x40"></span>');
         $mmrpg_formatting_array += array('/\\[([^\\[\\]]+)\\]\\((.*?).(jpg|jpeg|gif|png|bmp)\\:text\\)/i' => '<a class="link_inline" href="$2.$3" target="_blank">$1</a>', '/\\[([^\\[\\]]+)\\]\\((.*?).(jpg|jpeg|gif|png|bmp)\\:image\\)/i' => '<a class="link_image_inline" href="$2.$3" target="_blank"><img src="$2.$3" alt="$1" title="$1" /></a>');
     }
     //die('<pre>$mmrpg_formatting_array = '.print_r($mmrpg_formatting_array, true).'</pre>');
     // -- REPLACE CODE BLOCKS -- //
     // Define the newline string
     $nl = "\n";
     // Strip any illegal HTML from the string
     $string = strip_tags($string);
     $string = preg_replace('/\\[\\/code\\]\\[\\/code\\]/i', '[&#47;code][/code]', $string);
     //$string = preg_replace('/\s+/', ' ', $string);
     // Loop through each find, and replace with the appropriate replacement
     $code_matches = array();
     $has_code = preg_match_all('/\\[code\\]\\s?(.*?)\\s?\\[\\/code\\]/is', $string, $code_matches);
     //if ($has_code){ echo('<pre style="background-color: white; clear: both; width: 100%; white-space: normal; color: #000000; margin: 0 auto 20px;">$code_matches = '.print_r($code_matches[0], true).'</pre>'); }
     if ($has_code) {
         foreach ($code_matches[0] as $key => $match) {
             $string = str_replace($match, '##CODE' . $key . '##', $string);
         }
     }
     //if ($has_code){ echo('<pre style="background-color: white; clear: both; width: 100%; white-space: normal; color: #000000; margin: 0 auto 20px;">$string = '.print_r($string, true).'</pre>'); }
     // -- REPLACE STANDARD FORMATTING -- //
     // Replace all the other, inline formatting with its markup
     foreach ($mmrpg_formatting_array as $find_pattern => $replace_pattern) {
         $string = preg_replace($find_pattern, $replace_pattern, $string);
     }
     // Start off the count variable for later
     $count = 0;
     // Replace special types of line breaks with one single type
     //$string = str_replace("\r\n", "\n", $string);
     $string = str_replace("\r\n", "\n", $string);
     // -- REPLACE IMAGES -- //
     // Recusively replace all the size spans with their span markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\((.*?).(jpg|jpeg|gif|png|bmp)\\)/i', '<a class="link_image_inline" href="$2.$3" target="_blank"><img src="$2.$3" alt="$1" title="$1" /></a>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE LINKS -- //
     // Recusively replace all the standard text links with their markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\((.*?)\\)/i', '<a class="link_inline" href="$2" target="_blank">$1</a>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE BBCODE BLOCKS/SPANS -- //
     // Recusively replace all the BOLD blocks with their div markup
     do {
         $string = preg_replace('/\\[b\\](.*?)\\[\\/b\\]/is', '<strong class="bold">$1</strong>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the ITALIC blocks with their div markup
     do {
         $string = preg_replace('/\\[i\\](.*?)\\[\\/i\\]/is', '<em class="italic">$1</em>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the UNDERLINE blocks with their div markup
     do {
         $string = preg_replace('/\\[u\\](.*?)\\[\\/u\\]/is', '<span class="underline">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the STRIKE blocks with their div markup
     do {
         $string = preg_replace('/\\[s\\](.*?)\\[\\/s\\]/is', '<span class="strike">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE TYPE/COLOR/SIZE SPANS -- //
     // Recusively replace all the dual type spans with their span markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\{(' . $mmrpg_types_array_string . ')_(' . $mmrpg_types_array_string . ')\\}/i', '<span class="type type_span type_$2_$3">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the single type spans with their span markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\{(' . $mmrpg_types_array_string . ')\\}/i', '<span class="type type_span type_$2">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the size spans with their span markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\{(small|medium|large)\\}/i', '<span class="size_$2">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // Recusively replace all the colour(hex) spans with their span markup
     do {
         $string = preg_replace('/\\[([^\\[\\]]+)\\]\\{(#[a-f0-9]{6}|[a-z]+|rgb\\([0-9]+,[0-9]+,[0-9]+\\)|rgba\\([0-9]+,[0-9]+,[0-9]+,[.0-9]+\\)|[a-z]+)\\}/i', '<span class="colour_inline" style="color: $2;">$1</span>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE BACKGROUND BLOCKS -- //
     // Replace background blocks code with relavant markup [background-name:posx,posy:width,height][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/background(?:-\\1)?(?:-\\2)\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-position: $2 $3; width: $4; height: $5; background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$6</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background-name:posx,posy:width][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/background(?:-\\1)?(?:-\\2)\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-position: $2 $3; width: $4; background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$5</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background-name:posx,posy][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)\\](.*?)\\[\\/background(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-position: $2 $3; background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$4</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background-name:posy][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(top|bottom)\\](.*?)\\[\\/background(?:-\\1)(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-position: center $2; background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$3</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background-name:posx][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px)\\](.*?)\\[\\/background(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-position: $2 center; background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$3</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background-name][/background]
     do {
         $string = preg_replace('/\\s?\\[background(?:-|=|\\:)([-_a-z0-9]+)\\](.*?)\\[\\/background(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_background" style="background-image: url(images/sprites/fields/$1/battle-field_background_base.gif?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$2</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace background blocks code with relavant markup [background][/background]
     do {
         $string = preg_replace('/\\s?\\[background\\](.*?)\\[\\/background\\]\\s?/is', '<div class="field field_panel field_panel_background"><div class="wrap">$1</div></div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE FOREGROUND BLOCKS -- //
     // Replace foreground blocks code with relavant markup [foreground-name:posx,posy:width,height][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-position: $2 $3; width: $4; height: $5; background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$6</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground-name:posx,posy:width][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-position: $2 $3; width: $4; background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$5</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground-name:posx,posy][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px),(top|bottom|center|[0-9]+%|[0-9]+px)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-position: $2 $3; background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$4</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground-name:posy][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(top|bottom)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-position: center $2; background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$3</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground-name:posx][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)(?:-|=|\\:)(left|right|center|[0-9]+%|[0-9]+px)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-position: $2 center; background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$3</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground-name][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground(?:-|=|\\:)([-_a-z0-9]+)\\](.*?)\\[\\/foreground(?:-\\1)?(?:-\\2)?\\]\\s?/is', '<div class="field field_panel field_panel_foreground" style="background-image: url(images/sprites/fields/$1/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . ');"><div class="wrap">$2</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace foreground blocks code with relavant markup [foreground][/foreground]
     do {
         $string = preg_replace('/\\s?\\[foreground\\](.*?)\\[\\/foreground\\]\\s?/is', '<div class="field field_panel field_panel_foreground"><div class="wrap">$1</div></div>', $string, -1, $count);
     } while ($count > 0);
     // Replace float blocks code with relavant markup [layer][/layer]
     //do { $string = preg_replace('/\s?\[layer\](.*?)\[\/layer\]\s?/is', '<div class="layer">$1</div>', $string, -1, $count); }
     //while ($count > 0);
     // -- REPLACE LAYER WRAPPERS -- //
     // Replace layer wrappers code with relavant markup [layer][/layer]
     do {
         $string = preg_replace('/\\s?\\[layer(?:-|=|\\:)([0-9]+)%\\](.*?)\\[\\/layer\\]\\s?/is', '<div class="layer" style="opacity: 0.$1;">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace layer wrappers code with relavant markup [layer][/layer]
     do {
         $string = preg_replace('/\\s?\\[layer\\](.*?)\\[\\/layer\\]\\s?/is', '<div class="layer">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE TYPE BLOCKS -- //
     // Replace type blocks code with relavant markup [type-name:width,height][/type]
     do {
         $string = preg_replace('/\\s?\\[type(?:-|=|\\:)([_a-z]+)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/type(?:-\\1)?\\]\\s?/is', '<div class="type type_panel type_$1" style="width: $2; height: $3;">$4</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace type blocks code with relavant markup [type-name:width][/type]
     do {
         $string = preg_replace('/\\s?\\[type(?:-|=|\\:)([_a-z]+)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/type(?:-\\1)?\\]\\s?/is', '<div class="type type_panel type_$1" style="width: $2;">$3</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace type blocks code with relavant markup [type-name][/type]
     do {
         $string = preg_replace('/\\s?\\[type(?:-|=|\\:)([_a-z]+)\\](.*?)\\[\\/type(?:-\\1)?\\]\\s?/is', '<div class="type type_panel type_$1">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace type blocks code with relavant markup [type][/type]
     do {
         $string = preg_replace('/\\s?\\[type\\](.*?)\\[\\/type\\]\\s?/is', '<div class="type type_panel type_none">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE COLOUR BLOCKS/SPANS -- //
     // Replace colour blocks code with relavant markup [color-value:width,height][/color]
     do {
         $string = preg_replace('/\\s?\\[color(?:-|=|\\:)(#[a-f0-9]{6}|[a-z]+|rgb\\([0-9]+,[0-9]+,[0-9]+\\)|rgba\\([0-9]+,[0-9]+,[0-9]+,[.0-9]+\\)|[a-z]+)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/color(?:-\\1)?\\]\\s?/is', '<div class="colour_panel" style="color: $1; width: $2; height: $3;">$4</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace colour blocks code with relavant markup [color-value:width][/color]
     do {
         $string = preg_replace('/\\s?\\[color(?:-|=|\\:)(#[a-f0-9]{6}|[a-z]+|rgb\\([0-9]+,[0-9]+,[0-9]+\\)|rgba\\([0-9]+,[0-9]+,[0-9]+,[.0-9]+\\)|[a-z]+)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/color(?:-\\1)?\\]\\s?/is', '<div class="colour_panel" style="color: $1; width: $2;">$3</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace colour blocks code with relavant markup [color-value][/color]
     do {
         $string = preg_replace('/\\s?\\[color(?:-|=|\\:)(#[a-f0-9]{6}|[a-z]+|rgb\\([0-9]+,[0-9]+,[0-9]+\\)|rgba\\([0-9]+,[0-9]+,[0-9]+,[.0-9]+\\)|[a-z]+)\\](.*?)\\[\\/color(?:-\\1)?\\]\\s?/is', '<div class="colour_panel" style="color: $1;">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace colour blocks code with relavant markup [color][/color]
     do {
         $string = preg_replace('/\\s?\\[color\\](.*?)\\[\\/color\\]\\s?/is', '<div class="colour_panel" style="color: #FFFFFF;">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE SIZE BLOCKS -- //
     // Replace size blocks code with relavant markup [size-keyword:width,height][/size]
     do {
         $string = preg_replace('/\\s?\\[size(?:-|=|\\:)(small|medium|large)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/size(?:-\\1)?\\]\\s?/is', '<div class="size_$1" style="width: $2; height: $3;">$4</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace size blocks code with relavant markup [size-keyword:width][/size]
     do {
         $string = preg_replace('/\\s?\\[size(?:-|=|\\:)(small|medium|large)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/size(?:-\\1)?\\]\\s?/is', '<div class="size_$1" style="width: $2;">$3</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace size blocks code with relavant markup [size-keyword][/size]
     do {
         $string = preg_replace('/\\s?\\[size(?:-|=|\\:)(small|medium|large)\\](.*?)\\[\\/size(?:-\\1)?\\]\\s?/is', '<div class="size_$1">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace size blocks code with relavant markup [size][/size]
     do {
         $string = preg_replace('/\\s?\\[size\\](.*?)\\[\\/size\\]\\s?/is', '<div class="size_medium">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE ALIGN BLOCKS -- //
     // Replace align blocks code with relavant markup [align-direction:width,height][/align]
     do {
         $string = preg_replace('/\\s?\\[align(?:-|=)(left|right|center)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/align(?:-\\1)?\\]\\s?/is', '<div class="align_$1" style="width: $2; height: $3;">$4</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace align blocks code with relavant markup [align-direction:width][/align]
     do {
         $string = preg_replace('/\\s?\\[align(?:-|=)(left|right|center)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/align(?:-\\1)?\\]\\s?/is', '<div class="align_$1" style="width: $2;">$3</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace align blocks code with relavant markup [align-direction][/align]
     do {
         $string = preg_replace('/\\s?\\[align(?:-|=)(left|right|center)\\](.*?)\\[\\/align(?:-\\1)?\\]\\s?/is', '<div class="align_$1">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace align blocks code with relavant markup [align][/align]
     do {
         $string = preg_replace('/\\s?\\[align\\](.*?)\\[\\/align\\]\\s?/is', '<div class="align_left">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- REPLACE FLOAT BLOCKS -- //
     // Replace float blocks code with relavant markup [float-direction:width,height][/float]
     do {
         $string = preg_replace('/\\s?\\[float(?:-|=|\\:)(left|right|none)(?:-|=|\\:)([0-9]+%|[0-9]+px),([0-9]+%|[0-9]+px)\\](.*?)\\[\\/float(?:-\\1)?\\]\\s?/is', '<div class="float_$1" style="width: $2; height: $3;">$4</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace float blocks code with relavant markup [float-direction:width][/float]
     do {
         $string = preg_replace('/\\s?\\[float(?:-|=|\\:)(left|right|none)(?:-|=|\\:)([0-9]+%|[0-9]+px)\\](.*?)\\[\\/float(?:-\\1)?\\]\\s?/is', '<div class="float_$1" style="width: $2;">$3</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace float blocks code with relavant markup [float-direction][/float]
     do {
         $string = preg_replace('/\\s?\\[float(?:-|=|\\:)(left|right|none)\\](.*?)\\[\\/float(?:-\\1)?\\]\\s?/is', '<div class="float_$1">$2</div>', $string, -1, $count);
     } while ($count > 0);
     // Replace float blocks code with relavant markup [float][/float]
     do {
         $string = preg_replace('/\\s?\\[float\\](.*?)\\[\\/float\\]\\s?/is', '<div class="float_left">$1</div>', $string, -1, $count);
     } while ($count > 0);
     // -- RE-INSERT CODE BLOCKS -- //
     // Loop through any code blocks and replace their contents with the original markup
     if ($has_code) {
         foreach ($code_matches[1] as $key => $match) {
             $string = str_replace('##CODE' . $key . '##', '<span class="code">' . $match . '</span>', $string);
         }
     }
     // -- REPLACE LINE BREAKS -- //
     // Change line breaks to actual breaks by grouping into paragraphs
     $string = str_replace("\n", '<br />', $string);
     $string = preg_replace('/<div( class="[^"]+")?( style="[^"]+")?><br \\/>/is', '<div$1$2>', $string);
     $string = preg_replace('/<br \\/><\\/div>/is', '</div>', $string);
     //$string = preg_replace('<br /><', '<', $string);
     $string = '<div>' . $string . '</div>';
     // Return the decoded string
     return $string;
 }
예제 #2
0
$user_id = isset($_GET['num']) && is_numeric($_GET['num']) ? (int) $_GET['num'] : false;
// Collect user info based on the ID if available
$user_fields = rpg_user::get_fields(true);
if (!empty($user_id)) {
    $user_info = $db->get_array("SELECT {$user_fields} FROM mmrpg_users WHERE user_id = {$user_id};");
} elseif ($user_id === 0) {
    $user_info = $db->get_array("SELECT {$user_fields} FROM mmrpg_users WHERE user_name_clean = 'guest';");
} else {
    $user_info = array();
}
// Parse the user info if it was collected
if (!empty($user_info)) {
    $user_info = rpg_user::parse_info($user_info);
}
// Collect the type index for display and looping
$type_index = rpg_type::get_index(true);
// Generate form select options for the type index
$type_tokens = array_keys($type_index);
$type_index_options = '';
$type_index_options .= '<option value="">Neutral</option>' . PHP_EOL;
// Manually add 'none' up top
foreach ($type_tokens as $type_token) {
    if ($type_token == 'none') {
        continue;
    }
    // We already added 'none' above
    $type_info = $type_index[$type_token];
    $type_index_options .= '<option value="' . $type_token . '">' . $type_info['type_name'] . '</option>' . PHP_EOL;
}
// Require actions file for form processing
require_once MMRPG_CONFIG_ROOTDIR . 'pages/admin_users_actions.php';
예제 #3
0
 /**
  * Get a formatted quote from this player object, optionally providing search and replace values
  * @return string
  */
 public function print_quote($quote_type, $this_search = array(), $this_replace = array())
 {
     $mmrpg_types = rpg_type::get_index();
     // Define the quote text variable
     $quote_text = '';
     // If the player is visible and has the requested quote text
     if ($this->get_token() != 'player' && $this->has_quote($quote_type)) {
         // Collect the quote text with any search/replace modifications
         $this_quote_text = $this->get_quote($quote_type);
         $this_quote_text = str_replace($this_search, $this_replace, $this_quote_text);
         // Collect the text colour for this player
         $this_type_token = str_replace('dr-', '', $this->player_token);
         $this_text_colour = !empty($mmrpg_types[$this_type_token]) ? $mmrpg_types[$this_type_token]['type_colour_light'] : array(200, 200, 200);
         foreach ($this_text_colour as $key => $val) {
             $this_text_colour[$key] += 20;
         }
         // Generate the quote text markup with the appropriate RGB values
         $quote_text = '<span style="color: rgb(' . implode(',', $this_text_colour) . ');">&quot;<em>' . $this_quote_text . '</em>&quot;</span>';
     }
     return $quote_text;
 }
예제 #4
0
    public static function print_database_markup($ability_info, $print_options = array())
    {
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url;
        global $mmrpg_database_abilities, $mmrpg_database_abilities, $mmrpg_database_types;
        global $db;
        // Collect global indexes for easier search
        $mmrpg_types = rpg_type::get_index();
        // Define the markup variable
        $this_markup = '';
        // Define the print style defaults
        if (!isset($print_options['layout_style'])) {
            $print_options['layout_style'] = 'website';
        }
        if ($print_options['layout_style'] == 'website') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = true;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = true;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = true;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'website_compact') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'event') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = false;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = false;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        }
        // Collect the ability sprite dimensions
        $ability_image_size = !empty($ability_info['ability_image_size']) ? $ability_info['ability_image_size'] : 40;
        $ability_image_size_text = $ability_image_size . 'x' . $ability_image_size;
        $ability_image_token = !empty($ability_info['ability_image']) ? $ability_info['ability_image'] : $ability_info['ability_token'];
        // Collect the ability's type for background display
        $ability_type_class = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
        if ($ability_type_class != 'none' && !empty($ability_info['ability_type2'])) {
            $ability_type_class .= '_' . $ability_info['ability_type2'];
        } elseif ($ability_type_class == 'none' && !empty($ability_info['ability_type2'])) {
            $ability_type_class = $ability_info['ability_type2'];
        }
        $ability_header_types = 'ability_type_' . $ability_type_class . ' ';
        // If this is a special category of item, it's a special type
        if (preg_match('/^item-score-ball-(red|blue|green|purple)$/i', $ability_info['ability_token'])) {
            $ability_info['ability_type_special'] = 'bonus';
        } elseif (preg_match('/^item-super-(pellet|capsule)$/i', $ability_info['ability_token'])) {
            $ability_info['ability_type_special'] = 'multi';
        }
        // Define the sprite sheet alt and title text
        $ability_sprite_size = $ability_image_size * 2;
        $ability_sprite_size_text = $ability_sprite_size . 'x' . $ability_sprite_size;
        $ability_sprite_title = $ability_info['ability_name'];
        //$ability_sprite_title = $ability_info['ability_number'].' '.$ability_info['ability_name'];
        //$ability_sprite_title .= ' Sprite Sheet | Robot Database | Mega Man RPG World';
        // Define the sprite frame index for robot images
        $ability_sprite_frames = array('frame_01', 'frame_02', 'frame_03', 'frame_04', 'frame_05', 'frame_06', 'frame_07', 'frame_08', 'frame_09', 'frame_10');
        // Limit any damage or recovery percents to 100%
        if (!empty($ability_info['ability_damage_percent']) && $ability_info['ability_damage'] > 100) {
            $ability_info['ability_damage'] = 100;
        }
        if (!empty($ability_info['ability_damage2_percent']) && $ability_info['ability_damage2'] > 100) {
            $ability_info['ability_damage2'] = 100;
        }
        if (!empty($ability_info['ability_recovery_percent']) && $ability_info['ability_recovery'] > 100) {
            $ability_info['ability_recovery'] = 100;
        }
        if (!empty($ability_info['ability_recovery2_percent']) && $ability_info['ability_recovery2'] > 100) {
            $ability_info['ability_recovery2'] = 100;
        }
        // Start the output buffer
        ob_start();
        ?>
        <div class="database_container database_<?php 
        echo $ability_info['ability_class'] == 'item' ? 'item' : 'ability';
        ?>
_container" data-token="<?php 
        echo $ability_info['ability_token'];
        ?>
" style="<?php 
        echo $print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important;' : '';
        ?>
">

            <?php 
        if ($print_options['layout_style'] == 'website' || $print_options['layout_style'] == 'website_compact') {
            ?>
                <a class="anchor" id="<?php 
            echo $ability_info['ability_token'];
            ?>
">&nbsp;</a>
            <?php 
        }
        ?>

            <div class="subbody event event_triple event_visible" data-token="<?php 
        echo $ability_info['ability_token'];
        ?>
" style="<?php 
        echo ($print_options['layout_style'] == 'event' ? 'margin: 0 !important; ' : '') . ($print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important; ' : '');
        ?>
">

                <?php 
        if ($print_options['show_icon']) {
            ?>

                    <div class="this_sprite sprite_left" style="height: 40px;">
                        <?php 
            if ($print_options['show_icon']) {
                ?>
                            <?php 
                if ($print_options['show_key'] !== false) {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
" style="font-size: 9px; line-height: 11px; text-align: center; margin-bottom: 2px; padding: 0 0 1px !important;"><?php 
                    echo 'No.' . $ability_info['ability_key'];
                    ?>
</div>
                            <?php 
                }
                ?>
                            <?php 
                if ($ability_image_token != 'ability') {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
"><div style="background-image: url(i/a/<?php 
                    echo $ability_image_token;
                    ?>
/ir<?php 
                    echo $ability_image_size;
                    ?>
.png?<?php 
                    echo MMRPG_CONFIG_CACHE_DATE;
                    ?>
); background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_ability sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
_icon"><?php 
                    echo $ability_info['ability_name'];
                    ?>
's Mugshot</div></div>
                            <?php 
                } else {
                    ?>
                                <div class="icon ability_type <?php 
                    echo $ability_header_types;
                    ?>
"><div style="background-image: none; background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_ability sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $ability_image_size_text;
                    ?>
_icon">No Image</div></div>
                            <?php 
                }
                ?>
                        <?php 
            }
            ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_basics']) {
            ?>

                    <h2 class="header header_left <?php 
            echo $ability_header_types;
            ?>
 <?php 
            echo !$print_options['show_icon'] ? 'noicon' : '';
            ?>
">
                        <?php 
            if ($print_options['layout_style'] == 'website_compact') {
                ?>
                            <a href="<?php 
                echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
                ?>
"><?php 
                echo $ability_info['ability_name'];
                ?>
</a>
                        <?php 
            } else {
                ?>
                            <?php 
                echo $ability_info['ability_name'];
                ?>
&#39;s Data
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($ability_info['ability_type_special'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type_special']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($ability_info['ability_type']) && !empty($ability_info['ability_type2'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type']) . ' / ' . ucfirst($ability_info['ability_type2']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($ability_info['ability_type'])) {
                ?>
                            <div class="header_core ability_type"><?php 
                echo ucfirst($ability_info['ability_type']);
                ?>
 Type</div>
                        <?php 
            } else {
                ?>
                            <div class="header_core ability_type">Neutral Type</div>
                        <?php 
            }
            ?>
                    </h2>
                    <div class="body body_left" style="margin-right: 0; margin-bottom: 5px; padding: 2px 0; min-height: 10px; <?php 
            echo !$print_options['show_icon'] ? 'margin-left: 0; ' : '';
            echo $print_options['layout_style'] == 'event' ? 'font-size: 10px; min-height: 150px; ' : '';
            ?>
">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="48%" />
                                <col width="1%" />
                                <col width="48%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td  class="right">
                                        <label style="display: block; float: left;">Name :</label>
                                        <span class="ability_type ability_type_"><?php 
            echo $ability_info['ability_name'];
            ?>
</span>
                                    </td>
                                    <td class="center">&nbsp;</td>
                                    <td class="right">
                                        <label style="display: block; float: left;">Type :</label>
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <?php 
                if (!empty($ability_info['ability_type_special'])) {
                    echo '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_info['ability_type_special'] . '/') . '" class="ability_type ' . $ability_header_types . '">' . ucfirst($ability_info['ability_type_special']) . '</a>';
                } elseif (!empty($ability_info['ability_type'])) {
                    $temp_string = array();
                    $ability_type = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
                    $temp_string[] = '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_type . '/') . '" class="ability_type ability_type_' . $ability_type . '">' . $mmrpg_types[$ability_type]['type_name'] . '</a>';
                    if (!empty($ability_info['ability_type2'])) {
                        $ability_type2 = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : 'none';
                        $temp_string[] = '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . $ability_type2 . '/') . '" class="ability_type ability_type_' . $ability_type2 . '">' . $mmrpg_types[$ability_type2]['type_name'] . '</a>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<a href="' . ((preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' : 'database/abilities/') . 'none/') . '" class="ability_type ability_type_none">Neutral</a>';
                }
                ?>
                                        <?php 
            } else {
                ?>
                                            <?php 
                if (!empty($ability_info['ability_type_special'])) {
                    echo '<span class="ability_type ' . $ability_header_types . '">' . ucfirst($ability_info['ability_type_special']) . '</span>';
                } elseif (!empty($ability_info['ability_type'])) {
                    $temp_string = array();
                    $ability_type = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : 'none';
                    $temp_string[] = '<span class="ability_type ability_type_' . $ability_type . '">' . $mmrpg_types[$ability_type]['type_name'] . '</span>';
                    if (!empty($ability_info['ability_type2'])) {
                        $ability_type2 = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : 'none';
                        $temp_string[] = '<span class="ability_type ability_type_' . $ability_type2 . '">' . $mmrpg_types[$ability_type2]['type_name'] . '</span>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<span class="ability_type ability_type_none">Neutral</span>';
                }
                ?>
                                        <?php 
            }
            ?>
                                    </td>
                                </tr>
                                <?php 
            if ($ability_info['ability_class'] != 'item') {
                ?>

                                    <?php 
                if ($ability_image_token != 'ability') {
                    ?>

                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Power :</label>
                                                <?php 
                    if (!empty($ability_info['ability_damage']) || !empty($ability_info['ability_recovery'])) {
                        ?>
                                                    <?php 
                        if (!empty($ability_info['ability_damage'])) {
                            ?>
<span class="ability_stat"><?php 
                            echo $ability_info['ability_damage'] . (!empty($ability_info['ability_damage_percent']) ? '%' : '');
                            ?>
 Damage</span><?php 
                        }
                        ?>
                                                    <?php 
                        if (!empty($ability_info['ability_recovery'])) {
                            ?>
<span class="ability_stat"><?php 
                            echo $ability_info['ability_recovery'] . (!empty($ability_info['ability_recovery_percent']) ? '%' : '');
                            ?>
 Recovery</span><?php 
                        }
                        ?>
                                                <?php 
                    } else {
                        ?>
                                                    <span class="ability_stat">-</span>
                                                <?php 
                    }
                    ?>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Accuracy :</label>
                                                <span class="ability_stat"><?php 
                    echo $ability_info['ability_accuracy'] . '%';
                    ?>
</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Energy :</label>
                                                <span class="ability_stat"><?php 
                    echo (!empty($ability_info['ability_energy']) ? $ability_info['ability_energy'] : '-') . (!empty($ability_info['ability_energy_percent']) ? '%' : '');
                    ?>
</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Speed :</label>
                                                <span class="ability_stat"><?php 
                    echo !empty($ability_info['ability_speed']) ? $ability_info['ability_speed'] : '1';
                    ?>
</span>
                                            </td>
                                        </tr>

                                    <?php 
                } else {
                    ?>

                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Power :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Accuracy :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td  class="right">
                                                <label style="display: block; float: left;">Energy :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                            <td class="center">&nbsp;</td>
                                            <td class="right">
                                                <label style="display: block; float: left;">Speed :</label>
                                                <span class="ability_stat">-</span>
                                            </td>
                                        </tr>

                                    <?php 
                }
                ?>

                                <?php 
            }
            ?>
                            </tbody>
                        </table>
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <label style="display: block; float: left;">Description :</label>
                                        <?php 
            }
            ?>
                                        <div class="description_container" style="white-space: normal; text-align: left; <?php 
            echo $print_options['layout_style'] == 'event' ? 'font-size: 12px; ' : '';
            ?>
 "><?php 
            // Define the search/replace pairs for the description
            $temp_find = array('{DAMAGE}', '{RECOVERY}', '{DAMAGE2}', '{RECOVERY2}', '{}');
            $temp_replace = array(!empty($ability_info['ability_damage']) ? $ability_info['ability_damage'] : 0, !empty($ability_info['ability_recovery']) ? $ability_info['ability_recovery'] : 0, !empty($ability_info['ability_damage2']) ? $ability_info['ability_damage2'] : 0, !empty($ability_info['ability_recovery2']) ? $ability_info['ability_recovery2'] : 0, '');
            $temp_description = !empty($ability_info['ability_description']) ? $ability_info['ability_description'] : '';
            if (!empty($ability_info['ability_description2'])) {
                $temp_description .= '  ' . $ability_info['ability_description2'];
            }
            echo !empty($temp_description) ? str_replace($temp_find, $temp_replace, $temp_description) : '&hellip;';
            ?>
</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_sprites'] && (!isset($ability_info['ability_image_sheets']) || $ability_info['ability_image_sheets'] !== 0) && $ability_image_token != 'ability') {
            ?>

                    <?php 
            // Start the output buffer and prepare to collect sprites
            ob_start();
            // Define the alts we'll be looping through for this ability
            $temp_alts_array = array();
            $temp_alts_array[] = array('token' => '', 'name' => $ability_info['ability_name'], 'summons' => 0);
            // Append predefined alts automatically, based on the ability image alt array
            if (!empty($ability_info['ability_image_alts'])) {
                $temp_alts_array = array_merge($temp_alts_array, $ability_info['ability_image_alts']);
            } elseif ($ability_info['ability_type'] == 'copy' && preg_match('/^(mega-man|proto-man|bass)$/i', $ability_info['ability_token'])) {
                foreach ($mmrpg_database_types as $type_token => $type_info) {
                    if (empty($type_token) || $type_token == 'none' || $type_token == 'copy') {
                        continue;
                    }
                    $temp_alts_array[] = array('token' => $type_token, 'name' => $ability_info['ability_name'] . ' (' . ucfirst($type_token) . ' Core)', 'summons' => 0);
                }
            } elseif (!empty($ability_info['ability_image_sheets'])) {
                for ($i = 2; $i <= $ability_info['ability_image_sheets']; $i++) {
                    $temp_alts_array[] = array('sheet' => $i, 'name' => $ability_info['ability_name'] . ' (Sheet #' . $i . ')', 'summons' => 0);
                }
            }
            // Loop through the alts and display images for them (yay!)
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                // Define the current image token with alt in mind
                $temp_ability_image_token = $ability_image_token;
                $temp_ability_image_token .= !empty($alt_info['token']) ? '_' . $alt_info['token'] : '';
                $temp_ability_image_token .= !empty($alt_info['sheet']) ? '-' . $alt_info['sheet'] : '';
                $temp_ability_image_name = $alt_info['name'];
                // Update the alt array with this info
                $temp_alts_array[$alt_key]['image'] = $temp_ability_image_token;
                // Collect the number of sheets
                $temp_sheet_number = !empty($ability_info['ability_image_sheets']) ? $ability_info['ability_image_sheets'] : 1;
                // Loop through the different frames and print out the sprite sheets
                foreach (array('right', 'left') as $temp_direction) {
                    $temp_direction2 = substr($temp_direction, 0, 1);
                    $temp_embed = '[ability:' . $temp_direction . ']{' . $temp_ability_image_token . '}';
                    $temp_title = $temp_ability_image_name . ' | Icon Sprite ' . ucfirst($temp_direction);
                    $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                    $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                    $temp_label = 'Icon ' . ucfirst(substr($temp_direction, 0, 1));
                    echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_ability_image_token . '" data-frame="icon" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $ability_sprite_size . 'px; height: ' . $ability_sprite_size . 'px; overflow: hidden;">';
                    echo '<img style="margin-left: 0;" data-tooltip="' . $temp_title . '" src="i/a/' . $temp_ability_image_token . '/i' . $temp_direction2 . $ability_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                    echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                    echo '</div>';
                }
                // Loop through the different frames and print out the sprite sheets
                foreach ($ability_sprite_frames as $this_key => $this_frame) {
                    $margin_left = ceil((0 - $this_key) * $ability_sprite_size);
                    $frame_relative = $this_frame;
                    //if ($temp_sheet > 1){ $frame_relative = 'frame_'.str_pad((($temp_sheet - 1) * count($ability_sprite_frames) + $this_key + 1), 2, '0', STR_PAD_LEFT); }
                    $frame_relative_text = ucfirst(str_replace('_', ' ', $frame_relative));
                    foreach (array('right', 'left') as $temp_direction) {
                        $temp_direction2 = substr($temp_direction, 0, 1);
                        $temp_embed = '[ability:' . $temp_direction . ':' . $frame_relative . ']{' . $temp_ability_image_token . '}';
                        $temp_title = $temp_ability_image_name . ' | ' . $frame_relative_text . ' Sprite ' . ucfirst($temp_direction);
                        $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                        $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                        $temp_label = $frame_relative_text . ' ' . ucfirst(substr($temp_direction, 0, 1));
                        //$image_token = !empty($ability_info['ability_image']) ? $ability_info['ability_image'] : $ability_info['ability_token'];
                        //if ($temp_sheet > 1){ $temp_ability_image_token .= '-'.$temp_sheet; }
                        echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_ability_image_token . '" data-frame="' . $frame_relative . '" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $ability_sprite_size . 'px; height: ' . $ability_sprite_size . 'px; overflow: hidden;">';
                        echo '<img style="margin-left: ' . $margin_left . 'px;" title="' . $temp_title . '" alt="' . $temp_title . '" src="i/a/' . $temp_ability_image_token . '/s' . $temp_direction2 . $ability_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                        echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                        echo '</div>';
                    }
                }
            }
            // Collect the sprite markup from the output buffer for later
            $this_sprite_markup = ob_get_clean();
            ?>

                    <h2 id="sprites" class="header header_full <?php 
            echo $ability_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $ability_info['ability_name'];
            ?>
&#39;s Sprites
                        <span class="header_links image_link_container">
                            <span class="images" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
"><?php 
            // Loop though and print links for the alts
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                $alt_type = '';
                $alt_style = '';
                $alt_title = $alt_info['name'];
                if (preg_match('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', $alt_info['name'])) {
                    $alt_type = strtolower(preg_replace('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', '$1', $alt_info['name']));
                    $alt_name = '&bull;';
                    //ucfirst($alt_type); //substr(ucfirst($alt_type), 0, 2);
                    $alt_type = 'ability_type ability_type_' . $alt_type . ' core_type ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; ';
                } else {
                    $alt_name = $alt_key + 1;
                    //$alt_key == 0 ? $ability_info['ability_name'] : 'Alt'.($alt_key > 1 ? ' '.$alt_key : ''); //$alt_key == 0 ? $ability_info['ability_name'] : $ability_info['ability_name'].' Alt'.($alt_key > 1 ? ' '.$alt_key : '');
                    $alt_type = 'ability_type ability_type_empty ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ';
                    //if ($ability_info['ability_type'] == 'copy' && $alt_key == 0){ $alt_type = 'ability_type ability_type_empty '; }
                }
                echo '<a href="#" data-tooltip="' . $alt_title . '" class="link link_image ' . ($alt_key == 0 ? 'link_active ' : '') . '" data-image="' . $alt_info['image'] . '">';
                echo '<span class="' . $alt_type . '" style="' . $alt_style . '">' . $alt_name . '</span>';
                echo '</a>';
            }
            ?>
</span>
                            <span class="pipe" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
">|</span>
                            <span class="directions"><?php 
            // Loop though and print links for the alts
            foreach (array('right', 'left') as $temp_key => $temp_direction) {
                echo '<a href="#" data-tooltip="' . ucfirst($temp_direction) . ' Facing Sprites" class="link link_direction ' . ($temp_key == 0 ? 'link_active' : '') . '" data-direction="' . $temp_direction . '">';
                echo '<span class="ability_type ability_type_empty" style="border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ">' . ucfirst($temp_direction) . '</span>';
                echo '</a>';
            }
            ?>
</span>
                        </span>
                    </h2>
                    <div id="sprites_body" class="body body_full" style="margin: 0; padding: 10px; min-height: auto;">
                        <div style="border: 1px solid rgba(0, 0, 0, 0.20); border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; background: #4d4d4d url(images/assets/sprite-grid.gif) scroll repeat -10px -30px; overflow: hidden; padding: 10px 30px;">
                            <?php 
            echo $this_sprite_markup;
            ?>
                        </div>
                        <?
                        // Collect the sprite contributor index for display
                        $user_fields = rpg_user::get_fields(true, 'user');
                        $user_role_fields = rpg_user_role::get_fields(true, 'role');
                        $contributor_index = $db->get_array_list("SELECT
                            {$user_fields},
                            {$user_role_fields},
                            (CASE WHEN user.user_name_public <> ''
                                THEN user.user_name_public
                                ELSE user.user_name
                                END) AS user_name_current
                            FROM mmrpg_users AS user
                            LEFT JOIN mmrpg_roles AS role ON role.role_id = user.role_id
                            WHERE role.role_token IN ('developer', 'administrator', 'contributor', 'moderator')
                            ORDER BY user_name_current ASC;
                            ", 'user_id');
                        // Define the editor title based on ID
                        $temp_editor_title = 'Undefined';
                        $temp_final_divider = '<span style="color: #565656;"> | </span>';
                        $temp_editor_ids = array();
                        // Check if an image editor ID has been defined
                        if (!empty($ability_info['ability_image_editor']) && isset($contributor_index[$ability_info['ability_image_editor']])){
                            $temp_editor_ids[] = $ability_info['ability_image_editor'];
                        }
                        // Check if a second image editor ID has been defined
                        if (!empty($ability_info['ability_image_editor2']) && isset($contributor_index[$ability_info['ability_image_editor2']])){
                            $temp_editor_ids[] = $ability_info['ability_image_editor2'];
                        }
                        // If not empty, loop through and add image editors to the string
                        if (!empty($temp_editor_ids)){
                            $temp_editor_title = array();
                            foreach ($temp_editor_ids AS $editor_id){
                                $temp_editor = $contributor_index[$editor_id];
                                $temp_name_public = !empty($temp_editor['user_name_public']) ? $temp_editor['user_name_public'] : $temp_editor['user_name'];
                                $temp_name_real = !empty($temp_editor['user_name']) ? $temp_editor['user_name'] : $temp_editor['user_name_clean'];
                                $temp_name_public_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_public));
                                $temp_name_real_clean = preg_replace('/[^a-z0-9]+/i', '', strtolower($temp_name_real));
                                if ($temp_name_public_clean != $temp_name_real_clean){ $temp_editor_title[] = '<strong>'.$temp_name_public.' / '.$temp_name_real.'</strong>'; }
                                else { $temp_editor_title[] = '<strong>'.$temp_name_public.'</strong>'; }
                            }
                            if (count($temp_editor_title) > 1){ $temp_final_divider = '<br />'; }
                            $temp_editor_title = implode(' and ', $temp_editor_title);
                        }
                        // Print out the final credits footer based on if special case or Capcom original
                        if ($ability_info['ability_game'] == 'MMRPG'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG Prototype</strong></p>'."\n";
                        } elseif ($ability_info['ability_game'] == 'MMRPG2'){
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Mega Man RPG World</strong></p>'."\n";
                        } else {
                            echo '<p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 13px; margin-top: 6px;">Sprite Editing by '.$temp_editor_title.' '.$temp_final_divider.' Original Artwork by <strong>Capcom</strong></p>'."\n";
                        }

                        ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_robots'] && $ability_info['ability_class'] != 'item') {
            ?>

                    <h2 class="header header_full <?php 
            echo $ability_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $ability_info['ability_name'];
            ?>
&#39;s Robots
                    </h2>
                    <div class="body body_full" style="margin: 0; padding: 2px 3px;">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <div class="robot_container">
                                        <?php 
            // Collect the full robot index to loop through
            $ability_type_one = !empty($ability_info['ability_type']) ? $ability_info['ability_type'] : false;
            $ability_type_two = !empty($ability_info['ability_type2']) ? $ability_info['ability_type2'] : false;
            $ability_robot_rewards = array();
            $ability_robot_rewards_level = array();
            $ability_robot_rewards_core = array();
            $ability_robot_rewards_player = array();
            // Collect a FULL list of abilities for display
            $temp_required = array();
            if (!empty($ability_info['ability_master'])) {
                $temp_required[] = $ability_info['ability_master'];
            }
            $temp_robots_index = rpg_robot::get_index(false, false, 'master', $temp_required);
            // Loop through and remove any robots that do not learn the ability
            foreach ($temp_robots_index as $robot_token => $robot_info) {
                // Define the match flah to prevent doubling up
                $temp_match_flag = false;
                // Loop through this robot's ability rewards one by one
                foreach ($robot_info['robot_rewards']['abilities'] as $temp_info) {
                    // If the temp info's type token matches this ability
                    if ($temp_info['token'] == $ability_info['ability_token']) {
                        // Add this ability to the rewards list
                        $ability_robot_rewards_level[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => $temp_info['level']));
                        $temp_match_flag = true;
                        break;
                    }
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
                // If this ability's type matches the robot's first
                if (!empty($robot_info['robot_core']) && ($robot_info['robot_core'] == $ability_type_one || $robot_info['robot_core'] == $ability_type_two)) {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_core[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'core'));
                    continue;
                }
                // If this ability's type matches the robot's second
                if (!empty($robot_info['robot_core2']) && ($robot_info['robot_core2'] == $ability_type_one || $robot_info['robot_core2'] == $ability_type_two)) {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_core[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'core'));
                    continue;
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
                // If this ability's in the robot's list of player-only abilities
                if (!empty($robot_info['robot_abilities']) && in_array($ability_info['ability_token'], $robot_info['robot_abilities']) || !empty($robot_info['robot_core']) && $robot_info['robot_core'] == 'copy' || !empty($robot_info['robot_core2']) && $robot_info['robot_core2'] == 'copy') {
                    // Add this ability to the rewards list
                    $ability_robot_rewards_player[] = array_merge($robot_info, array('token' => $robot_info['robot_token'], 'level' => 'player'));
                    continue;
                }
                // If a type match was found, continue
                if ($temp_match_flag) {
                    continue;
                }
            }
            // Combine the arrays together into one
            $ability_robot_rewards = array_merge($ability_robot_rewards_level, $ability_robot_rewards_core, $ability_robot_rewards_player);
            // Loop through the collected robots if there are any
            if (!empty($ability_robot_rewards)) {
                $temp_string = array();
                $robot_key = 0;
                $robot_method_key = 0;
                $robot_method = '';
                $temp_global_abilities = self::get_global_abilities();
                foreach ($ability_robot_rewards as $this_info) {
                    $this_level = $this_info['level'];
                    $this_robot = $temp_robots_index[$this_info['token']];
                    $this_robot_token = $this_robot['robot_token'];
                    $this_robot_name = $this_robot['robot_name'];
                    $this_robot_image = !empty($this_robot['robot_image']) ? $this_robot['robot_image'] : $this_robot['robot_token'];
                    $this_robot_energy = !empty($this_robot['robot_energy']) ? $this_robot['robot_energy'] : 0;
                    $this_robot_attack = !empty($this_robot['robot_attack']) ? $this_robot['robot_attack'] : 0;
                    $this_robot_defense = !empty($this_robot['robot_defense']) ? $this_robot['robot_defense'] : 0;
                    $this_robot_speed = !empty($this_robot['robot_speed']) ? $this_robot['robot_speed'] : 0;
                    $this_robot_method = 'level';
                    $this_robot_method_text = 'Level Up';
                    $this_robot_title_html = '<strong class="name">' . $this_robot_name . '</strong>';
                    if (is_numeric($this_level)) {
                        if ($this_level > 1) {
                            $this_robot_title_html .= '<span class="level">Lv ' . str_pad($this_level, 2, '0', STR_PAD_LEFT) . '</span>';
                        } else {
                            $this_robot_title_html .= '<span class="level">Start</span>';
                        }
                    } else {
                        if ($this_level == 'core') {
                            $this_robot_method = 'core';
                            $this_robot_method_text = 'Core Match';
                        } elseif ($this_level == 'player') {
                            $this_robot_method = 'player';
                            $this_robot_method_text = 'Player Only';
                        }
                        $this_robot_title_html .= '<span class="level">&nbsp;</span>';
                    }
                    $this_stat_base_total = $this_robot_energy + $this_robot_attack + $this_robot_defense + $this_robot_speed;
                    $this_stat_width_total = 84;
                    if (!empty($this_robot['robot_core'])) {
                        $this_robot_title_html .= '<span class="robot_core type_' . $this_robot['robot_core'] . '">' . ucwords($this_robot['robot_core'] . (!empty($this_robot['robot_core2']) ? ' / ' . $this_robot['robot_core2'] : '')) . ' Core</span>';
                    } else {
                        $this_robot_title_html .= '<span class="robot_core type_none">Neutral Core</span>';
                    }
                    $this_robot_title_html .= '<span class="class">' . (!empty($this_robot['robot_description']) ? $this_robot['robot_description'] : '&hellip;') . '</span>';
                    if (!empty($this_robot_speed)) {
                        $temp_speed_width = floor($this_stat_width_total * ($this_robot_speed / $this_stat_base_total));
                    }
                    if (!empty($this_robot_defense)) {
                        $temp_defense_width = floor($this_stat_width_total * ($this_robot_defense / $this_stat_base_total));
                    }
                    if (!empty($this_robot_attack)) {
                        $temp_attack_width = floor($this_stat_width_total * ($this_robot_attack / $this_stat_base_total));
                    }
                    if (!empty($this_robot_energy)) {
                        $temp_energy_width = $this_stat_width_total - ($temp_speed_width + $temp_defense_width + $temp_attack_width);
                    }
                    if (!empty($this_robot_energy)) {
                        $this_robot_title_html .= '<span class="energy robot_type robot_type_energy" style="width: ' . $temp_energy_width . '%;" title="' . $this_robot_energy . ' Energy">' . $this_robot_energy . '</span>';
                    }
                    if (!empty($this_robot_attack)) {
                        $this_robot_title_html .= '<span class="attack robot_type robot_type_attack" style="width: ' . $temp_attack_width . '%;" title="' . $this_robot_attack . ' Attack">' . $this_robot_attack . '</span>';
                    }
                    if (!empty($this_robot_defense)) {
                        $this_robot_title_html .= '<span class="defense robot_type robot_type_defense" style="width: ' . $temp_defense_width . '%;" title="' . $this_robot_defense . ' Defense">' . $this_robot_defense . '</span>';
                    }
                    if (!empty($this_robot_speed)) {
                        $this_robot_title_html .= '<span class="speed robot_type robot_type_speed" style="width: ' . $temp_speed_width . '%;" title="' . $this_robot_speed . ' Speed">' . $this_robot_speed . '</span>';
                    }
                    $this_robot_sprite_size = !empty($this_robot['robot_image_size']) ? $this_robot['robot_image_size'] : 40;
                    $this_robot_sprite_path = 'images/sprites/robots/' . $this_robot_image . '/mug_left_' . $this_robot_sprite_size . 'x' . $this_robot_sprite_size . '.png';
                    if (!file_exists(MMRPG_CONFIG_ROOTDIR . $this_robot_sprite_path)) {
                        $this_robot_image = 'robot';
                        $this_robot_sprite_path = 'i/r/robot/ml40.png';
                    } else {
                        $this_robot_sprite_path = 'i/r/' . $this_robot_image . '/ml' . $this_robot_sprite_size . '.png';
                    }
                    if ($this_robot_image != 'robot') {
                        $this_robot_sprite_html = '<span class="mug"><img class="size_' . $this_robot_sprite_size . 'x' . $this_robot_sprite_size . '" src="' . $this_robot_sprite_path . '?' . MMRPG_CONFIG_CACHE_DATE . '" alt="' . $this_robot_name . ' Mug" /></span>';
                    } else {
                        $this_robot_sprite_html = '<span class="mug"></span>';
                    }
                    $this_robot_title_html = '<span class="label">' . $this_robot_title_html . '</span>';
                    //$this_robot_title_html = (is_numeric($this_level) && $this_level > 1 ? 'Lv '.str_pad($this_level, 2, '0', STR_PAD_LEFT).' : ' : $this_level.' : ').$this_robot_title_html;
                    if ($robot_method != $this_robot_method) {
                        if ($this_robot_method == 'level' && $ability_info['ability_token'] == 'buster-shot') {
                            continue;
                        }
                        $temp_separator = '<div class="robot_separator">' . $this_robot_method_text . '</div>';
                        $temp_string[] = $temp_separator;
                        $robot_method = $this_robot_method;
                        $robot_method_key++;
                        // Print out the disclaimer if a global ability
                        if (in_array($ability_info['ability_token'], $temp_global_abilities)) {
                            $temp_string[] = '<div class="" style="margin: 10px auto; text-align: center; color: #767676; font-size: 11px;">' . $ability_info['ability_name'] . ' can be equipped by <em>any</em> robot master!</div>';
                        }
                    }
                    // If this is a global ability, don't bother showing EVERY compatible robot
                    if ($this_robot_method == 'level' && $ability_info['ability_token'] == 'buster-shot' || $this_robot_method != 'level' && in_array($ability_info['ability_token'], $temp_global_abilities)) {
                        continue;
                    }
                    if ($this_level >= 0) {
                        //title="'.$this_robot_title_plain.'"
                        $temp_markup = '<a href="' . MMRPG_CONFIG_ROOTURL . 'database/robots/' . $this_robot['robot_token'] . '/"  class="robot_name robot_type robot_type_' . (!empty($this_robot['robot_core']) ? $this_robot['robot_core'] . (!empty($this_robot['robot_core2']) ? '_' . $this_robot['robot_core2'] : '') : 'none') . '" style="' . ($this_robot_image == 'robot' ? 'opacity: 0.3; ' : '') . '">';
                        $temp_markup .= '<span class="chrome">' . $this_robot_sprite_html . $this_robot_title_html . '</span>';
                        $temp_markup .= '</a>';
                        $temp_string[] = $temp_markup;
                        $robot_key++;
                        continue;
                    }
                }
                echo implode(' ', $temp_string);
            } else {
                echo '<span class="robot_ability robot_type_none"><span class="chrome">Neutral</span></span>';
            }
            ?>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
            ?>
" rel="permalink">+ Permalink</a>

                <?php 
        } elseif ($print_options['show_footer'] && $print_options['layout_style'] == 'website_compact') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo preg_match('/^item-/', $ability_info['ability_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $ability_info['ability_token']) . '/' : 'database/abilities/' . $ability_info['ability_token'] . '/';
            ?>
" rel="permalink">+ View More</a>

                <?php 
        }
        ?>

            </div>
        </div>
        <?php 
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
        'limit' => $this_search_limit
        );

    // Sanitize the search string to prevent exploitation
    if (!empty($this_search_text)){
        $this_search_text = trim($this_search_text);
        if (!is_numeric($this_search_text)){
            $this_search_text = strtolower($this_search_text);
            $this_search_text = preg_replace('/[^-a-z0-9*@]+/i', ' ', $this_search_text);
            $this_search_text = trim($this_search_text);
            $this_search_text = preg_replace('/(\*|\s)+/', '%', $this_search_text);
        }
    }

    // Collect an array of elemental types
    $mmrpg_types = rpg_type::get_index(true);
    $mmrpg_types_tokens = array_keys($mmrpg_types);
    $mmrpg_types_tokens[] = 'neutral';

    // Define different search actions for different types
    switch ($this_search_type){

        // If this was a USER search request
        case 'users': {

            // Define a search query for finding users
            $this_search_query = "SELECT
                user_id AS id,
                user_name AS name,
                user_name_public AS name2,
                user_name_clean AS name3,
예제 #6
0
<?php

// TYPES DATABASE
// Define the index of types for the game
$mmrpg_database_types = rpg_type::get_index();
uasort($mmrpg_database_types, function ($t1, $t2) {
    if ($t1['type_order'] > $t2['type_order']) {
        return 1;
    } elseif ($t1['type_order'] < $t2['type_order']) {
        return -1;
    } else {
        return 0;
    }
});
$mmrpg_database_types_count = count($mmrpg_database_types);
$mmrpg_database_types_count_added = 1;
$mmrpg_database_types_count_actual = count($mmrpg_database_types);
예제 #7
0
    public static function print_database_markup($item_info, $print_options = array())
    {
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url;
        global $mmrpg_database_items, $mmrpg_database_robots, $mmrpg_database_items, $mmrpg_database_types;
        global $db;
        // Collect global indexes for easier search
        $mmrpg_types = rpg_type::get_index(true);
        // Define the markup variable
        $this_markup = '';
        // Define the print style defaults
        if (!isset($print_options['layout_style'])) {
            $print_options['layout_style'] = 'website';
        }
        if ($print_options['layout_style'] == 'website') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = true;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = true;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = true;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'website_compact') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = true;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = true;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        } elseif ($print_options['layout_style'] == 'event') {
            if (!isset($print_options['show_basics'])) {
                $print_options['show_basics'] = true;
            }
            if (!isset($print_options['show_icon'])) {
                $print_options['show_icon'] = false;
            }
            if (!isset($print_options['show_sprites'])) {
                $print_options['show_sprites'] = false;
            }
            if (!isset($print_options['show_robots'])) {
                $print_options['show_robots'] = false;
            }
            if (!isset($print_options['show_records'])) {
                $print_options['show_records'] = false;
            }
            if (!isset($print_options['show_footer'])) {
                $print_options['show_footer'] = false;
            }
            if (!isset($print_options['show_key'])) {
                $print_options['show_key'] = false;
            }
        }
        // Collect the item sprite dimensions
        $item_image_size = !empty($item_info['item_image_size']) ? $item_info['item_image_size'] : 40;
        $item_image_size_text = $item_image_size . 'x' . $item_image_size;
        $item_image_token = !empty($item_info['item_image']) ? $item_info['item_image'] : $item_info['item_token'];
        // Collect the item's type for background display
        $item_type_class = !empty($item_info['item_type']) ? $item_info['item_type'] : 'none';
        if ($item_type_class != 'none' && !empty($item_info['item_type2'])) {
            $item_type_class .= '_' . $item_info['item_type2'];
        } elseif ($item_type_class == 'none' && !empty($item_info['item_type2'])) {
            $item_type_class = $item_info['item_type2'];
        }
        $item_header_types = 'item_type_' . $item_type_class . ' ';
        // If this is a special category of item, it's a special type
        if (preg_match('/^(red|blue|green|purple)-score-ball$/i', $item_info['item_token'])) {
            $item_info['item_type_special'] = 'bonus';
        } elseif (preg_match('/^super-(pellet|capsule)$/i', $item_info['item_token'])) {
            $item_info['item_type_special'] = 'multi';
        }
        // Define the sprite sheet alt and title text
        $item_sprite_size = $item_image_size * 2;
        $item_sprite_size_text = $item_sprite_size . 'x' . $item_sprite_size;
        $item_sprite_title = $item_info['item_name'];
        //$item_sprite_title = $item_info['item_number'].' '.$item_info['item_name'];
        //$item_sprite_title .= ' Sprite Sheet | Robot Database | Mega Man RPG World';
        // Define the sprite frame index for robot images
        $item_sprite_frames = array('frame_01', 'frame_02', 'frame_03', 'frame_04', 'frame_05', 'frame_06', 'frame_07', 'frame_08', 'frame_09', 'frame_10');
        // Limit any damage or recovery percents to 100%
        if (!empty($item_info['item_damage_percent']) && $item_info['item_damage'] > 100) {
            $item_info['item_damage'] = 100;
        }
        if (!empty($item_info['item_damage2_percent']) && $item_info['item_damage2'] > 100) {
            $item_info['item_damage2'] = 100;
        }
        if (!empty($item_info['item_recovery_percent']) && $item_info['item_recovery'] > 100) {
            $item_info['item_recovery'] = 100;
        }
        if (!empty($item_info['item_recovery2_percent']) && $item_info['item_recovery2'] > 100) {
            $item_info['item_recovery2'] = 100;
        }
        // Start the output buffer
        ob_start();
        ?>
        <div class="database_container database_<?php 
        echo $item_info['item_class'] == 'item' ? 'item' : 'item';
        ?>
_container" data-token="<?php 
        echo $item_info['item_token'];
        ?>
" style="<?php 
        echo $print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important;' : '';
        ?>
">

            <?php 
        if ($print_options['layout_style'] == 'website' || $print_options['layout_style'] == 'website_compact') {
            ?>
                <a class="anchor" id="<?php 
            echo $item_info['item_token'];
            ?>
">&nbsp;</a>
            <?php 
        }
        ?>

            <div class="subbody event event_triple event_visible" data-token="<?php 
        echo $item_info['item_token'];
        ?>
" style="<?php 
        echo ($print_options['layout_style'] == 'event' ? 'margin: 0 !important; ' : '') . ($print_options['layout_style'] == 'website_compact' ? 'margin-bottom: 2px !important; ' : '');
        ?>
">

                <?php 
        if ($print_options['show_icon']) {
            ?>

                    <div class="this_sprite sprite_left" style="height: 40px;">
                        <?php 
            if ($print_options['show_icon']) {
                ?>
                            <?php 
                if ($print_options['show_key'] !== false) {
                    ?>
                                <div class="icon item_type <?php 
                    echo $item_header_types;
                    ?>
" style="font-size: 9px; line-height: 11px; text-align: center; margin-bottom: 2px; padding: 0 0 1px !important;"><?php 
                    echo 'No.' . $item_info['item_key'];
                    ?>
</div>
                            <?php 
                }
                ?>
                            <?php 
                if ($item_image_token != 'item') {
                    ?>
                                <div class="icon item_type <?php 
                    echo $item_header_types;
                    ?>
"><div style="background-image: url(i/i/<?php 
                    echo $item_image_token;
                    ?>
/ir<?php 
                    echo $item_image_size;
                    ?>
.png?<?php 
                    echo MMRPG_CONFIG_CACHE_DATE;
                    ?>
); background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_item sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $item_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $item_image_size_text;
                    ?>
_icon"><?php 
                    echo $item_info['item_name'];
                    ?>
's Mugshot</div></div>
                            <?php 
                } else {
                    ?>
                                <div class="icon item_type <?php 
                    echo $item_header_types;
                    ?>
"><div style="background-image: none; background-color: #000000; background-color: rgba(0, 0, 0, 0.6); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); " class="sprite sprite_item sprite_40x40 sprite_40x40_icon sprite_size_<?php 
                    echo $item_image_size_text;
                    ?>
 sprite_size_<?php 
                    echo $item_image_size_text;
                    ?>
_icon">No Image</div></div>
                            <?php 
                }
                ?>
                        <?php 
            }
            ?>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_basics']) {
            ?>

                    <h2 class="header header_left <?php 
            echo $item_header_types;
            ?>
 <?php 
            echo !$print_options['show_icon'] ? 'noicon' : '';
            ?>
">
                        <?php 
            if ($print_options['layout_style'] == 'website_compact') {
                ?>
                            <a href="<?php 
                echo preg_match('/^item-/', $item_info['item_token']) ? 'database/items/' . preg_replace('/^item-/i', '', $item_info['item_token']) . '/' : 'database/items/' . $item_info['item_token'] . '/';
                ?>
"><?php 
                echo $item_info['item_name'];
                ?>
</a>
                        <?php 
            } else {
                ?>
                            <?php 
                echo $item_info['item_name'];
                ?>
&#39;s Data
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($item_info['item_type_special'])) {
                ?>
                            <div class="header_core item_type"><?php 
                echo ucfirst($item_info['item_type_special']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($item_info['item_type']) && !empty($item_info['item_type2'])) {
                ?>
                            <div class="header_core item_type"><?php 
                echo ucfirst($item_info['item_type']) . ' / ' . ucfirst($item_info['item_type2']);
                ?>
 Type</div>
                        <?php 
            } elseif (!empty($item_info['item_type'])) {
                ?>
                            <div class="header_core item_type"><?php 
                echo ucfirst($item_info['item_type']);
                ?>
 Type</div>
                        <?php 
            } else {
                ?>
                            <div class="header_core item_type">Neutral Type</div>
                        <?php 
            }
            ?>
                    </h2>
                    <div class="body body_left" style="margin-right: 0; margin-bottom: 5px; padding: 2px 0; min-height: 10px; <?php 
            echo !$print_options['show_icon'] ? 'margin-left: 0; ' : '';
            echo $print_options['layout_style'] == 'event' ? 'font-size: 10px; min-height: 150px; ' : '';
            ?>
">
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="48%" />
                                <col width="1%" />
                                <col width="48%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td  class="right">
                                        <label style="display: block; float: left;">Name :</label>
                                        <span class="item_type item_type_"><?php 
            echo $item_info['item_name'];
            ?>
</span>
                                    </td>
                                    <td class="center">&nbsp;</td>
                                    <td class="right">
                                        <label style="display: block; float: left;">Type :</label>
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <?php 
                if (!empty($item_info['item_type_special'])) {
                    echo '<a href="database/items/' . $item_info['item_type_special'] . '/" class="item_type ' . $item_header_types . '">' . ucfirst($item_info['item_type_special']) . '</a>';
                } elseif (!empty($item_info['item_type'])) {
                    $temp_string = array();
                    $item_type = !empty($item_info['item_type']) ? $item_info['item_type'] : 'none';
                    $temp_string[] = '<a href="database/items/' . $item_type . '/" class="item_type item_type_' . $item_type . '">' . $mmrpg_types[$item_type]['type_name'] . '</a>';
                    if (!empty($item_info['item_type2'])) {
                        $item_type2 = !empty($item_info['item_type2']) ? $item_info['item_type2'] : 'none';
                        $temp_string[] = '<a href="database/items/' . $item_type2 . '/" class="item_type item_type_' . $item_type2 . '">' . $mmrpg_types[$item_type2]['type_name'] . '</a>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<a href="database/items/none/" class="item_type item_type_none">Neutral</a>';
                }
                ?>
                                        <?php 
            } else {
                ?>
                                            <?php 
                if (!empty($item_info['item_type_special'])) {
                    echo '<span class="item_type ' . $item_header_types . '">' . ucfirst($item_info['item_type_special']) . '</span>';
                } elseif (!empty($item_info['item_type'])) {
                    $temp_string = array();
                    $item_type = !empty($item_info['item_type']) ? $item_info['item_type'] : 'none';
                    $temp_string[] = '<span class="item_type item_type_' . $item_type . '">' . $mmrpg_types[$item_type]['type_name'] . '</span>';
                    if (!empty($item_info['item_type2'])) {
                        $item_type2 = !empty($item_info['item_type2']) ? $item_info['item_type2'] : 'none';
                        $temp_string[] = '<span class="item_type item_type_' . $item_type2 . '">' . $mmrpg_types[$item_type2]['type_name'] . '</span>';
                    }
                    echo implode(' ', $temp_string);
                } else {
                    echo '<span class="item_type item_type_none">Neutral</span>';
                }
                ?>
                                        <?php 
            }
            ?>
                                    </td>
                                </tr>
                                <tr>
                                    <td  class="right">
                                        <label style="display: block; float: left;">Power :</label>
                                        <?php 
            if (!empty($item_info['item_damage']) || !empty($item_info['item_recovery'])) {
                ?>
                                            <?php 
                if (!empty($item_info['item_damage'])) {
                    ?>
<span class="item_stat"><?php 
                    echo number_format($item_info['item_damage'], 0, '.', ',') . (!empty($item_info['item_damage_percent']) ? '%' : '');
                    ?>
 Damage</span><?php 
                }
                ?>
                                            <?php 
                if (!empty($item_info['item_recovery'])) {
                    ?>
<span class="item_stat"><?php 
                    echo number_format($item_info['item_recovery'], 0, '.', ',') . (!empty($item_info['item_recovery_percent']) ? '%' : '');
                    ?>
 Recovery</span><?php 
                }
                ?>
                                        <?php 
            } elseif (!empty($item_info['item_damage2']) || !empty($item_info['item_recovery2'])) {
                ?>
                                            <?php 
                if (!empty($item_info['item_damage2'])) {
                    ?>
<span class="item_stat"><?php 
                    echo number_format($item_info['item_damage2'], 0, '.', ',') . (!empty($item_info['item_damage2_percent']) ? '%' : '');
                    ?>
</span><?php 
                }
                ?>
                                            <?php 
                if (!empty($item_info['item_recovery2'])) {
                    ?>
<span class="item_stat"><?php 
                    echo number_format($item_info['item_recovery2'], 0, '.', ',') . (!empty($item_info['item_recovery2_percent']) ? '%' : '');
                    ?>
</span><?php 
                }
                ?>
                                        <?php 
            } else {
                ?>
                                            <span class="item_stat">-</span>
                                        <?php 
            }
            ?>
                                    </td>
                                    <td class="center">&nbsp;</td>
                                    <td class="right">
                                        <label style="display: block; float: left;">Value :</label>
                                        <?php 
            if (!empty($item_info['item_price'])) {
                ?>
                                            <span class="item_stat"><?php 
                echo number_format($item_info['item_price'], 0, '.', ',') . 'z';
                ?>
</span>
                                        <?php 
            } else {
                ?>
                                            <span class="item_stat">-</span>
                                        <?php 
            }
            ?>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <table class="full" style="margin: 5px auto 10px;">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right">
                                        <?php 
            if ($print_options['layout_style'] != 'event') {
                ?>
                                            <label style="display: block; float: left;">Description :</label>
                                        <?php 
            }
            ?>
                                        <div class="description_container" style="white-space: normal; text-align: left; <?php 
            echo $print_options['layout_style'] == 'event' ? 'font-size: 12px; ' : '';
            ?>
 "><?php 
            // Define the search/replace pairs for the description
            $temp_find = array('{DAMAGE}', '{RECOVERY}', '{DAMAGE2}', '{RECOVERY2}', '{}');
            $temp_replace = array(!empty($item_info['item_damage']) ? number_format($item_info['item_damage'], 0, '.', ',') : 0, !empty($item_info['item_recovery']) ? number_format($item_info['item_recovery'], 0, '.', ',') : 0, !empty($item_info['item_damage2']) ? number_format($item_info['item_damage2'], 0, '.', ',') : 0, !empty($item_info['item_recovery2']) ? number_format($item_info['item_recovery2'], 0, '.', ',') : 0, '');
            echo !empty($item_info['item_description']) ? str_replace($temp_find, $temp_replace, $item_info['item_description']) : '&hellip;';
            ?>
</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_sprites'] && (!isset($item_info['item_image_sheets']) || $item_info['item_image_sheets'] !== 0) && $item_image_token != 'item') {
            ?>

                    <?php 
            // Start the output buffer and prepare to collect sprites
            ob_start();
            // Define the alts we'll be looping through for this item
            $temp_alts_array = array();
            $temp_alts_array[] = array('token' => '', 'name' => $item_info['item_name'], 'summons' => 0);
            // Append predefined alts automatically, based on the item image alt array
            if (!empty($item_info['item_image_alts'])) {
                $temp_alts_array = array_merge($temp_alts_array, $item_info['item_image_alts']);
            } elseif ($item_info['item_type'] == 'copy' && preg_match('/^(mega-man|proto-man|bass)$/i', $item_info['item_token'])) {
                foreach ($mmrpg_database_types as $type_token => $type_info) {
                    if (empty($type_token) || $type_token == 'none' || $type_token == 'copy') {
                        continue;
                    }
                    $temp_alts_array[] = array('token' => $type_token, 'name' => $item_info['item_name'] . ' (' . ucfirst($type_token) . ' Core)', 'summons' => 0);
                }
            } elseif (!empty($item_info['item_image_sheets'])) {
                for ($i = 2; $i <= $item_info['item_image_sheets']; $i++) {
                    $temp_alts_array[] = array('sheet' => $i, 'name' => $item_info['item_name'] . ' (Sheet #' . $i . ')', 'summons' => 0);
                }
            }
            // Loop through the alts and display images for them (yay!)
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                // Define the current image token with alt in mind
                $temp_item_image_token = $item_image_token;
                $temp_item_image_token .= !empty($alt_info['token']) ? '_' . $alt_info['token'] : '';
                $temp_item_image_token .= !empty($alt_info['sheet']) ? '-' . $alt_info['sheet'] : '';
                $temp_item_image_name = $alt_info['name'];
                // Update the alt array with this info
                $temp_alts_array[$alt_key]['image'] = $temp_item_image_token;
                // Collect the number of sheets
                $temp_sheet_number = !empty($item_info['item_image_sheets']) ? $item_info['item_image_sheets'] : 1;
                // Loop through the different frames and print out the sprite sheets
                foreach (array('right', 'left') as $temp_direction) {
                    $temp_direction2 = substr($temp_direction, 0, 1);
                    $temp_embed = '[item:' . $temp_direction . ']{' . $temp_item_image_token . '}';
                    $temp_title = $temp_item_image_name . ' | Icon Sprite ' . ucfirst($temp_direction);
                    $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                    $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                    $temp_label = 'Icon ' . ucfirst(substr($temp_direction, 0, 1));
                    echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_item_image_token . '" data-frame="icon" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $item_sprite_size . 'px; height: ' . $item_sprite_size . 'px; overflow: hidden;">';
                    echo '<img style="margin-left: 0;" data-tooltip="' . $temp_title . '" src="i/i/' . $temp_item_image_token . '/i' . $temp_direction2 . $item_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                    echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                    echo '</div>';
                }
                // Loop through the different frames and print out the sprite sheets
                foreach ($item_sprite_frames as $this_key => $this_frame) {
                    $margin_left = ceil((0 - $this_key) * $item_sprite_size);
                    $frame_relative = $this_frame;
                    //if ($temp_sheet > 1){ $frame_relative = 'frame_'.str_pad((($temp_sheet - 1) * count($item_sprite_frames) + $this_key + 1), 2, '0', STR_PAD_LEFT); }
                    $frame_relative_text = ucfirst(str_replace('_', ' ', $frame_relative));
                    foreach (array('right', 'left') as $temp_direction) {
                        $temp_direction2 = substr($temp_direction, 0, 1);
                        $temp_embed = '[item:' . $temp_direction . ':' . $frame_relative . ']{' . $temp_item_image_token . '}';
                        $temp_title = $temp_item_image_name . ' | ' . $frame_relative_text . ' Sprite ' . ucfirst($temp_direction);
                        $temp_title .= '<div style="margin-top: 4px; letting-spacing: 1px; font-size: 90%; font-family: Courier New; color: rgb(159, 150, 172);">' . $temp_embed . '</div>';
                        $temp_title = htmlentities($temp_title, ENT_QUOTES, 'UTF-8', true);
                        $temp_label = $frame_relative_text . ' ' . ucfirst(substr($temp_direction, 0, 1));
                        //$image_token = !empty($item_info['item_image']) ? $item_info['item_image'] : $item_info['item_token'];
                        //if ($temp_sheet > 1){ $temp_item_image_token .= '-'.$temp_sheet; }
                        echo '<div class="frame_container" data-clickcopy="' . $temp_embed . '" data-direction="' . $temp_direction . '" data-image="' . $temp_item_image_token . '" data-frame="' . $frame_relative . '" style="padding-top: 20px; float: left; position: relative; margin: 0; box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.75); width: ' . $item_sprite_size . 'px; height: ' . $item_sprite_size . 'px; overflow: hidden;">';
                        echo '<img style="margin-left: ' . $margin_left . 'px;" title="' . $temp_title . '" alt="' . $temp_title . '" src="i/i/' . $temp_item_image_token . '/s' . $temp_direction2 . $item_sprite_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '" />';
                        echo '<label style="position: absolute; left: 5px; top: 0; color: #EFEFEF; font-size: 10px; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);">' . $temp_label . '</label>';
                        echo '</div>';
                    }
                }
            }
            // Collect the sprite markup from the output buffer for later
            $this_sprite_markup = ob_get_clean();
            ?>

                    <h2 id="sprites" class="header header_full <?php 
            echo $item_header_types;
            ?>
" style="margin: 10px 0 0; text-align: left;">
                        <?php 
            echo $item_info['item_name'];
            ?>
&#39;s Sprites
                        <span class="header_links image_link_container">
                            <span class="images" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
"><?php 
            // Loop though and print links for the alts
            foreach ($temp_alts_array as $alt_key => $alt_info) {
                $alt_type = '';
                $alt_style = '';
                $alt_title = $alt_info['name'];
                if (preg_match('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', $alt_info['name'])) {
                    $alt_type = strtolower(preg_replace('/^(?:[-_a-z0-9\\s]+)\\s\\(([a-z0-9]+)\\sCore\\)$/i', '$1', $alt_info['name']));
                    $alt_name = '&bull;';
                    //ucfirst($alt_type); //substr(ucfirst($alt_type), 0, 2);
                    $alt_type = 'item_type item_type_' . $alt_type . ' core_type ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; ';
                } else {
                    $alt_name = $alt_key + 1;
                    //$alt_key == 0 ? $item_info['item_name'] : 'Alt'.($alt_key > 1 ? ' '.$alt_key : ''); //$alt_key == 0 ? $item_info['item_name'] : $item_info['item_name'].' Alt'.($alt_key > 1 ? ' '.$alt_key : '');
                    $alt_type = 'item_type item_type_empty ';
                    $alt_style = 'border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ';
                    //if ($item_info['item_type'] == 'copy' && $alt_key == 0){ $alt_type = 'item_type item_type_empty '; }
                }
                echo '<a href="#" data-tooltip="' . $alt_title . '" class="link link_image ' . ($alt_key == 0 ? 'link_active ' : '') . '" data-image="' . $alt_info['image'] . '">';
                echo '<span class="' . $alt_type . '" style="' . $alt_style . '">' . $alt_name . '</span>';
                echo '</a>';
            }
            ?>
</span>
                            <span class="pipe" style="<?php 
            echo count($temp_alts_array) == 1 ? 'visibility: hidden;' : '';
            ?>
">|</span>
                            <span class="directions"><?php 
            // Loop though and print links for the alts
            foreach (array('right', 'left') as $temp_key => $temp_direction) {
                echo '<a href="#" data-tooltip="' . ucfirst($temp_direction) . ' Facing Sprites" class="link link_direction ' . ($temp_key == 0 ? 'link_active' : '') . '" data-direction="' . $temp_direction . '">';
                echo '<span class="item_type item_type_empty" style="border-color: rgba(0, 0, 0, 0.2) !important; background-color: rgba(0, 0, 0, 0.2) !important; ">' . ucfirst($temp_direction) . '</span>';
                echo '</a>';
            }
            ?>
</span>
                        </span>
                    </h2>
                    <div id="sprites_body" class="body body_full" style="margin: 0; padding: 10px; min-height: auto;">
                        <div style="border: 1px solid rgba(0, 0, 0, 0.20); border-radius: 0.5em; -moz-border-radius: 0.5em; -webkit-border-radius: 0.5em; background: #4d4d4d url(images/assets/sprite-grid.gif) scroll repeat -10px -30px; overflow: hidden; padding: 10px 30px;">
                            <?php 
            echo $this_sprite_markup;
            ?>
                        </div>
                        <?php 
            // Define the editor title based on ID
            $temp_editor_title = 'Undefined';
            if (!empty($item_info['item_image_editor'])) {
                if ($item_info['item_image_editor'] == 412) {
                    $temp_editor_title = 'Adrian Marceau / Ageman20XX';
                } elseif ($item_info['item_image_editor'] == 110) {
                    $temp_editor_title = 'MetalMarioX100 / EliteP1';
                } elseif ($item_info['item_image_editor'] == 18) {
                    $temp_editor_title = 'Sean Adamson / MetalMan';
                }
            } elseif ($item_image_token != 'item') {
                $temp_editor_title = 'Adrian Marceau / Ageman20XX';
            }
            ?>
                        <p class="text text_editor" style="text-align: center; color: #868686; font-size: 10px; line-height: 10px; margin-top: 6px;">Sprite Editing by <strong><?php 
            echo $temp_editor_title;
            ?>
</strong> <span style="color: #565656;"> | </span> Original Artwork by <strong>Capcom</strong></p>
                    </div>

                <?php 
        }
        ?>

                <?php 
        if ($print_options['show_footer'] && $print_options['layout_style'] == 'website') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo 'database/items/' . $item_info['item_token'] . '/';
            ?>
" rel="permalink">+ Permalink</a>

                <?php 
        } elseif ($print_options['show_footer'] && $print_options['layout_style'] == 'website_compact') {
            ?>

                    <a class="link link_top" data-href="#top" rel="nofollow">^ Top</a>
                    <a class="link link_permalink permalink" href="<?php 
            echo 'database/items/' . $item_info['item_token'] . '/';
            ?>
" rel="permalink">+ View More</a>

                <?php 
        }
        ?>

            </div>
        </div>
        <?php 
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
예제 #8
0
 /**
  * Get the formatted editor title markup for this field object given field info
  * @param array $field_info
  * @return string
  */
 public static function print_editor_title_markup($field_info)
 {
     // Collect references to global objects
     $db = cms_database::get_database();
     // Collect references to global indexes
     $mmrpg_types = rpg_type::get_index();
     $mmrpg_players = rpg_player::get_index();
     $mmrpg_robots = rpg_robot::get_index();
     // Expand the field index info
     $field_token = $field_info['field_token'];
     $field_info = rpg_field::get_index_info($field_token);
     if (empty($field_info) || empty($field_info)) {
         return false;
     }
     // Collect the field type info and expand master/mecha data
     $temp_field_type = !empty($field_info['field_type']) ? $mmrpg_types[$field_info['field_type']] : false;
     $temp_field_type2 = !empty($field_info['field_type2']) ? $mmrpg_types[$field_info['field_type2']] : false;
     $temp_field_master = !empty($field_info['field_master']) ? rpg_robot::parse_index_info($mmrpg_robots[$field_info['field_master']]) : false;
     $temp_field_mechas = !empty($field_info['field_mechas']) ? $field_info['field_mechas'] : array();
     foreach ($temp_field_mechas as $key => $token) {
         $temp_mecha = rpg_robot::parse_index_info($mmrpg_robots[$token]);
         if (!empty($temp_mecha)) {
             $temp_field_mechas[$key] = $temp_mecha['robot_name'];
         } else {
             unset($temp_field_mechas[$key]);
         }
     }
     // Generate the field title markup
     $temp_field_title = $field_info['field_name'];
     if (!empty($temp_field_type)) {
         $temp_field_title .= ' (' . $temp_field_type['type_name'] . ' Type)';
     }
     if (!empty($temp_field_type2)) {
         $temp_field_title = str_replace('Type', '/ ' . $temp_field_type2['type_name'] . ' Type', $temp_field_title);
     }
     $temp_field_title .= '  // ';
     if (!empty($temp_field_master)) {
         $temp_field_title .= 'Robot : ' . $temp_field_master['robot_name'] . ' // ';
     }
     if (!empty($temp_field_mechas)) {
         $temp_field_title .= 'Mecha : ' . implode(', ', array_unique($temp_field_mechas)) . ' // ';
     }
     // Return the generated markup
     return $temp_field_title;
 }
예제 #9
0
        $key_counter = array_search($this_token, array_keys($mmrpg_database_fields));
        $temp_field_info = $mmrpg_database_fields[$this_token];
        $temp_field_markup = rpg_field::print_database_markup($temp_field_info, array('show_key' => $key_counter));
        $temp_field_markup = preg_replace('/\\s+/', ' ', $temp_field_markup);
        echo 'success : ' . $temp_field_markup;
        break;
        // If this was a item request
    // If this was a item request
    case 'items':
        $key_counter = array_search($this_token, array_keys($mmrpg_database_items));
        $temp_item_info = $mmrpg_database_items[$this_token];
        $temp_item_markup = rpg_ability::print_database_markup($temp_item_info, array('show_key' => $key_counter));
        $temp_item_markup = preg_replace('/\\s+/', ' ', $temp_item_markup);
        echo 'success : ' . $temp_item_markup;
        break;
        // If this was a type request
    // If this was a type request
    case 'types':
        $temp_type_info = $mmrpg_database_types[$this_token];
        $temp_type_markup = rpg_type::print_database_markup($temp_type_info);
        $temp_type_markup = preg_replace('/\\s+/', ' ', $temp_type_markup);
        echo 'success : ' . $temp_type_markup;
        break;
        // If this was an invalid request
    // If this was an invalid request
    default:
        die('error : invalid class requested');
        break;
}
// Exit the script gracefully if it gets this far
exit;
예제 #10
0
    if (!empty($this_current_cat) && $this_current_id !== false && !empty($this_current_token)) {
        $this_current_uri .= $this_current_cat . '/' . $this_current_id . '/' . $this_current_token . '/';
    } elseif (!empty($this_current_cat) && !empty($this_current_sub)) {
        $this_current_uri = $this_current_page . '/' . $this_current_cat . '/' . $this_current_sub . '/';
    } elseif (!empty($this_current_cat)) {
        $this_current_uri .= $this_current_cat . '/';
    }
    if (!empty($this_current_target)) {
        //$this_current_uri .= $this_current_target.'/';
    }
    if (!empty($this_current_num) && $this_current_num != 1) {
        $this_current_uri .= $this_current_num . '/';
    }
} elseif ($this_current_page == 'database') {
    $this_current_token = !empty($_GET['token']) ? $_GET['token'] : '';
    $temp_type_token = rpg_type::get_index_info($this_current_token);
    if (!empty($this_current_token) && !empty($temp_type_token) || in_array($this_current_token, array('multi', 'bonus'))) {
        $this_current_filter = $_GET['filter'] = $this_current_token;
        $this_current_filter_name = $this_current_filter == 'none' ? 'Neutral' : ucfirst($this_current_filter);
        $this_current_uri .= $this_current_filter . '/';
        $this_current_token = $_GET['token'] = '';
    } elseif (!empty($this_current_token)) {
        $this_current_uri .= $this_current_token . '/';
    }
} elseif ($this_current_page == 'leaderboard') {
    $this_current_token = !empty($_GET['token']) ? $_GET['token'] : '';
    if (!empty($this_current_token)) {
        $this_current_uri .= $this_current_token . '/';
    }
} elseif ($this_current_page == 'file') {
    $this_current_token = !empty($_GET['token']) ? $_GET['token'] : '';
예제 #11
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;
    }