コード例 #1
0
<?php

// -- DR. WILY PASSWORDS -- //
// Collect the temp battle flags
$temp_flags = !empty($_SESSION['GAME']['flags']) ? $_SESSION['GAME']['flags'] : array();
// If the UNLOCK DISCO password was created
if (!empty($temp_flags['drwily_password_robotgetpanicatthedisco'])) {
    if (!rpg_game::robot_unlocked(false, 'disco')) {
        // Unlock Roll as a playable character
        $unlock_player_info = $mmrpg_index['players']['dr-wily'];
        $unlock_robot_info = rpg_robot::get_index_info('disco');
        $unlock_robot_info['robot_level'] = 1;
        $unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience(1) - 1;
        rpg_game::unlock_robot($unlock_player_info, $unlock_robot_info, true);
        header('Location: prototype.php');
        exit;
    }
}
// If the UNLOCK BUBBLE BOMB password was created
if (!empty($temp_flags['drwily_password_abilitygetbubblebombsaway'])) {
    if (!rpg_game::ability_unlocked('dr-wily', false, 'bubble-bomb')) {
        // Unlock Bubble Bomb as an equippable ability
        rpg_game::unlock_ability($mmrpg_index['players']['dr-wily'], false, array('ability_token' => 'bubble-bomb'), true);
        header('Location: prototype.php');
        exit;
    }
}
// If the UNLOCK SHADOW BLADE password was created
if (!empty($temp_flags['drwily_password_abilitygetcutterofdarkness'])) {
    if (!rpg_game::ability_unlocked('dr-wily', false, 'shadow-blade')) {
        // Unlock Shadow Blade as an equippable ability
コード例 #2
0
 public static function generate_fortress($this_prototype_data, $temp_battle_level, $temp_index_token, $temp_battle_token, $temp_robot_masters = array(), $temp_support_mechas = array(), $temp_player_info = array())
 {
     // Pull in global variables for this function
     global $mmrpg_index, $db;
     // Collect the battle index for this foress battle
     $temp_battle_index = rpg_battle::get_index_info($temp_index_token);
     $temp_robot_index = rpg_robot::get_index();
     //ksort($_SESSION['GAME']['values']['battle_index']);
     //exit('$session_values_battle_index = <pre>'.print_r($_SESSION['GAME']['values']['battle_index'], true).'</pre>');
     //unset($_SESSION['GAME']['values']['battle_index'][$temp_battle_token]);
     //die('$temp_battle_index = <pre>'.print_r($temp_battle_index, true).'</pre>');
     // Copy over any completion records from the old, index-based name
     if (!empty($_SESSION['GAME']['values']['battle_complete'][$this_prototype_data['this_player_token']][$temp_index_token])) {
         $_SESSION['GAME']['values']['battle_complete'][$this_prototype_data['this_player_token']][$temp_battle_token] = $_SESSION['GAME']['values']['battle_complete'][$this_prototype_data['this_player_token']][$temp_index_token];
         unset($_SESSION['GAME']['values']['battle_complete'][$this_prototype_data['this_player_token']][$temp_index_token]);
     }
     // Copy over any completion records from the old, index-based name
     if (!empty($_SESSION['GAME']['values']['battle_failure'][$this_prototype_data['this_player_token']][$temp_index_token])) {
         $_SESSION['GAME']['values']['battle_failure'][$this_prototype_data['this_player_token']][$temp_battle_token] = $_SESSION['GAME']['values']['battle_failure'][$this_prototype_data['this_player_token']][$temp_index_token];
         unset($_SESSION['GAME']['values']['battle_failure'][$this_prototype_data['this_player_token']][$temp_index_token]);
     }
     // Collect and define the rest of the details
     $temp_battle_omega = $temp_battle_index;
     $temp_battle_complete = rpg_prototype::battle_complete($this_prototype_data['this_player_token'], $temp_battle_token);
     $temp_battle_targets = !empty($temp_battle_omega['battle_target_player']['player_robots']) ? count($temp_battle_omega['battle_target_player']['player_robots']) : 0;
     $temp_battle_omega['option_chapter'] = $this_prototype_data['this_current_chapter'];
     $temp_battle_omega['battle_token'] = $temp_battle_token;
     $temp_battle_omega['battle_phase'] = $this_prototype_data['battle_phase'];
     $temp_battle_omega['battle_level'] = $temp_battle_level;
     //$this_prototype_data['this_chapter_levels'][5];
     // If the battle is complete, remove the player from the description and increase the level
     if (!empty($temp_battle_complete)) {
         $temp_base_level = $temp_battle_omega['battle_level'];
         $temp_battle_omega['battle_level'] += !empty($temp_battle_complete['battle_count']) ? $temp_battle_complete['battle_count'] : 0;
         if ($temp_battle_omega['battle_level'] > $temp_base_level * 2) {
             $temp_battle_omega['battle_level'] = $temp_base_level * 2;
         }
         $temp_battle_omega['battle_target_player']['player_token'] = 'player';
         $temp_battle_omega['battle_description'] = preg_replace('/^Defeat (Dr. (Wily|Light|Cossack)\'s)/i', 'Defeat', $temp_battle_omega['battle_description']);
     }
     // If robot masters were provided to the function, update them in the battle array
     if (!empty($temp_robot_masters)) {
         $temp_battle_omega['battle_target_player']['player_robots'] = $temp_robot_masters;
     }
     // If support mechas were provided to the function, update them in the battle array
     if (!empty($temp_support_mechas)) {
         $temp_battle_omega['battle_field_info']['field_mechas'] = $temp_support_mechas;
     }
     // Start all the point-based battle vars at zero
     $temp_battle_omega['battle_points'] = 0;
     $temp_battle_omega['battle_zenny'] = 0;
     $temp_battle_omega['battle_turns_limit'] = 0;
     $temp_battle_omega['battle_robots_limit'] = 0;
     // If the player info array was provided, merge into current
     if (!empty($temp_player_info)) {
         $temp_battle_omega['battle_target_player'] = array_merge($temp_battle_omega['battle_target_player'], $temp_player_info);
     }
     // Loop through and adjust the levels of robots
     if (!empty($temp_battle_omega['battle_target_player']['player_robots'])) {
         $stat_boost_amount = !empty($temp_battle_complete['battle_count']) ? $temp_battle_complete['battle_count'] * $temp_battle_level : 0;
         if ($stat_boost_amount >= 1000) {
             $stat_boost_amount = 1000;
         }
         foreach ($temp_battle_omega['battle_target_player']['player_robots'] as $key => $robot) {
             $index = $temp_robot_index[$robot['robot_token']];
             $robot['robot_level'] = $temp_battle_omega['battle_level'];
             if (!empty($stat_boost_amount)) {
                 $robot['values'] = array();
                 $robot['values']['robot_rewards'] = array();
                 $robot['values']['robot_rewards']['robot_energy'] = $stat_boost_amount;
                 $robot['values']['robot_rewards']['robot_attack'] = $stat_boost_amount;
                 $robot['values']['robot_rewards']['robot_defense'] = $stat_boost_amount;
                 $robot['values']['robot_rewards']['robot_speed'] = $stat_boost_amount;
             }
             // Increment the battle's turn limit based on the class of target robot
             if ($index['robot_class'] == 'master') {
                 $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERROBOT;
             } elseif ($index['robot_class'] == 'mecha') {
                 $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERMECHA;
             } elseif ($index['robot_class'] == 'boss') {
                 $temp_battle_omega['battle_turns_limit'] += MMRPG_SETTINGS_BATTLETURNS_PERBOSS;
             }
             // Increment the battle's point reward based on the class of target robot
             if ($index['robot_class'] == 'master') {
                 $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERROBOT;
             } elseif ($index['robot_class'] == 'mecha') {
                 $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERMECHA;
             } elseif ($index['robot_class'] == 'boss') {
                 $temp_battle_omega['battle_points'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERBOSS;
             }
             // Increment the battle's zenny reward based on the class of target robot
             if ($index['robot_class'] == 'master') {
                 $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERROBOT;
             } elseif ($index['robot_class'] == 'mecha') {
                 $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERMECHA;
             } elseif ($index['robot_class'] == 'boss') {
                 $temp_battle_omega['battle_zenny'] += $robot['robot_level'] * MMRPG_SETTINGS_BATTLEZENNY_PERBOSS;
             }
             // Increment the battle's robot limit based on the class of target robot
             if ($index['robot_class'] == 'master') {
                 $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERROBOT;
             } elseif ($index['robot_class'] == 'mecha') {
                 $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERMECHA;
             } elseif ($index['robot_class'] == 'boss') {
                 $temp_battle_omega['battle_robots_limit'] += MMRPG_SETTINGS_BATTLEROBOTS_PERBOSS;
             }
             $temp_battle_omega['battle_target_player']['player_robots'][$key] = $robot;
         }
     }
     //$temp_battle_omega['battle_field_info']['field_name'] = 'stat boost '.$stat_boost_amount.' '.$temp_battle_omega['battle_target_player']['player_robots'][$key]['values']['robot_rewards']['robot_energy'].' | ';
     // Fix any zero or invalid battle values
     if ($temp_battle_omega['battle_points'] < 1) {
         $temp_battle_omega['battle_points'] = 1;
     } else {
         $temp_battle_omega['battle_points'] = ceil($temp_battle_omega['battle_points']);
     }
     if ($temp_battle_omega['battle_turns_limit'] < 1) {
         $temp_battle_omega['battle_turns_limit'] = 1;
     } else {
         $temp_battle_omega['battle_turns_limit'] = ceil($temp_battle_omega['battle_turns_limit']);
     }
     if ($temp_battle_omega['battle_robots_limit'] < 1) {
         $temp_battle_omega['battle_robots_limit'] = 1;
     } else {
         $temp_battle_omega['battle_robots_limit'] = ceil($temp_battle_omega['battle_robots_limit']);
     }
     // Return the generated omega battle data
     return $temp_battle_omega;
 }
コード例 #3
0
 */

// Define object class tokens for ABILITIES
$object_class_token = 'ability';
$object_single_token = 'ability';
$object_multi_token = 'abilities';

// Define the object names based on tokens
$object_single_name = ucfirst($object_single_token);
$object_multi_name = ucfirst($object_multi_token);

// Collect the various global indexes for display and looping
$type_index = rpg_type::get_index(true);
$player_index = rpg_player::get_index(true, true);
$field_index = rpg_field::get_index(true, true);
$robot_index = rpg_robot::get_index(true, true, '', null, "FIELD(robot_class, 'mecha', 'master', 'boss')");

// Collect the ability ID from the request header
$ability_id = isset($_GET['num']) && is_numeric($_GET['num']) ? (int)($_GET['num']) : false;

// Collect ability fields to pull from the database
$ability_fields = rpg_ability::get_index_fields(true);

// Collect ability info from the database if an ID was provided
if (!empty($ability_id)){
    $ability_info = $db->get_array("SELECT {$ability_fields} FROM mmrpg_index_abilities WHERE ability_id = {$ability_id};");
}
// Generate new ability info given a class and the database ability template
elseif ($ability_id === 0){
    $ability_info = $db->get_array("SELECT {$ability_fields} FROM mmrpg_index_abilities WHERE ability_token = 'ability';");
    foreach ($ability_info AS $f => $v){
コード例 #4
0
 public static function ability_function_overdrive($objects, $shot_text = 'energy', $damage_text = 'damaged', $recovery_text = 'recovered')
 {
     // Extract all objects into the current scope
     extract($objects);
     // Decrease this robot's weapon energy to zero
     $this_robot->set_weapons(0);
     // Target the opposing robot
     $this_ability->target_options_update(array('kickback' => array(-5, 0, 0), 'frame' => 'defend', 'success' => array(0, 15, 45, 10, $this_robot->print_name() . ' uses the ' . $this_ability->print_name() . '!')));
     $this_robot->trigger_target($target_robot, $this_ability);
     // Define this ability's attachment token
     $crest_attachment_token = 'ability_' . $this_ability->ability_token;
     $crest_attachment_info = array('class' => 'ability', 'sticky' => true, 'ability_id' => $this_ability->ability_id, 'ability_token' => $this_ability->ability_token, 'ability_image' => $this_ability->ability_token, 'ability_frame' => 0, 'ability_frame_animate' => array(1, 2), 'ability_frame_offset' => array('x' => 20, 'y' => 50, 'z' => 10), 'ability_frame_classes' => ' ', 'ability_frame_styles' => ' ');
     // Add the ability crest attachment
     $this_robot->set_frame('summon');
     $this_robot->set_attachment($crest_attachment_token, $crest_attachment_info);
     // Define this ability's attachment token
     $overlay_attachment_token = 'system_fullscreen-black';
     $overlay_attachment_info = array('class' => 'ability', 'sticky' => true, 'ability_id' => $this_ability->ability_id, 'ability_token' => $this_ability->ability_token, 'ability_image' => 'fullscreen-black', 'ability_frame' => 0, 'ability_frame_animate' => array(0, 1), 'ability_frame_offset' => array('x' => 0, 'y' => 0, 'z' => -12), 'ability_frame_classes' => 'sprite_fullscreen ');
     // Add the black overlay attachment
     $target_robot->set_attachment($overlay_attachment_token, $overlay_attachment_info);
     // prepare the ability options
     $this_ability->damage_options_update(array('kind' => 'energy', 'kickback' => array(20, 0, 0), 'success' => array(3, -60, -15, 10, 'A powerful ' . ($shot_text != 'energy' ? $shot_text . ' energy' : 'energy') . ' shot ' . $damage_text . ' ' . $target_robot->print_name() . '!'), 'failure' => array(3, -110, -15, -10, 'The ' . $this_ability->print_name() . ' shot missed ' . $target_robot->print_name() . '&hellip;')));
     $this_ability->recovery_options_update(array('kind' => 'energy', 'frame' => 'taunt', 'kickback' => array(20, 0, 0), 'success' => array(3, -60, -15, 10, 'The ' . ($shot_text != 'energy' ? $shot_text . ' energy' : 'energy') . ' shot ' . $recovery_text . ' ' . $target_robot->print_name() . '!'), 'failure' => array(3, -110, -15, -10, 'The ' . $this_ability->print_name() . ' shot missed ' . $target_robot->print_name() . '&hellip;')));
     // Inflict damage on the opposing robot
     $energy_damage_amount = $this_ability->ability_damage;
     $target_robot->trigger_damage($this_robot, $this_ability, $energy_damage_amount, false);
     // Remove the black overlay attachment
     $target_robot->unset_attachment($overlay_attachment_token);
     // Loop through the target's benched robots, inflicting half base damage to each
     $backup_robots_active = $target_player->values['robots_active'];
     foreach ($backup_robots_active as $key => $info) {
         if ($info['robot_id'] == $target_robot->robot_id) {
             continue;
         }
         $this_ability->ability_results_reset();
         $temp_target_robot = new rpg_robot($target_player, $info);
         // Add the black overlay attachment
         $overlay_attachment_info['ability_frame_offset']['z'] -= 2;
         $temp_target_robot->set_attachment($overlay_attachment_token, $overlay_attachment_info);
         // Update the ability options
         $this_ability->damage_options_update(array('kind' => 'energy', 'kickback' => array(20, 0, 0), 'success' => array(3, -60, -15, 10, 'A powerful ' . ($shot_text != 'energy' ? $shot_text . ' energy' : 'energy') . ' shot ' . $damage_text . ' ' . $temp_target_robot->print_name() . '!'), 'failure' => array(3, -110, -15, -10, 'The ' . $this_ability->print_name() . ' shot missed ' . $temp_target_robot->print_name() . '&hellip;')));
         $this_ability->recovery_options_update(array('kind' => 'energy', 'frame' => 'taunt', 'kickback' => array(20, 0, 0), 'success' => array(3, -60, -15, 10, 'The ' . ($shot_text != 'energy' ? $shot_text . ' energy' : 'energy') . ' shot ' . $recovery_text . ' ' . $temp_target_robot->print_name() . '!'), 'failure' => array(3, -110, -15, -10, 'The ' . $this_ability->print_name() . ' shot missed ' . $temp_target_robot->print_name() . '&hellip;')));
         //$energy_damage_amount = ceil($this_ability->ability_damage / $target_robots_active);
         $energy_damage_amount = $this_ability->ability_damage;
         $temp_target_robot->trigger_damage($this_robot, $this_ability, $energy_damage_amount, false);
         $temp_target_robot->unset_attachment($overlay_attachment_token);
     }
     // Remove the black background attachment
     $this_robot->set_frame('base');
     $this_robot->unset_attachment($crest_attachment_token);
     // Trigger the disabled event on the targets now if necessary
     if ($target_robot->robot_energy <= 0 || $target_robot->robot_status == 'disabled') {
         $target_robot->trigger_disabled($this_robot, $this_ability);
     }
     foreach ($backup_robots_active as $key => $info) {
         if ($info['robot_id'] == $target_robot->robot_id) {
             continue;
         }
         $temp_target_robot = new rpg_robot($target_player, $info);
         if ($temp_target_robot->robot_energy <= 0 || $temp_target_robot->robot_status == 'disabled') {
             $temp_target_robot->trigger_disabled($this_robot, $this_ability);
         }
     }
     // Return true on success
     return true;
 }
コード例 #5
0
ファイル: unlocks.php プロジェクト: AdrianMarceau/mmrpg-world
    // If Cossack has been unlocked but somehow Proto Man was not
    if (!rpg_game::robot_unlocked(false, 'proto-man')) {
        // Unlock Proto Man as a playable character
        $unlock_player_info = $mmrpg_index['players']['dr-cossack'];
        $unlock_robot_info = rpg_robot::get_index_info('proto-man');
        $unlock_robot_info['robot_level'] = 21;
        $unlock_robot_info['robot_experience'] = 999;
        rpg_game::unlock_robot($unlock_player_info, $unlock_robot_info, true, true);
    }
}
// UNLOCK ROBOT : RHYTHM
// If the player has failed at least three battles, unlock Rhythm as a playable character
if ($battle_failure_counter_cossack >= 3 && !rpg_game::robot_unlocked(false, 'rhythm')) {
    // Unlock Rhythm as a playable character
    $unlock_player_info = $mmrpg_index['players']['dr-cossack'];
    $unlock_robot_info = rpg_robot::get_index_info('rhythm');
    $unlock_robot_info['robot_level'] = 21;
    $unlock_robot_info['robot_experience'] = 999;
    rpg_game::unlock_robot($unlock_player_info, $unlock_robot_info, true, true);
}
// UNLOCK EVENT : PHASE TWO CHAPTERS (LIGHT)
// If Dr. Cossack has completed all of his first phase, open Dr. Light's second
if ($battle_complete_counter_cossack >= 10) {
    // Create the event flag and unset the player select variable to force main menu
    $temp_event_flag = 'dr-cossack_event-97_phase-one-complete';
    if (empty($temp_game_flags['events'][$temp_event_flag])) {
        $temp_game_flags['events'][$temp_event_flag] = true;
        $_SESSION[$session_token]['battle_settings']['this_player_token'] = false;
    }
}
// UNLOCK EVENT : PHASE THREE CHAPTERS (ALL)
コード例 #6
0
ファイル: shop.php プロジェクト: AdrianMarceau/mmrpg-world
    // Start the output buffer
    ob_start();
    // Loop through the shops in the field edit data
    foreach ($allowed_edit_data as $shop_token => $shop_info) {
        // Update the player key to the current counter
        $shop_key = $key_counter;
        $shop_info['shop_image'] = $shop_info['shop_token'];
        $shop_info['shop_image_size'] = 40;
        // Collect a temp robot object for printing items
        $player_info = $mmrpg_index['players'][$shop_info['shop_player']];
        if ($shop_info['shop_player'] == 'dr-light') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['mega-man']);
        } elseif ($shop_info['shop_player'] == 'dr-wily') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['bass']);
        } elseif ($shop_info['shop_player'] == 'dr-cossack') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['proto-man']);
        }
        // Collect the tokens for all this shop's selling and buying tabs
        $shop_selling_tokens = is_array($shop_info['shop_kind_selling']) ? $shop_info['shop_kind_selling'] : array($shop_info['shop_kind_selling']);
        $shop_buying_tokens = is_array($shop_info['shop_kind_buying']) ? $shop_info['shop_kind_buying'] : array($shop_info['shop_kind_buying']);
        // Collect and print the editor markup for this player
        ?>
        <div class="event event_double event_<?php 
        echo $shop_key == 0 ? 'visible' : 'hidden';
        ?>
" data-token="<?php 
        echo $shop_info['shop_token'];
        ?>
">
            <div class="this_sprite sprite_left" style="top: 4px; left: 4px; width: 36px; height: 36px; background-image: url(images/sprites/fields/<?php 
        echo $shop_info['shop_field'];
コード例 #7
0
$this_graph_data['description'] = 'Mega Man RPG World was not created by person, or even by any one piece of software.  Many different tools and resources were necessary for the game to get to where it is today, and you can find a list of the most notable here on this page.';
//$this_graph_data['image'] = MMRPG_CONFIG_ROOTURL.'images/assets/mmrpg-prototype-logo.png';
//$this_graph_data['type'] = 'website';
// Define the MARKUP variables for this page
$this_markup_header = 'Mega Man RPG World Resources';
// Start generating the page markup
ob_start();
?>

<h2 class="subheader field_type_<?php 
echo MMRPG_SETTINGS_CURRENT_FIELDTYPE;
?>
">Resources Overview</h2>
<div class="subbody">
  <div class="float float_right"><div class="sprite sprite_80x80 sprite_80x80_<?php 
echo rpg_robot::random_frame();
?>
" style="background-image: url(images/sprites/robots/time-man/sprite_left_80x80.png);"></div></div>
  <p class="text">The <strong>Mega Man RPG World</strong> was not created by person, or even by any one piece of software.  Many different tools and resources were necessary for the game to get to where it is today, and you can find a list of the most notable here on this page. If there are any other items that you think I've forgotten and should be added to the list, please <a href="contact/">let me know</a> using the contact page.</p>
</div>

<h2 class="subheader field_type_<?php 
echo MMRPG_SETTINGS_CURRENT_FIELDTYPE;
?>
">Tools and Resources</h2>
<div class="subbody" style="margin-bottom: 2px; ">
  <p class="text">
    <a href="http://www.sprites-inc.co.uk/files/Classic/" target="_blank"><strong>Sprites Inc.</strong></a> <span class="pipe">|</span> <span>Resource</span> <span class="pipe">|</span> <em>Official Sprites</em><br />
    Many (and maybe all) sprites that appear in this game were found on the number one Mega Man sprite resource - Sprites Inc. - and without the the website I'm sure many Mega Man fan-games would not have been possible.  Even the custom sprites are based on those found on this website, and I cannot thank the creators and contributors enough for their efforts and the fantastic service they provide.  I highly recommend the website for all your Mega Man sprite needs.  :)
  </p>
</div>
コード例 #8
0
foreach ($this_omega_factors_four as $key => $factor) {
    if (in_array($factor['field'], $temp_unlocked_fields)) {
        $temp_omega_factor_options[] = $factor;
        $unlocked_factor_four_robots = true;
    }
}
// Loop through the collected options and pull just the robot tokens
foreach ($temp_omega_factor_options as $key => $factor) {
    $temp_omega_factor_options_unlocked[] = $factor['field'];
}
// Require the starforce data file
require_once '../includes/starforce.php';
// Collect the editor flag if set
$global_allow_editing = isset($_GET['edit']) && $_GET['edit'] == 'false' ? false : true;
// Collect the robot's index for names and fields
$rpg_robots_index = rpg_robot::get_index();
// Collect all the robots that have been unlocked by the player
$rpg_robots_encountered = array();
if (!empty($_SESSION[$session_token]['values']['robot_database'])) {
    $rpg_robots_encountered = array_keys($_SESSION[$session_token]['values']['robot_database']);
}
// Collect the omega factors that we should be printing links for
$temp_omega_factors_unlocked = array();
if ($unlocked_factor_one_robots) {
    $temp_omega_factors_unlocked = array_merge($temp_omega_factors_unlocked, $this_omega_factors_one);
}
if ($unlocked_factor_two_robots) {
    $temp_omega_factors_unlocked = array_merge($temp_omega_factors_unlocked, $this_omega_factors_two);
}
if ($unlocked_factor_four_robots) {
    $temp_omega_factors_unlocked = array_merge($temp_omega_factors_unlocked, $this_omega_factors_four);
コード例 #9
0
    Mecha Listing
    <?php 
    echo isset($this_current_filter) ? '<span class="count" style="float: right;">( ' . $this_current_filter_name . ' Type )</span>' : '';
    ?>
  </h2>
  <?php 
}
// If we're in the index view, loop through and display all mechas
if (empty($this_current_token)) {
    // Loop through the mecha database and display the appropriate data
    $key_counter = 0;
    foreach ($mmrpg_database_mechas as $mecha_key => $mecha_info) {
        // If a type filter has been applied to the mecha page
        if (isset($this_current_filter) && $this_current_filter == 'none' && $mecha_info['robot_core'] != '') {
            $key_counter++;
            continue;
        } elseif (isset($this_current_filter) && $this_current_filter != 'none' && $mecha_info['robot_core'] != $this_current_filter && $mecha_info['robot_core2'] != $this_current_filter) {
            $key_counter++;
            continue;
        }
        // Collect information about this mecha
        $this_robot_image = !empty($mecha_info['robot_image']) ? $mecha_info['robot_image'] : $mecha_info['robot_token'];
        if ($this_robot_image == 'robot') {
            $this_seo_robots = 'noindex';
        }
        // Collect the markup for this robot and print it to the browser
        $temp_mecha_markup = rpg_robot::print_database_markup($mecha_info, array('layout_style' => 'website_compact', 'show_key' => $key_counter));
        echo $temp_mecha_markup;
        $key_counter++;
    }
}
コード例 #10
0
function refresh_editor_arrays()
{
    global $allowed_edit_players, $allowed_edit_robots, $allowed_edit_data;
    global $allowed_edit_data_count, $allowed_edit_player_count, $allowed_edit_robot_count;
    // Collect the current session token
    $session_token = rpg_game::session_token();
    // Collect the player array and merge in session details
    $temp_player_array = array();
    if (!empty($_SESSION[$session_token]['values']['battle_rewards'])) {
        $temp_player_rewards = $_SESSION[$session_token]['values']['battle_rewards'];
        $temp_player_array = array_merge($temp_player_array, $temp_player_rewards);
    }
    if (!empty($_SESSION[$session_token]['values']['battle_settings'])) {
        $temp_player_settings = $_SESSION[$session_token]['values']['battle_settings'];
        $temp_player_array = array_merge($temp_player_array, $temp_player_settings);
    }
    // Define the editor indexes and count variables
    $allowed_edit_players = array();
    $allowed_edit_robots = array();
    $allowed_edit_data = array();
    $allowed_edit_data_count = 0;
    $allowed_edit_player_count = 0;
    $allowed_edit_robot_count = 0;
    // Collect a temporary player index
    $temp_player_tokens = array_keys($temp_player_array);
    $temp_player_index = rpg_player::get_index_custom($temp_player_tokens);
    // Now to actually loop through and update the allowed players, robots, and abilities arrays
    foreach ($temp_player_array as $player_token => $player_info) {
        if (empty($player_token) || !isset($temp_player_index[$player_token])) {
            continue;
        }
        $player_index_info = $temp_player_index[$player_token];
        // If this player has not yet completed chapter one, no robot editor
        $intro_complete = rpg_prototype::event_complete('completed-chapter_' . $player_token . '_one');
        $prototype_complete = rpg_prototype::campaign_complete($player_token);
        if (!$intro_complete && !$prototype_complete) {
            continue;
        }
        // Merge the player and index info then append the token and info
        $player_info = array_merge($player_index_info, $player_info);
        $allowed_edit_players[] = $player_token;
        $allowed_edit_data[$player_token] = $player_info;
        // Collect a temporary robot index
        $temp_robot_tokens = array_keys($player_info['player_robots']);
        $temp_robot_index = rpg_robot::get_index_custom($temp_robot_tokens);
        foreach ($player_info['player_robots'] as $robot_token => $robot_info) {
            if (empty($robot_token) || !isset($temp_robot_index[$robot_token])) {
                continue;
            }
            $robot_index_info = $temp_robot_index[$robot_token];
            // Merge the robot and index info then append the token and info
            $robot_info = array_merge($robot_index_info, $robot_info);
            $allowed_edit_robots[] = $robot_token;
            $allowed_edit_data[$player_token]['player_robots'][$robot_token] = $robot_info;
            // Collect a temporary ability index
            $temp_ability_tokens = array_keys($robot_info['robot_abilities']);
            $temp_ability_index = rpg_ability::get_index_custom($temp_ability_tokens);
            foreach ($robot_info['robot_abilities'] as $ability_token => $ability_info) {
                if (empty($ability_token) || !isset($temp_ability_index[$ability_token])) {
                    continue;
                }
                $ability_index_info = $temp_ability_index[$ability_token];
                // Merge the ability and index info then append the token and info
                $ability_info = array_merge($ability_index_info, $ability_info);
                $allowed_edit_data[$player_token]['player_robots'][$robot_token]['robot_abilities'][$ability_token] = $ability_info;
            }
        }
    }
    //$allowed_edit_data = array_reverse($allowed_edit_data, true);
    $allowed_edit_player_count = !empty($allowed_edit_players) ? count($allowed_edit_players) : 0;
    $allowed_edit_robot_count = !empty($allowed_edit_robots) ? count($allowed_edit_robots) : 0;
    $allowed_edit_data_count = 0;
    foreach ($allowed_edit_data as $pinfo) {
        $pcount = !empty($pinfo['player_robots']) ? count($pinfo['player_robots']) : 0;
        $allowed_edit_data_count += $pcount;
    }
}
コード例 #11
0
ファイル: battle.php プロジェクト: AdrianMarceau/mmrpg-world
     die('<pre>$this_robot is empty on line ' . __LINE__ . '! :' . print_r($this_robot, true) . '</pre>');
 } elseif (empty($target_robot)) {
     die('<pre>$target_robot is empty on line ' . __LINE__ . '! :' . print_r($target_robot, true) . '</pre>');
 }
 // If the target's was a switch action, also queue up an ability
 if ($target_action == 'switch') {
     // Now execute the stored actions
     $this_battle->actions_execute();
     // Update the active robot reference just in case it has changed
     foreach ($target_player->player_robots as $temp_robotinfo) {
         if ($temp_robotinfo['robot_position'] == 'active') {
             $active_target_robot->robot_load($temp_robotinfo);
             $active_target_robot->robot_position = 'active';
             $active_target_robot->update_session();
         } else {
             $temp_robot = new rpg_robot($target_player, $temp_robotinfo);
             $temp_robot->robot_load($temp_robotinfo);
             $temp_robot->robot_position = 'bench';
             $temp_robot->update_session();
         }
     }
     if (empty($active_target_robot)) {
         $active_target_robot->robot_load($target_player->player_robots[0]);
         $active_target_robot->robot_position = 'active';
         $active_target_robot->update_session();
     }
     // Decide which ability this robot will use
     $target_action_token = '';
     // Check if this robot has choice data defined
     if (true) {
         // Collect the ability choice from the robot
コード例 #12
0
 public function trigger_disabled($target_robot, $this_ability, $trigger_options = array())
 {
     // Pull in the global variable
     global $mmrpg_index;
     // Import global variables
     $db = cms_database::get_database();
     $this_battle = rpg_battle::get_battle();
     $this_field = rpg_field::get_field();
     // Generate default trigger options if not set
     if (!isset($trigger_options['item_multiplier'])) {
         $trigger_options['item_multiplier'] = 1.0;
     }
     // If the battle has already ended, return false
     if (!empty($this_battle->flags['battle_complete_message_created'])) {
         return false;
     }
     // Create references to save time 'cause I'm tired
     // (rather than replace all target references to this references)
     $this_battle =& $this_battle;
     $this_player =& $this->player;
     // the player of the robot being disabled
     $this_robot =& $this;
     // the robot being disabled
     $target_player =& $target_robot->player;
     // the player of the other robot
     $target_robot =& $target_robot;
     // the other robot that isn't this one
     // If the target player is the same as the current or the target is dead
     if ($this_player->player_id == $target_player->player_id) {
         // Collect the actual target player from the battle values
         if (!empty($this_battle->values['players'])) {
             foreach ($this_battle->values['players'] as $id => $info) {
                 if ($this_player->player_id != $id) {
                     unset($target_player);
                     $target_player = new rpg_player($info);
                 }
             }
         }
         // Collect the actual target robot from the battle values
         if (!empty($target_player->values['robots_active'])) {
             foreach ($target_player->values['robots_active'] as $key => $info) {
                 if ($info['robot_position'] == 'active') {
                     $target_robot->robot_load($info);
                 }
             }
         }
     }
     // Update the target player's session
     $this_player->update_session();
     // Create the robot disabled event
     $disabled_text = in_array($this_robot->robot_token, array('dark-frag', 'dark-spire', 'dark-tower')) || $this_robot->robot_core == 'empty' ? 'destroyed' : 'disabled';
     $event_header = ($this_player->player_token != 'player' ? $this_player->player_name . '&#39;s ' : '') . $this_robot->robot_name;
     $event_body = ($this_player->player_token != 'player' ? $this_player->print_name() . '&#39;s ' : 'The target ') . ' ' . $this_robot->print_name() . ' was ' . $disabled_text . '!<br />';
     //'.($this_robot->robot_position == 'bench' ? ' and removed from battle' : '').'
     if (isset($this_robot->robot_quotes['battle_defeat'])) {
         $this_find = array('{target_player}', '{target_robot}', '{this_player}', '{this_robot}');
         $this_replace = array($target_player->player_name, $target_robot->robot_name, $this_player->player_name, $this_robot->robot_name);
         $event_body .= $this_robot->print_quote('battle_defeat', $this_find, $this_replace);
     }
     if ($target_robot->robot_status != 'disabled') {
         $target_robot->robot_frame = 'base';
     }
     $this_robot->robot_frame = 'defeat';
     $target_robot->update_session();
     $this_robot->update_session();
     $this_battle->events_create($this_robot, $target_robot, $event_header, $event_body, array('console_show_target' => false, 'canvas_show_disabled_bench' => $this_robot->robot_id . '_' . $this_robot->robot_token));
     /*
      * EFFORT VALUES / STAT BOOST BONUSES
      */
     // Define the event options array
     $event_options = array();
     $event_options['this_ability_results']['total_actions'] = 0;
     // Calculate the bonus boosts from defeating the target robot (if NOT player battle)
     if ($target_player->player_side == 'left' && $this_player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID && $target_robot->robot_status != 'disabled') {
         // Boost this robot's attack if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_attack'])) {
             $this_attack_boost = $this_robot->robot_base_attack / 100;
             //ceil($this_robot->robot_base_attack / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_attack_boost = $this_attack_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_attack_boost = $this_attack_boost * 2;
             }
             if ($target_robot->robot_attack + $this_attack_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_attack_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_attack) * -1;
                 $this_attack_boost = $this_attack_boost - $this_attack_overboost;
             }
             $this_attack_boost = round($this_attack_boost);
         } else {
             $this_attack_boost = 0;
         }
         // Boost this robot's defense if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_defense'])) {
             $this_defense_boost = $this_robot->robot_base_defense / 100;
             //ceil($this_robot->robot_base_defense / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_defense_boost = $this_defense_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_defense_boost = $this_defense_boost * 2;
             }
             if ($target_robot->robot_defense + $this_defense_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_defense_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_defense) * -1;
                 $this_defense_boost = $this_defense_boost - $this_defense_overboost;
             }
             $this_defense_boost = round($this_defense_boost);
         } else {
             $this_defense_boost = 0;
         }
         // Boost this robot's speed if a boost is in order
         if (empty($target_robot->flags['robot_stat_max_speed'])) {
             $this_speed_boost = $this_robot->robot_base_speed / 100;
             //ceil($this_robot->robot_base_speed / 100);
             if ($this_robot->robot_class == 'mecha') {
                 $this_speed_boost = $this_speed_boost / 2;
             }
             if ($target_player->player_side == 'left' && $target_robot->robot_class == 'mecha') {
                 $this_speed_boost = $this_speed_boost * 2;
             }
             if ($target_robot->robot_speed + $this_speed_boost > MMRPG_SETTINGS_STATS_MAX) {
                 $this_speed_overboost = (MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_speed) * -1;
                 $this_speed_boost = $this_speed_boost - $this_speed_overboost;
             }
             $this_speed_boost = round($this_speed_boost);
         } else {
             $this_speed_boost = 0;
         }
         // If the target robot is holding a Growth Module, double the stat bonuses
         if ($target_robot->robot_item == 'growth-module') {
             if (!$this_attack_boost) {
                 $this_attack_boost = $this_attack_boost * 2;
             }
             if (!$this_defense_boost) {
                 $this_defense_boost = $this_defense_boost * 2;
             }
             if (!$this_speed_boost) {
                 $this_speed_boost = $this_speed_boost * 2;
             }
         }
         // Define the temporary boost actions counter
         $temp_boost_actions = 1;
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_attack < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'])) {
                 $this_attack_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] = 0;
             }
         }
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_defense < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'])) {
                 $this_defense_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] = 0;
             }
         }
         // Increase reward if there are any pending stat boosts and clear session
         if ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master') && $target_robot->robot_base_speed < MMRPG_SETTINGS_STATS_MAX) {
             if (!empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'])) {
                 $this_speed_boost += $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'];
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] = 0;
             }
         }
         // If the attack boost was not empty, process it
         if ($this_attack_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack_pending'] += $this_attack_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_attack < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base attack boost based on robot base stats
                 $temp_attack_boost = ceil($this_attack_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_attack_boost + $target_robot->robot_attack > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_attack_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_attack;
                 }
                 // Increment this robot's attack by the calculated amount and display an event
                 $target_robot->robot_attack = ceil($target_robot->robot_attack + $temp_attack_boost);
                 $target_robot->robot_base_attack = ceil($target_robot->robot_base_attack + $temp_attack_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'attack';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_attack_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads weapons data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s attack grew by <span class="recovery_amount">' . $temp_attack_boost . '</span>! ';
                 $target_robot->robot_frame = 'shoot';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack']);
                     $temp_attack_session_boost = round($this_attack_boost);
                     if ($temp_attack_session_boost < 1) {
                         $temp_attack_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_attack'] += $temp_attack_session_boost;
                 }
             }
         }
         // If the defense boost was not empty, process it
         if ($this_defense_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense_pending'] += $this_defense_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_defense < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base defense boost based on robot base stats
                 $temp_defense_boost = ceil($this_defense_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_defense_boost + $target_robot->robot_defense > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_defense_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_defense;
                 }
                 // Increment this robot's defense by the calculated amount and display an event
                 $target_robot->robot_defense = ceil($target_robot->robot_defense + $temp_defense_boost);
                 $target_robot->robot_base_defense = ceil($target_robot->robot_base_defense + $temp_defense_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'defense';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_defense_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads shield data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s defense grew by <span class="recovery_amount">' . $temp_defense_boost . '</span>! ';
                 $target_robot->robot_frame = 'defend';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense']);
                     $temp_defense_session_boost = round($this_defense_boost);
                     if ($temp_defense_session_boost < 1) {
                         $temp_defense_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_defense'] += $temp_defense_session_boost;
                 }
             }
         }
         // If the speed boost was not empty, process it
         if ($this_speed_boost > 0) {
             // If the robot is under level 100, stat boosts are pending
             if ($target_player->player_side == 'left' && $target_robot->robot_level < 100 && $target_robot->robot_class == 'master') {
                 // Update the session variables with the pending stat boost
                 if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed_pending'] += $this_speed_boost;
             } elseif ($target_player->player_side == 'left' && ($target_robot->robot_level == 100 && $target_robot->robot_class == 'master' || $target_robot->robot_class == 'mecha') && $target_robot->robot_base_speed < MMRPG_SETTINGS_STATS_MAX) {
                 // Define the base speed boost based on robot base stats
                 $temp_speed_boost = ceil($this_speed_boost);
                 // If this action would boost the robot over their stat limits
                 if ($temp_speed_boost + $target_robot->robot_speed > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_speed_boost = MMRPG_SETTINGS_STATS_MAX - $target_robot->robot_speed;
                 }
                 // Increment this robot's speed by the calculated amount and display an event
                 $target_robot->robot_speed = ceil($target_robot->robot_speed + $temp_speed_boost);
                 $target_robot->robot_base_speed = ceil($target_robot->robot_base_speed + $temp_speed_boost);
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'speed';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_speed_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = $temp_boost_actions++;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $target_robot->robot_id . '_' . $target_robot->robot_token;
                 $event_options['console_show_target'] = false;
                 $event_body = $target_robot->print_name() . ' downloads mobility data from the target robot! ';
                 $event_body .= '<br />';
                 $event_body .= $target_robot->print_name() . '&#39;s speed grew by <span class="recovery_amount">' . $temp_speed_boost . '</span>! ';
                 $target_robot->robot_frame = 'slide';
                 $target_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($target_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the session variables with the rewarded stat boost if not mecha
                 if ($target_robot->robot_class == 'master') {
                     if (empty($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] = 0;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] = ceil($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed']);
                     $temp_speed_session_boost = round($this_speed_boost);
                     if ($temp_speed_session_boost < 1) {
                         $temp_speed_session_boost = 1;
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$target_robot->robot_token]['robot_speed'] += $temp_speed_session_boost;
                 }
             }
         }
         // Update the target robot frame
         $target_robot->robot_frame = 'base';
         $target_robot->update_session();
     }
     // Ensure player and robot variables are updated
     $target_robot->update_session();
     $target_player->update_session();
     $this_robot->update_session();
     $this_player->update_session();
     /*
     // DEBUG
     $this_battle->events_create(false, false, 'DEBUG', 'we made it past the stat boosts... <br />'.
         '$this_robot->robot_token='.$this_robot->robot_token.'; $target_robot->robot_token='.$target_robot->robot_token.';<br />'.
         '$target_player->player_token='.$target_player->player_token.'; $target_player->player_side='.$target_player->player_side.';<br />'
         );
     */
     /*
      * ITEM REWARDS / EXPERIENCE POINTS / LEVEL UP
      * Reward the player and robots with items and experience if not in demo mode
      */
     if ($target_player->player_side == 'left' && $this_player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID && rpg_game::is_user()) {
         // -- EXPERIENCE POINTS / LEVEL UP -- //
         // Filter out robots who were active in this battle in at least some way
         $temp_robots_active = $target_player->values['robots_active'];
         usort($temp_robots_active, array('rpg_functions', 'robot_sort_by_active'));
         // Define the boost multiplier and start out at zero
         $temp_boost_multiplier = 0;
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $this_robot->counters = <pre>'.print_r($this_robot->counters, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         // If the target has had any damage flags triggered, update the multiplier
         //if ($this_robot->flags['triggered_immunity']){ $temp_boost_multiplier += 0; }
         //if (!empty($this_robot->flags['triggered_resistance'])){ $temp_boost_multiplier -= $this_robot->counters['triggered_resistance'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_affinity'])){ $temp_boost_multiplier -= $this_robot->counters['triggered_affinity'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_weakness'])){ $temp_boost_multiplier += $this_robot->counters['triggered_weakness'] * 0.10; }
         //if (!empty($this_robot->flags['triggered_critical'])){ $temp_boost_multiplier += $this_robot->counters['triggered_critical'] * 0.10; }
         // If we're in DEMO mode, give a 100% experience boost
         //if (rpg_game::is_demo()){ $temp_boost_multiplier += 1; }
         // Ensure the multiplier has not gone below 100%
         if ($temp_boost_multiplier < -0.99) {
             $temp_boost_multiplier = -0.99;
         } elseif ($temp_boost_multiplier > 0.99) {
             $temp_boost_multiplier = 0.99;
         }
         // Define the boost text to match the multiplier
         $temp_boost_text = '';
         if ($temp_boost_multiplier < 0) {
             $temp_boost_text = 'a lowered ';
         } elseif ($temp_boost_multiplier > 0) {
             $temp_boost_text = 'a boosted ';
         }
         /*
         $event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.'<pre>'.print_r($this_robot->flags, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         
         $event_body = preg_replace('/\s+/', ' ', $target_robot->robot_token.'<pre>'.print_r($target_robot->flags, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         */
         // Define the base experience for the target robot
         $temp_experience = $this_robot->robot_base_energy + $this_robot->robot_base_attack + $this_robot->robot_base_defense + $this_robot->robot_base_speed;
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_boost_multiplier = '.$temp_boost_multiplier.'; $temp_experience = '.$temp_experience.'; ');
         //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $event_body);
         // Apply any boost multipliers to the experience earned
         if ($temp_boost_multiplier > 0 || $temp_boost_multiplier < 0) {
             $temp_experience += $temp_experience * $temp_boost_multiplier;
         }
         if ($temp_experience <= 0) {
             $temp_experience = 1;
         }
         $temp_experience = round($temp_experience);
         $temp_target_experience = array('level' => $this_robot->robot_level, 'experience' => $temp_experience);
         // DEBUG
         //$event_body = preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_target_experience = <pre>'.print_r($temp_target_experience, true).'</pre>');
         //$this_battle->events_create(false, false, 'DEBUG', $event_body);
         // Define the robot experience level and start at zero
         $target_robot_experience = 0;
         // Sort the active robots based on active or not
         /*
         function mmrpg_sort_temp_active_robots($info1, $info2){
             if ($info1['robot_position'] == 'active'){ return -1; }
             else { return 1; }
         }
         usort($temp_robots_active, 'mmrpg_sort_temp_active_robots');
         */
         // If the target was defeated with overkill, add it to the battle var
         if (!empty($this_robot->counters['defeat_overkill'])) {
             $overkill_bonus = $this_robot->counters['defeat_overkill'];
             //$overkill_bonus = $overkill_bonus - ceil($overkill_bonus * 0.90);
             //$overkill_divider = $target_robot->robot_level >= 100 ? 0.01 : (100 - $target_robot->robot_level) / 100;
             //$overkill_bonus = floor($overkill_bonus * $overkill_divider);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_battle->battle_overkill' => $this_battle->battle_overkill, '$this_battle->battle_rewards_zenny' => $this_battle->battle_rewards_zenny), true)).'</pre>', $event_options);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$overkill_bonus' => $overkill_bonus), true)).'</pre>', $event_options);
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_robot->robot_base_total' => $this_robot->robot_base_total, '$target_robot->robot_base_total' => $target_robot->robot_base_total), true)).'</pre>', $event_options);
             //if ($target_robot->robot_base_total > $this_robot->robot_base_total){ $overkill_bonus = floor($overkill_bonus * ($this_robot->robot_base_total / $target_robot->robot_base_total));   }
             //elseif ($target_robot->robot_base_total < $this_robot->robot_base_total){ $overkill_bonus = floor($overkill_bonus * ($target_robot->robot_base_total / $this_robot->robot_base_total));   }
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$overkill_bonus' => $overkill_bonus), true)).'</pre>', $event_options);
             $this_battle->battle_overkill += $this_robot->counters['defeat_overkill'];
             if (empty($this_battle->flags['starter_battle'])) {
                 $this_battle->battle_rewards_zenny += $overkill_bonus;
             }
             $this_battle->update_session();
             //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r(array('$this_battle->battle_overkill' => $this_battle->battle_overkill, '$this_battle->battle_rewards_zenny' => $this_battle->battle_rewards_zenny), true)).'</pre>', $event_options);
         }
         // Increment each of this player's robots
         $temp_robots_active_num = count($temp_robots_active);
         $temp_robots_active_num2 = $temp_robots_active_num;
         // This will be decremented for each non-experience gaining level 100 robots
         $temp_robots_active = array_reverse($temp_robots_active, true);
         usort($temp_robots_active, array('rpg_functions', 'robot_sort_by_active'));
         $temp_robot_active_position = false;
         foreach ($temp_robots_active as $temp_id => $temp_info) {
             $temp_robot = $target_robot->robot_id == $temp_info['robot_id'] ? $target_robot : new rpg_robot($target_player, $temp_info);
             if ($temp_robot->robot_level >= 100 || $temp_robot->robot_class != 'master') {
                 $temp_robots_active_num2--;
             }
             if ($temp_robot->robot_position == 'active') {
                 $temp_robot_active_position = $temp_robots_active[$temp_id];
                 unset($temp_robots_active[$temp_id]);
             }
         }
         $temp_unshift = array_unshift($temp_robots_active, $temp_robot_active_position);
         foreach ($temp_robots_active as $temp_id => $temp_info) {
             // Collect or define the robot points and robot rewards variables
             $temp_robot = $target_robot->robot_id == $temp_info['robot_id'] ? $target_robot : new rpg_robot($target_player, $temp_info);
             //if ($temp_robot->robot_class == 'mecha'){ continue; }
             $temp_robot_token = $temp_info['robot_token'];
             if ($temp_robot_token == 'robot') {
                 continue;
             }
             $temp_robot_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
             $temp_robot_rewards = !empty($temp_info['robot_rewards']) ? $temp_info['robot_rewards'] : array();
             if (empty($temp_robots_active_num2)) {
                 break;
             }
             // Continue if over already at level 100
             //if ($temp_robot->robot_level >= 100){ continue; }
             // Reset the robot experience points to zero
             $target_robot_experience = 0;
             // Continue with experience mods only if under level 100
             if ($temp_robot->robot_level < 100 && $temp_robot->robot_class == 'master') {
                 // Give a proportionate amount of experience based on this and the target robot's levels
                 if ($temp_robot->robot_level == $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'];
                 } elseif ($temp_robot->robot_level < $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'] + round(($temp_target_experience['level'] - $temp_robot->robot_level) / 100 * $temp_target_experience['experience']);
                     //$temp_experience_boost = $temp_target_experience['experience'] + ((($temp_target_experience['level']) / $temp_robot->robot_level) * $temp_target_experience['experience']);
                 } elseif ($temp_robot->robot_level > $temp_target_experience['level']) {
                     $temp_experience_boost = $temp_target_experience['experience'] - round(($temp_robot->robot_level - $temp_target_experience['level']) / 100 * $temp_target_experience['experience']);
                     //$temp_experience_boost = $temp_target_experience['experience'] - ((($temp_robot->robot_level - $temp_target_experience['level']) / 100) * $temp_target_experience['experience']);
                 }
                 // DEBUG
                 //$event_body = 'START EXPERIENCE | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 //$temp_experience_boost = ceil($temp_experience_boost / 10);
                 $temp_experience_boost = ceil($temp_experience_boost / $temp_robots_active_num);
                 //$temp_experience_boost = ceil($temp_experience_boost / ($temp_robots_active_num * 2));
                 //$temp_experience_boost = ceil($temp_experience_boost / ($temp_robots_active_num2 * 2));
                 //$temp_experience_boost = ceil(($temp_experience_boost / $temp_robots_active_num2) * 1.00);
                 if ($temp_experience_boost > MMRPG_SETTINGS_STATS_MAX) {
                     $temp_experience_boost = MMRPG_SETTINGS_STATS_MAX;
                 }
                 $target_robot_experience += $temp_experience_boost;
                 // DEBUG
                 //$event_body = 'ACTIVE ROBOT DIVISION | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robots_active_num = '.$temp_robots_active_num.'; $temp_robots_active_num2 = '.$temp_robots_active_num2.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 // If this robot has been traded, give it an additional experience boost
                 $temp_experience_boost = 0;
                 $temp_robot_boost_text = $temp_boost_text;
                 $temp_player_boosted = false;
                 if ($temp_robot->player_token != $temp_robot->robot_original_player) {
                     $temp_player_boosted = true;
                     $temp_robot_boost_text = 'a player boosted ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = $target_robot_experience * 2;
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     // DEBUG
                     //$event_body = 'PLAYER BOOSTED | ';
                     //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robot->player_token('.$temp_robot->player_token.') != $temp_robot->robot_original_player('.$temp_robot->robot_original_player.'); ');
                     //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 }
                 // If the target robot is holding a Growth Module, double the experience bonus
                 if ($temp_robot->robot_item == 'growth-module') {
                     $temp_robot_boost_text = $temp_player_boosted ? 'a player and module boosted ' : 'a module boosted ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = $target_robot_experience * 2;
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     // DEBUG
                     //$event_body = 'MODULE BOOSTED | ';
                     //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; $temp_robot->robot_item = '.$temp_robot->robot_item.'; ');
                     //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 }
                 // If there are field multipliers in place, apply them now
                 $temp_experience_boost = 0;
                 if (isset($this->field->field_multipliers['experience'])) {
                     //$temp_robot_boost_text = '(and '.$target_robot_experience.' multiplied by '.number_format($this->field->field_multipliers['experience'], 1).') ';
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience = ceil($target_robot_experience * $this->field->field_multipliers['experience']);
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                 }
                 // DEBUG
                 //$event_body = 'FIELD MULTIPLIERS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 /*
                 // If this robot has any overkill, add that to the temp experience modifier
                 $temp_experience_boost = 0;
                 if (!empty($this_robot->counters['defeat_overkill'])){
                     if (empty($temp_robot_boost_text)){ $temp_robot_boost_text = 'an overkill boosted '; }
                     else { $temp_robot_boost_text = 'a player and overkill boosted '; }
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience += ceil($this_robot->counters['defeat_overkill'] / $temp_robots_active_num2);
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                     //$this_battle->battle_overkill += $this_robot->counters['defeat_overkill'];
                     //$this_battle->update_session();
                     //$temp_robot_boost_text .= 'umm '.$this_battle->battle_overkill;
                 }
                 */
                 // DEBUG
                 //$event_body = 'OVERKILL BONUS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $this_robot->robot_token.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 /*
                 // If the target robot's core type has been boosted by starforce
                 if (!empty($temp_robot->robot_core) && !empty($_SESSION['GAME']['values']['star_force'][$temp_robot->robot_core])){
                     if (empty($temp_robot_boost_text)){ $temp_robot_boost_text = 'a starforce boosted '; }
                     elseif ($temp_robot_boost_text == 'an overkill boosted '){ $temp_robot_boost_text = 'an overkill and starforce boosted '; }
                     elseif ($temp_robot_boost_text == 'a player boosted '){ $temp_robot_boost_text = 'a player and starforce boosted '; }
                     else { $temp_robot_boost_text = 'a player, overkill, and starforce boosted '; }
                     $temp_starforce = $_SESSION['GAME']['values']['star_force'][$temp_robot->robot_core];
                     $temp_experience_bak = $target_robot_experience;
                     $target_robot_experience += ceil($target_robot_experience * ($temp_starforce / 10));
                     $temp_experience_boost = $target_robot_experience - $temp_experience_bak;
                 }
                 */
                 // DEBUG
                 //$event_body = 'STARFORCE BONUS | ';
                 //$event_body .= preg_replace('/\s+/', ' ', $temp_robot->robot_token.' : '.$temp_robot->robot_core.' : $temp_experience_boost = '.$temp_experience_boost.'; $target_robot_experience = '.$target_robot_experience.'; ');
                 //$this_battle->events_create(false, false, 'DEBUG', $event_body);
                 // If the experience is greater then the max, level it off at the max (sorry guys!)
                 if ($target_robot_experience > MMRPG_SETTINGS_STATS_MAX) {
                     $target_robot_experience = MMRPG_SETTINGS_STATS_MAX;
                 }
                 if ($target_robot_experience < MMRPG_SETTINGS_STATS_MIN) {
                     $target_robot_experience = MMRPG_SETTINGS_STATS_MIN;
                 }
                 // Collect the robot's current experience and level for reference later
                 $temp_start_experience = rpg_game::robot_experience($target_player->player_token, $temp_robot_token);
                 $temp_start_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
                 // Increment this robots's points total with the battle points
                 if (!isset($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] = 1;
                 }
                 if (!isset($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'])) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] = 0;
                 }
                 $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] += $target_robot_experience;
                 // Define the new experience for this robot
                 $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 $temp_new_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
                 // If the new experience is over the required, level up the robot
                 $level_boost = 0;
                 if ($temp_new_experience > $temp_required_experience) {
                     //$level_boost = floor($temp_new_experience / $temp_required_experience);
                     while ($temp_new_experience > $temp_required_experience) {
                         $level_boost += 1;
                         $temp_new_experience -= $temp_required_experience;
                         $temp_required_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level + $level_boost);
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] += $level_boost;
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_experience'] = $temp_new_experience;
                     //$level_boost * $temp_required_experience;
                     if ($_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] > 100) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_level'] = 100;
                     }
                     $temp_new_experience = rpg_game::robot_experience($target_player->player_token, $temp_info['robot_token']);
                 }
                 // Define the new level for this robot
                 $temp_new_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
             } else {
                 // Collect the robot's current experience and level for reference later
                 $temp_start_experience = rpg_game::robot_experience($target_player->player_token, $temp_robot_token);
                 $temp_start_level = rpg_game::robot_level($target_player->player_token, $temp_robot_token);
                 // Define the new experience for this robot
                 $temp_new_experience = $temp_start_experience;
                 $temp_new_level = $temp_start_level;
             }
             // Define the event options
             $event_options = array();
             $event_options['this_ability_results']['trigger_kind'] = 'recovery';
             $event_options['this_ability_results']['recovery_kind'] = 'experience';
             $event_options['this_ability_results']['recovery_type'] = '';
             $event_options['this_ability_results']['this_amount'] = $target_robot_experience;
             $event_options['this_ability_results']['this_result'] = 'success';
             $event_options['this_ability_results']['flag_affinity'] = true;
             $event_options['this_ability_results']['total_actions'] = 1;
             $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
             $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
             // Update player/robot frames and points for the victory
             $temp_robot->robot_frame = 'victory';
             $temp_robot->robot_level = $temp_new_level;
             $temp_robot->robot_experience = $temp_new_experience;
             $target_player->set_frame('victory');
             $temp_robot->update_session();
             // Only display the event if the player is under level 100
             if ($temp_robot->robot_level < 100 && $temp_robot->robot_class == 'master') {
                 // Display the win message for this robot with battle points
                 $temp_robot->robot_frame = 'taunt';
                 $temp_robot->robot_level = $temp_new_level;
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 }
                 $target_player->set_frame('victory');
                 $event_header = $temp_robot->robot_name . '&#39;s Rewards';
                 $event_multiplier_text = $temp_robot_boost_text;
                 $event_body = $temp_robot->print_name() . ' collects ' . $event_multiplier_text . '<span class="recovery_amount ability_type ability_type_cutter">' . $target_robot_experience . '</span> experience points! ';
                 $event_body .= '<br />';
                 if (isset($temp_robot->robot_quotes['battle_victory'])) {
                     $this_find = array('{target_player}', '{target_robot}', '{this_player}', '{this_robot}');
                     $this_replace = array($this_player->player_name, $this_robot->robot_name, $target_player->player_name, $temp_robot->robot_name);
                     $event_body .= $temp_robot->print_quote('battle_victory', $this_find, $this_replace);
                 }
                 //$event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $event_options['this_body_float'] = $target_player->player_side;
                 $temp_robot->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = $temp_new_experience;
                 }
                 if ($temp_robot->robot_core == 'copy') {
                     $temp_robot->robot_image = $temp_robot->robot_base_image;
                     $temp_robot->robot_image_overlay = array();
                 }
                 $temp_robot->update_session();
                 $target_player->update_session();
             }
             // Floor the robot's experience with or without the event
             $target_player->set_frame('victory');
             $temp_robot->robot_frame = 'base';
             if ($temp_start_level != $temp_new_level) {
                 $temp_robot->robot_experience = 0;
             }
             $temp_robot->update_session();
             // If the level has been boosted, display the stat increases
             if ($temp_start_level != $temp_new_level) {
                 // Define the event options
                 $event_options = array();
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_kind'] = 'level';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['flag_affinity'] = true;
                 $event_options['this_ability_results']['flag_critical'] = true;
                 $event_options['this_ability_results']['this_amount'] = $temp_new_level - $temp_start_level;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = 2;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                 // Display the win message for this robot with battle points
                 $temp_robot->robot_frame = 'taunt';
                 $temp_robot->robot_level = $temp_new_level;
                 if ($temp_start_level != $temp_new_level) {
                     $temp_robot->robot_experience = rpg_prototype::calculate_experience_required($temp_robot->robot_level);
                 } else {
                     $temp_robot->robot_experience = $temp_new_experience;
                 }
                 $target_player->set_frame('victory');
                 $event_header = $temp_robot->robot_name . '&#39;s Rewards';
                 //$event_body = $temp_robot->print_name().' grew to <span class="recovery_amount'.($temp_new_level >= 100 ? ' ability_type ability_type_electric' : '').'">Level '.$temp_new_level.'</span>!<br /> ';
                 $event_body = $temp_robot->print_name() . ' grew to <span class="recovery_amount ability_type ability_type_level">Level ' . $temp_new_level . ($temp_new_level >= 100 ? ' &#9733;' : '') . '</span>!<br /> ';
                 $event_body .= $temp_robot->robot_name . '&#39;s energy, weapons, shields, and mobility were upgraded!';
                 //$event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $event_options['this_body_float'] = $target_player->player_side;
                 $temp_robot->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 $temp_robot->robot_experience = 0;
                 $temp_robot->update_session();
                 // Collect the base robot template from the index for calculations
                 $temp_index_robot = rpg_robot::get_index_info($temp_robot->robot_token);
                 // Define the event options
                 $event_options['this_ability_results']['trigger_kind'] = 'recovery';
                 $event_options['this_ability_results']['recovery_type'] = '';
                 $event_options['this_ability_results']['this_amount'] = $this_defense_boost;
                 $event_options['this_ability_results']['this_result'] = 'success';
                 $event_options['this_ability_results']['total_actions'] = 0;
                 $event_options['this_ability_user'] = $this->robot_id . '_' . $this->robot_token;
                 $event_options['this_ability_target'] = $temp_robot->robot_id . '_' . $temp_robot->robot_token;
                 // Update the robot rewards array with any recent info
                 $temp_robot_rewards = rpg_game::robot_rewards($target_player->player_token, $temp_robot->robot_token);
                 //$this_battle->events_create(false, false, 'DEBUG', '<pre>'.preg_replace('/\s+/', ' ', print_r($temp_robot_rewards, true)).'</pre>', $event_options);
                 // Define the base energy boost based on robot base stats
                 $temp_energy_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_energy']));
                 // If this robot has reached level 100, the max level, create the flag in their session
                 if ($temp_new_level >= 100) {
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['flags']['reached_max_level'] = true;
                 }
                 // Check if there are eny pending energy stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_energy_pending'])) {
                     $temp_robot_rewards['robot_energy_pending'] = round($temp_robot_rewards['robot_energy_pending']);
                     $temp_energy_boost += $temp_robot_rewards['robot_energy_pending'];
                     if (!empty($temp_robot_rewards['robot_energy'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy'] += $temp_robot_rewards['robot_energy_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy'] = $temp_robot_rewards['robot_energy_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_energy_pending'] = 0;
                 }
                 // Increment this robot's energy by the calculated amount and display an event
                 $temp_robot->robot_energy += $temp_energy_boost;
                 $temp_base_energy_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_energy']));
                 $temp_robot->robot_base_energy += $temp_base_energy_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'energy';
                 $event_options['this_ability_results']['this_amount'] = $temp_energy_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s health improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s energy grew by <span class="recovery_amount">' . $temp_energy_boost . '</span>! ';
                 $temp_robot->robot_frame = 'summon';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base attack boost based on robot base stats
                 $temp_attack_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_attack']));
                 // Check if there are eny pending attack stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_attack_pending'])) {
                     $temp_robot_rewards['robot_attack_pending'] = round($temp_robot_rewards['robot_attack_pending']);
                     $temp_attack_boost += $temp_robot_rewards['robot_attack_pending'];
                     if (!empty($temp_robot_rewards['robot_attack'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack'] += $temp_robot_rewards['robot_attack_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack'] = $temp_robot_rewards['robot_attack_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_attack_pending'] = 0;
                 }
                 // Increment this robot's attack by the calculated amount and display an event
                 $temp_robot->robot_attack += $temp_attack_boost;
                 $temp_base_attack_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_attack']));
                 $temp_robot->robot_base_attack += $temp_base_attack_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'attack';
                 $event_options['this_ability_results']['this_amount'] = $temp_attack_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s weapons improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s attack grew by <span class="recovery_amount">' . $temp_attack_boost . '</span>! ';
                 $temp_robot->robot_frame = 'shoot';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base defense boost based on robot base stats
                 $temp_defense_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_defense']));
                 // Check if there are eny pending defense stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_defense_pending'])) {
                     $temp_robot_rewards['robot_defense_pending'] = round($temp_robot_rewards['robot_defense_pending']);
                     $temp_defense_boost += $temp_robot_rewards['robot_defense_pending'];
                     if (!empty($temp_robot_rewards['robot_defense'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense'] += $temp_robot_rewards['robot_defense_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense'] = $temp_robot_rewards['robot_defense_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_defense_pending'] = 0;
                 }
                 // Increment this robot's defense by the calculated amount and display an event
                 $temp_robot->robot_defense += $temp_defense_boost;
                 $temp_base_defense_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_defense']));
                 $temp_robot->robot_base_defense += $temp_base_defense_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'defense';
                 $event_options['this_ability_results']['this_amount'] = $temp_defense_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $event_body = $temp_robot->print_name() . '&#39;s shields improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s defense grew by <span class="recovery_amount">' . $temp_defense_boost . '</span>! ';
                 $temp_robot->robot_frame = 'defend';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Define the base speed boost based on robot base stats
                 $temp_speed_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_speed']));
                 // Check if there are eny pending speed stat boosts for level up
                 if (!empty($temp_robot_rewards['robot_speed_pending'])) {
                     $temp_robot_rewards['robot_speed_pending'] = round($temp_robot_rewards['robot_speed_pending']);
                     $temp_speed_boost += $temp_robot_rewards['robot_speed_pending'];
                     if (!empty($temp_robot_rewards['robot_speed'])) {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_speed'] += $temp_robot_rewards['robot_speed_pending'];
                     } else {
                         $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot->robot_token]['robot_speed'] = $temp_robot_rewards['robot_speed_pending'];
                     }
                     $_SESSION['GAME']['values']['battle_rewards'][$target_player->player_token]['player_robots'][$temp_robot_token]['robot_speed_pending'] = 0;
                 }
                 // Increment this robot's speed by the calculated amount and display an event
                 $temp_robot->robot_speed += $temp_speed_boost;
                 $event_options['this_ability_results']['recovery_kind'] = 'speed';
                 $event_options['this_ability_results']['this_amount'] = $temp_speed_boost;
                 $event_options['this_ability_results']['total_actions']++;
                 $temp_base_speed_boost = ceil($level_boost * (0.05 * $temp_index_robot['robot_speed']));
                 $temp_robot->robot_base_speed += $temp_base_speed_boost;
                 $event_body = $temp_robot->print_name() . '&#39;s mobility improved! ';
                 $event_body .= '<br />';
                 $event_body .= $temp_robot->print_name() . '&#39;s speed grew by <span class="recovery_amount">' . $temp_speed_boost . '</span>! ';
                 $temp_robot->robot_frame = 'slide';
                 $temp_robot->update_session();
                 $target_player->update_session();
                 $this_battle->events_create($temp_robot, $this_robot, $event_header, $event_body, $event_options);
                 // Update the robot frame
                 $temp_robot->robot_frame = 'base';
                 $temp_robot->update_session();
             }
             // Update the experience level for real this time
             $temp_robot->robot_experience = $temp_new_experience;
             $temp_robot->update_session();
             // Collect the robot info array
             $temp_robot_info = $temp_robot->export_array();
             // Collect the indexed robot rewards for new abilities
             $index_robot_rewards = $temp_robot_info['robot_rewards'];
             //$event_body = preg_replace('/\s+/', ' ', '<pre>'.print_r($index_robot_rewards, true).'</pre>');
             //$this_battle->events_create(false, false, 'DEBUG', $event_body);
             // Loop through the ability rewards for this robot if set
             if ($temp_robot->robot_class != 'mecha' && ($temp_start_level == 100 || $temp_start_level != $temp_new_level && !empty($index_robot_rewards['abilities']))) {
                 $temp_abilities_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
                 foreach ($index_robot_rewards['abilities'] as $ability_reward_key => $ability_reward_info) {
                     // If the ability does not exist or is otherwise incomplete, continue
                     if (!isset($temp_abilities_index[$ability_reward_info['token']])) {
                         continue;
                     }
                     // If this ability is already unlocked, continue
                     if (rpg_game::ability_unlocked($target_player->player_token, $temp_robot_token, $ability_reward_info['token'])) {
                         continue;
                     }
                     // If we're in DEMO mode, continue
                     if (rpg_game::is_demo()) {
                         continue;
                     }
                     // Check if the required level has been met by this robot
                     if ($temp_new_level >= $ability_reward_info['level']) {
                         // Create the temporary ability object for event creation
                         $temp_ability_info = array('ability_id' => MMRPG_SETTINGS_BATTLEABILITIES_PERROBOT_MAX + $ability_reward_key, 'ability_token' => $ability_reward_info['token']);
                         $temp_ability = new rpg_ability($target_player, $temp_robot, $temp_ability_info);
                         // Collect or define the ability variables
                         $temp_ability_token = $ability_reward_info['token'];
                         // Display the robot reward message markup
                         $event_header = $temp_ability->ability_name . ' Unlocked';
                         $event_body = '<span class="robot_name">' . $temp_info['robot_name'] . '</span> unlocked new ability data!<br />';
                         $event_body .= $temp_ability->print_name() . ' can now be used in battle!';
                         $event_options = array();
                         $event_options['console_show_target'] = false;
                         $event_options['this_header_float'] = $target_player->player_side;
                         $event_options['this_body_float'] = $target_player->player_side;
                         $event_options['this_ability'] = $temp_ability;
                         $event_options['this_ability_image'] = 'icon';
                         $event_options['console_show_this_player'] = false;
                         $event_options['console_show_this_robot'] = false;
                         $event_options['console_show_this_ability'] = true;
                         $event_options['canvas_show_this_ability'] = false;
                         $temp_robot->robot_frame = $ability_reward_key % 2 == 2 ? 'taunt' : 'victory';
                         $temp_robot->update_session();
                         $temp_ability->ability_frame = 'base';
                         $temp_ability->update_session();
                         $this_battle->events_create($temp_robot, false, $event_header, $event_body, $event_options);
                         $temp_robot->robot_frame = 'base';
                         $temp_robot->update_session();
                         // Automatically unlock this ability for use in battle
                         $this_reward = rpg_ability::get_index_info($temp_ability_token);
                         //array('ability_token' => $temp_ability_token);
                         $temp_player_info = $target_player->export_array();
                         $show_event = !rpg_game::ability_unlocked('', '', $temp_ability_token) ? true : false;
                         rpg_game::unlock_ability($temp_player_info, $temp_robot_info, $this_reward, $show_event);
                         if ($temp_robot_info['robot_original_player'] == $temp_player_info['player_token']) {
                             rpg_game::unlock_ability($temp_player_info, false, $this_reward);
                         } else {
                             rpg_game::unlock_ability(array('player_token' => $temp_robot_info['robot_original_player']), false, $this_reward);
                         }
                         //$_SESSION['GAME']['values']['battle_rewards'][$target_player_token]['player_robots'][$temp_robot_token]['robot_abilities'][$temp_ability_token] = $this_reward;
                     }
                 }
             }
         }
         // -- ITEM REWARDS -- //
         // Define the temp player rewards array
         $target_player_rewards = array();
         // Define the chance multiplier and start at one
         $temp_chance_multiplier = $trigger_options['item_multiplier'];
         // Increase the item chance multiplier if one is set for the stage
         if (isset($this_battle->field->field_multipliers['items'])) {
             $temp_chance_multiplier = $temp_chance_multiplier * $this_battle->field->field_multipliers['items'];
         }
         // Define the available item drops for this battle
         $target_player_rewards['items'] = $this_battle->get_item_rewards();
         // Increase the multipliers if starter battle
         if (!empty($this_battle->flags['starter_battle'])) {
             $temp_chance_multiplier = 4;
         } else {
             // If the target holds a Fortune Module, increase the chance of dropps
             $temp_fortune_module = false;
             if ($target_robot->robot_item == 'fortune-module') {
                 $temp_fortune_module = true;
             }
             // If this robot was a MECHA class, it may drop SMALL SCREWS
             if ($this_robot->robot_class == 'mecha') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'small-screw', 'quantity' => mt_rand(1, $temp_fortune_module ? 9 : 6));
                 // If this robot was an empty core, it drops other items too
                 if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                     $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'super-pellet');
                 }
             }
             // If this robot was a MASTER class, it may drop LARGE SCREWS
             if ($this_robot->robot_class == 'master') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'large-screw', 'quantity' => mt_rand(1, $temp_fortune_module ? 6 : 3));
                 // If this robot was an empty core, it drops other items too
                 if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                     $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'super-capsule');
                 }
             }
             // If this robot was a BOSS class, it may drop EXTRA LIFE
             if ($this_robot->robot_class == 'boss') {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => 'extra-life', 'quantity' => mt_rand(1, $temp_fortune_module ? 3 : 1));
             }
             // If this robot was holding an ITEM, it should also drop that at a high rate
             if (!empty($this_robot->robot_item)) {
                 $target_player_rewards['items'][] = array('chance' => 100, 'token' => $this_robot->robot_item);
             }
         }
         // Precount the item values for later use
         $temp_value_total = 0;
         $temp_count_total = 0;
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $temp_value_total += $item_reward_info['chance'];
             $temp_count_total += 1;
         }
         //$this_battle->events_create(false, false, 'DEBUG', '$temp_count_total = '.$temp_count_total.';<br /> $temp_value_total = '.$temp_value_total.'; ');
         // If this robot was a MECHA class and destroyed by WEAKNESS, it may drop a SHARD
         if ($this_robot->robot_class == 'mecha' && !empty($this_robot->flags['triggered_weakness'])) {
             $temp_shard_type = !empty($this->robot_core) ? $this->robot_core : 'none';
             $target_player_rewards['items'] = array();
             $target_player_rewards['items'][] = array('chance' => 100, 'token' => $temp_shard_type . '-shard');
         } elseif (in_array($this_robot->robot_class, array('master', 'boss')) && !empty($this_robot->flags['triggered_weakness'])) {
             $temp_core_type = !empty($this->robot_core) ? $this->robot_core : 'none';
             $target_player_rewards['items'] = array();
             $target_player_rewards['items'][] = array('chance' => 100, 'token' => $temp_core_type . '-core');
         }
         // Recount the item values for later use
         $temp_value_total = 0;
         $temp_count_total = 0;
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $temp_value_total += $item_reward_info['chance'];
             $temp_count_total += 1;
         }
         // Adjust item values for easier to understand percentages
         foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
             $target_player_rewards['items'][$item_reward_key]['chance'] = ceil($item_reward_info['chance'] / $temp_value_total * 100);
         }
         // Shuffle the rewards so it doesn't look to formulaic
         shuffle($target_player_rewards['items']);
         // DEBUG
         //$temp_string = '';
         //foreach ($target_player_rewards['items'] AS $info){ $temp_string .= $info['token'].' = '.$info['chance'].'%, '; }
         //$this_battle->events_create(false, false, 'DEBUG', '$target_player_rewards[\'items\'] = '.count($target_player_rewards['items']).'<br /> '.$temp_string);
         // Define a function for dealing with item drops
         if (!function_exists('temp_player_rewards_items')) {
             function temp_player_rewards_items($this_battle, $target_player, $target_robot, $this_robot, $item_reward_key, $item_reward_info, $item_drop_count = 1)
             {
                 global $mmrpg_index;
                 // Create the temporary ability object for event creation
                 $temp_info = array('ability_id' => MMRPG_SETTINGS_BATTLEABILITIES_PERROBOT_MAX + $item_reward_key + 300, 'ability_token' => $item_reward_info['ability_token']);
                 $temp_ability = new rpg_ability($target_player, $target_robot, $item_reward_info);
                 $temp_ability->ability_name = $item_reward_info['ability_name'];
                 $temp_ability->ability_image = $item_reward_info['ability_token'];
                 $temp_ability->update_session();
                 // Collect or define the ability variables
                 $temp_item_token = $item_reward_info['ability_token'];
                 $temp_item_name = $item_reward_info['ability_name'];
                 $temp_item_colour = !empty($item_reward_info['ability_type']) ? $item_reward_info['ability_type'] : 'none';
                 if (!empty($item_reward_info['ability_type2'])) {
                     $temp_item_colour .= '_' . $item_reward_info['ability_type2'];
                 }
                 $temp_type_name = !empty($item_reward_info['ability_type']) ? ucfirst($item_reward_info['ability_type']) : 'Neutral';
                 $allow_over_max = false;
                 $temp_is_shard = preg_match('/-shard$/i', $temp_item_token) ? true : false;
                 $temp_is_core = preg_match('/-core$/i', $temp_item_token) ? true : false;
                 // Define the max quantity limit for this particular item
                 if ($temp_is_shard) {
                     $temp_item_quantity_max = MMRPG_SETTINGS_SHARDS_MAXQUANTITY;
                     $allow_over_max = true;
                 } elseif ($temp_is_core) {
                     $temp_item_quantity_max = MMRPG_SETTINGS_CORES_MAXQUANTITY;
                 } else {
                     $temp_item_quantity_max = MMRPG_SETTINGS_ITEMS_MAXQUANTITY;
                 }
                 // Create the session variable for this item if it does not exist and collect its value
                 if (empty($_SESSION['GAME']['values']['battle_items'][$temp_item_token])) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                 }
                 $temp_item_quantity = $_SESSION['GAME']['values']['battle_items'][$temp_item_token];
                 // If this item is already at the quantity limit, skip it entirely
                 if ($temp_item_quantity >= $temp_item_quantity_max) {
                     //$this_battle->events_create(false, false, 'DEBUG', 'max count for '.$temp_item_token.' of '.$temp_item_quantity_max.' has been reached ('.($allow_over_max ? 'allow' : 'disallow').')');
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = $temp_item_quantity_max;
                     $temp_item_quantity = $temp_item_quantity_max;
                     if (!$allow_over_max) {
                         return true;
                     }
                 }
                 // Define the new item quantity after increment
                 $temp_item_quantity_new = $temp_item_quantity + $item_drop_count;
                 $shards_remaining = false;
                 // If this is a shard piece
                 if ($temp_is_shard) {
                     // Define the number of shards remaining for a new core
                     $temp_item_quantity_max = MMRPG_SETTINGS_SHARDS_MAXQUANTITY;
                     $shards_remaining = $temp_item_quantity_max - $temp_item_quantity_new;
                     // If this player has collected enough shards to create a new core
                     if ($shards_remaining == 0) {
                         $temp_body_addon = 'The other ' . $temp_type_name . ' Shards from the inventory started glowing&hellip;';
                     } else {
                         $temp_body_addon = 'Collect ' . $shards_remaining . ' more shard' . ($shards_remaining > 1 ? 's' : '') . ' to create a new ' . $temp_type_name . ' Core!';
                     }
                 } elseif (preg_match('/-core$/i', $temp_item_token)) {
                     // Define the robot core drop text for displau
                     $temp_body_addon = $target_player->print_name() . ' added the new core to the inventory.';
                 } else {
                     // Define the normal item drop text for display
                     $temp_body_addon = $target_player->print_name() . ' added the dropped item' . ($item_drop_count > 1 ? 's' : '') . ' to the inventory.';
                 }
                 // Display the robot reward message markup
                 $event_header = $temp_item_name . ' Item Drop';
                 $event_body = rpg_functions::get_random_positive_word();
                 $event_body .= ' The disabled ' . $this_robot->print_name() . ' dropped ';
                 if ($item_drop_count == 1) {
                     $event_body .= (preg_match('/^(a|e|i|o|u)/i', $temp_item_name) ? 'an' : 'a') . ' <span class="ability_name ability_type ability_type_' . $temp_item_colour . '">' . $temp_item_name . '</span>!<br />';
                 } else {
                     $event_body .= 'x' . $item_drop_count . ' <span class="ability_name ability_type ability_type_' . $temp_item_colour . '">' . ($temp_item_name == 'Extra Life' ? 'Extra Lives' : $temp_item_name . 's') . '</span>!<br />';
                 }
                 $event_body .= $temp_body_addon;
                 $event_options = array();
                 $event_options['console_show_target'] = false;
                 $event_options['this_header_float'] = $target_player->player_side;
                 $event_options['this_body_float'] = $target_player->player_side;
                 $event_options['this_ability'] = $temp_ability;
                 $event_options['this_ability_image'] = 'icon';
                 $event_options['event_flag_victory'] = true;
                 $event_options['console_show_this_player'] = false;
                 $event_options['console_show_this_robot'] = false;
                 $event_options['console_show_this_ability'] = true;
                 $event_options['canvas_show_this_ability'] = true;
                 $target_player->set_frame($item_reward_key % 3 == 0 ? 'victory' : 'taunt');
                 $target_robot->robot_frame = $item_reward_key % 2 == 0 ? 'taunt' : 'base';
                 $target_robot->update_session();
                 $temp_ability->ability_frame = 'base';
                 $temp_ability->ability_frame_offset = array('x' => 220, 'y' => 0, 'z' => 10);
                 $temp_ability->update_session();
                 $this_battle->events_create($target_robot, $target_robot, $event_header, $event_body, $event_options);
                 // Create and/or increment the session variable for this item increasing its quantity
                 if (empty($_SESSION['GAME']['values']['battle_items'][$temp_item_token])) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                 }
                 if ($temp_item_quantity < $temp_item_quantity_max) {
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] += $item_drop_count;
                 }
                 // If this was a shard, and it was the LAST shard
                 if ($shards_remaining !== false && $shards_remaining < 1) {
                     // Define the new core token and increment value in session
                     $temp_core_token = str_replace('shard', 'core', $temp_item_token);
                     $temp_core_name = str_replace('Shard', 'Core', $temp_item_name);
                     $item_core_info = array('ability_token' => $temp_core_token, 'ability_name' => $temp_core_name, 'ability_type' => $item_reward_info['ability_type']);
                     // Create the temporary ability object for event creation
                     $temp_info['ability_id'] += 1;
                     $temp_info['ability_token'] = $temp_core_token;
                     $temp_core = new rpg_ability($target_player, $target_robot, $temp_info);
                     $temp_core->ability_name = $item_core_info['ability_name'];
                     $temp_core->ability_image = $item_core_info['ability_token'];
                     $temp_core->update_session();
                     // Collect or define the ability variables
                     //$temp_core_token = $item_core_info['ability_token'];
                     //$temp_core_name = $item_core_info['ability_name'];
                     $temp_type_name = !empty($temp_core->ability_type) ? ucfirst($temp_core->ability_type) : 'Neutral';
                     $temp_core_colour = !empty($temp_core->ability_type) ? $temp_core->ability_type : 'none';
                     // Define the max quantity limit for this particular item
                     $temp_core_quantity_max = MMRPG_SETTINGS_ITEMS_MAXQUANTITY;
                     // Create the session variable for this item if it does not exist and collect its value
                     if (empty($_SESSION['GAME']['values']['battle_items'][$temp_core_token])) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = 0;
                     }
                     $temp_core_quantity = $_SESSION['GAME']['values']['battle_items'][$temp_core_token];
                     // If this item is already at the quantity limit, skip it entirely
                     if ($temp_core_quantity >= $temp_core_quantity_max) {
                         //$this_battle->events_create(false, false, 'DEBUG', 'max count for '.$temp_core_token.' of '.$temp_core_quantity_max.' has been reached');
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = $temp_core_quantity_max;
                         $temp_core_quantity = $temp_core_quantity_max;
                         return true;
                     }
                     // Display the robot reward message markup
                     $event_header = $temp_core_name . ' Item Fusion';
                     $event_body = rpg_functions::get_random_positive_word() . ' The glowing shards fused to create a new ' . $temp_core->print_name() . '!<br />';
                     $event_body .= $target_player->print_name() . ' added the new core to the inventory.';
                     $event_options = array();
                     $event_options['console_show_target'] = false;
                     $event_options['this_header_float'] = $target_player->player_side;
                     $event_options['this_body_float'] = $target_player->player_side;
                     $event_options['this_ability'] = $temp_core;
                     $event_options['this_ability_image'] = 'icon';
                     $event_options['event_flag_victory'] = true;
                     $event_options['console_show_this_player'] = false;
                     $event_options['console_show_this_robot'] = false;
                     $event_options['console_show_this_ability'] = true;
                     $event_options['canvas_show_this_ability'] = true;
                     $target_player->set_frame($item_reward_key + 1 % 3 == 0 ? 'taunt' : 'victory');
                     $target_robot->robot_frame = $item_reward_key % 2 == 0 ? 'base' : 'taunt';
                     $target_robot->update_session();
                     $temp_core->ability_frame = 'base';
                     $temp_core->ability_frame_offset = array('x' => 220, 'y' => 0, 'z' => 10);
                     $temp_core->update_session();
                     $this_battle->events_create($target_robot, $target_robot, $event_header, $event_body, $event_options);
                     // Create and/or increment the session variable for this item increasing its quantity
                     if (empty($_SESSION['GAME']['values']['battle_items'][$temp_core_token])) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] = 0;
                     }
                     if ($temp_core_quantity < $temp_core_quantity_max) {
                         $_SESSION['GAME']['values']['battle_items'][$temp_core_token] += 1;
                     }
                     // Set the old shard counter back to zero now that they've fused
                     $_SESSION['GAME']['values']['battle_items'][$temp_item_token] = 0;
                     $temp_item_quantity = 0;
                 }
                 // Return true on success
                 return true;
             }
         }
         // Loop through the ability rewards for this robot if set and NOT demo mode
         if (rpg_game::is_user() && !empty($target_player_rewards['items']) && $this->player->player_id == MMRPG_SETTINGS_TARGET_PLAYERID) {
             $temp_items_index = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_flag_complete = 1;", 'ability_token');
             // Define the default success rate and multiply by the modifier
             $temp_success_value = $this_robot->robot_class == 'master' ? 50 : 25;
             $temp_success_value = ceil($temp_success_value * $temp_chance_multiplier);
             // Empty cores always have item drops
             if (!empty($this_robot->robot_core) && $this_robot->robot_core == 'empty') {
                 $temp_success_value = 100;
             }
             // If the target holds a Fortune Module, increase the chance of dropps
             if ($target_robot->robot_item == 'fortune-module') {
                 $temp_success_value = $temp_success_value * 2;
             }
             // Fix success values over 100
             if ($temp_success_value > 100) {
                 $temp_success_value = 100;
             }
             // Define the failure based on success rate
             $temp_failure_value = 100 - $temp_success_value;
             // Define the dropping result based on rates
             $temp_dropping_result = $temp_success_value == 100 ? 'success' : rpg_functions::weighted_chance(array('success', 'failure'), array($temp_success_value, $temp_failure_value));
             //$this_battle->events_create(false, false, 'DEBUG', '..and the result of the drop ('.$temp_success_value.' / '.$temp_failure_value.') is '.$temp_dropping_result);
             if ($temp_dropping_result == 'success') {
                 $temp_value_total = 0;
                 $temp_count_total = 0;
                 foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
                     $temp_value_total += $item_reward_info['chance'];
                     $temp_count_total += 1;
                 }
                 $temp_item_counts = array();
                 $temp_item_tokens = array();
                 $temp_item_weights = array();
                 if ($temp_value_total > 0) {
                     foreach ($target_player_rewards['items'] as $item_reward_key => $item_reward_info) {
                         $temp_item_tokens[] = $item_reward_info['token'];
                         $temp_item_weights[] = ceil($item_reward_info['chance'] / $temp_value_total * 100);
                         $temp_item_counts[$item_reward_info['token']] = isset($item_reward_info['quantity']) ? $item_reward_info['quantity'] : 1;
                     }
                 }
                 $temp_random_item = rpg_functions::weighted_chance($temp_item_tokens, $temp_item_weights);
                 $item_index_info = rpg_ability::parse_index_info($temp_items_index[$temp_random_item]);
                 $item_drop_count = $temp_item_counts[$temp_random_item];
                 temp_player_rewards_items($this_battle, $target_player, $target_robot, $this, $item_reward_key, $item_index_info, $item_drop_count);
             }
         }
     }
     // DEBUG
     //$this_battle->events_create(false, false, 'DEBUG', 'we made it past the experience boosts');
     // If the player has replacement robots and the knocked-out one was active
     if ($this_player->counters['robots_active'] > 0) {
         // Try to find at least one active POSITION robot before requiring a switch
         $has_active_positon_robot = false;
         foreach ($this_player->values['robots_active'] as $key => $robot) {
             //if ($robot['robot_position'] == 'active'){ $has_active_positon_robot = true; }
         }
         // If the player does NOT have an active position robot, trigger a switch
         if (!$has_active_positon_robot) {
             // If the target player is not on autopilot, require input
             if ($this_player->player_autopilot == false) {
                 // Empty the action queue to allow the player switch time
                 $this_battle->actions = array();
             } elseif ($this_player->player_autopilot == true) {
                 // && $this_player->player_next_action != 'switch'
                 // Empty the action queue to allow the player switch time
                 $this_battle->actions = array();
                 // Remove any previous switch actions for this player
                 $backup_switch_actions = $this_battle->actions_extract(array('this_player_id' => $this_player->player_id, 'this_action' => 'switch'));
                 //$this_battle->events_create(false, false, 'DEBUG DEBUG', 'This is a test from inside the dead trigger ['.count($backup_switch_actions).'].');
                 // If there were any previous switches removed
                 if (!empty($backup_switch_actions)) {
                     // If the target robot was faster, it should attack first
                     if ($this_robot->robot_speed > $target_robot->robot_speed) {
                         // Prepend an ability action for this robot
                         $this_battle->actions_prepend($this_player, $this_robot, $target_player, $target_robot, 'ability', '');
                     } else {
                         // Prepend an ability action for this robot
                         $this_battle->actions_append($this_player, $this_robot, $target_player, $target_robot, 'ability', '');
                     }
                 }
                 // Prepend a switch action for the target robot
                 $this_battle->actions_prepend($this_player, $this_robot, $target_player, $target_robot, 'switch', '');
             }
         }
     } else {
         // Trigger a battle complete action
         $this_battle->trigger_complete($target_player, $target_robot, $this_player, $this_robot);
     }
     // Either way, set the hidden flag on the robot
     //if (($this_robot->robot_status == 'disabled' || $this_robot->robot_energy < 1) && $this_robot->robot_position == 'bench'){
     if ($this_robot->robot_status == 'disabled' || $this_robot->robot_energy < 1) {
         //$this_robot->robot_status == 'disabled';
         $this_robot->flags['apply_disabled_state'] = true;
         if ($this_robot->robot_position == 'bench') {
             $this_robot->flags['hidden'] = true;
         }
         $this_robot->update_session();
     }
     // -- ROBOT UNLOCKING STUFF!!! -- //
     // Check if this target winner was a HUMAN player and update the robot database counter for defeats
     if ($target_player->player_side == 'left') {
         // Add this robot to the global robot database array
         if (!isset($_SESSION['GAME']['values']['robot_database'][$this->robot_token])) {
             $_SESSION['GAME']['values']['robot_database'][$this->robot_token] = array('robot_token' => $this->robot_token);
         }
         if (!isset($_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated'])) {
             $_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated'] = 0;
         }
         $_SESSION['GAME']['values']['robot_database'][$this->robot_token]['robot_defeated']++;
     }
     // Check if this battle has any robot rewards to unlock and the winner was a HUMAN player
     $temp_robot_rewards = $this_battle->get_robot_rewards();
     if ($target_player->player_side == 'left' && !empty($temp_robot_rewards)) {
         // DEBUG
         //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | battle_rewards_robots = '.count($temp_robot_rewards).'');
         foreach ($temp_robot_rewards as $temp_reward_key => $temp_reward_info) {
             // DEBUG
             //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | checking '.$this->robot_token.' == '.preg_replace('/\s+/', ' ', print_r($temp_reward_info, true)).'...');
             // Check if this robot was part of the rewards for this battle
             if (!rpg_game::robot_unlocked(false, $temp_reward_info['token']) && $this->robot_token == $temp_reward_info['token']) {
                 // DEBUG
                 //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | '.$this->robot_token.' == '.$temp_reward_info['token'].' is a match!');
                 // Check if this robot has been attacked with any elemental moves
                 if (!empty($this->history['triggered_damage_types'])) {
                     // Loop through all the damage types and check if they're not empty
                     foreach ($this->history['triggered_damage_types'] as $key => $types) {
                         if (!empty($types)) {
                             // DEBUG
                             //$this_battle->events_create(false, false, 'DEBUG_'.__LINE__, $this->robot_token.' | trigger_disabled | '.$this->robot_token.' was attacked with a '.implode(', ', $types).' type ability!<br />Removing from the battle rewards!');
                             // Generate the robot removed event showing the destruction
                             /*
                             $event_header = $this->robot_name.'&#39;s Data Destroyed';
                             $event_body = $this->print_name().'&#39;s battle data was damaged beyond repair!<br />';
                             $event_body .= $this->print_name().' could not be unlocked for use in battle&hellip;';
                             $event_options = array();
                             $event_options['console_show_target'] = false;
                             $event_options['this_header_float'] = $this_player->player_side;
                             $event_options['this_body_float'] = $this_player->player_side;
                             $event_options['console_show_this_player'] = false;
                             $event_options['console_show_this_robot'] = true;
                             $this_robot->robot_frame = 'defeat';
                             $this_robot->update_session();
                             $this_battle->events_create($this, false, $event_header, $event_body, $event_options);
                             */
                             // Remove this robot from the battle rewards array
                             unset($temp_robot_rewards[$temp_reward_key]);
                             // Break, we know all we need to
                             break;
                         }
                     }
                 }
                 // If this robot is somehow still a reward, print a message showing a good job
                 if (!empty($temp_robot_rewards[$temp_reward_key])) {
                     // Collect this reward's information
                     $robot_reward_info = $temp_robot_rewards[$temp_reward_key];
                     // Collect or define the robot points and robot rewards variables
                     //$this_robot_token = $robot_reward_info['token'];
                     $this_robot_level = !empty($robot_reward_info['level']) ? $robot_reward_info['level'] : 1;
                     $this_robot_experience = !empty($robot_reward_info['experience']) ? $robot_reward_info['experience'] : 0;
                     $this_robot_rewards = !empty($robot_info['robot_rewards']) ? $robot_info['robot_rewards'] : array();
                     // Create the temp new robot for the player
                     //$temp_index_robot = rpg_robot::get_index_info($this_robot_token);
                     $temp_index_robot['robot_id'] = MMRPG_SETTINGS_TARGET_PLAYERID * 2;
                     $temp_index_robot['robot_level'] = $this_robot_level;
                     $temp_index_robot['robot_experience'] = $this_robot_experience;
                     $temp_unlocked_robot = new rpg_robot($target_player, $temp_index_robot);
                     // Automatically unlock this robot for use in battle
                     //$temp_unlocked_player = $mmrpg_index['players'][$target_player->player_token];
                     rpg_game::unlock_robot($temp_unlocked_player, $temp_index_robot, true, true);
                     // Display the robot reward message markup
                     //$event_header = $temp_unlocked_robot->robot_name.' Unlocked';
                     $event_body = rpg_functions::get_random_positive_word() . ' ' . $target_player->print_name() . ' unlocked new robot data!<br />';
                     $event_body .= $temp_unlocked_robot->print_name() . ' can now be used in battle!';
                     $event_options = array();
                     $event_options['console_show_target'] = false;
                     $event_options['this_header_float'] = $target_player->player_side;
                     $event_options['this_body_float'] = $target_player->player_side;
                     $event_options['this_robot_image'] = 'mug';
                     $temp_unlocked_robot->robot_frame = 'base';
                     $temp_unlocked_robot->update_session();
                     $this_battle->events_create($temp_unlocked_robot, false, $event_header, $event_body, $event_options);
                 }
                 // Update the battle with robot reward changes
                 $temp_robot_rewards = array_values($temp_robot_rewards);
                 $this_battle->set_robot_rewards($temp_robot_rewards);
             }
         }
     }
     // Return true on success
     return true;
 }
コード例 #13
0
 public static function reset_session()
 {
     // Reference global variables
     global $mmrpg_index, $db;
     //$GAME_SESSION = &$_SESSION[self::session_token()];
     $session_token = self::session_token();
     // Collect the user ID from the session
     $user_id = !empty($_SESSION[$session_token]['USER']['userid']) ? $_SESSION[$session_token]['USER']['userid'] : 0;
     // Back up the user and file info from the session
     $this_demo = $_SESSION[$session_token]['DEMO'];
     $this_user = $_SESSION[$session_token]['USER'];
     $this_file = $_SESSION[$session_token]['FILE'];
     $this_level_bonus = self::robot_level('dr-light', 'mega-man');
     $this_battle_points = !empty($_SESSION[$session_token]['counters']['battle_points']) ? $_SESSION[$session_token]['counters']['battle_points'] : 0;
     $this_battle_zenny = !empty($_SESSION[$session_token]['counters']['battle_zenny']) ? $_SESSION[$session_token]['counters']['battle_zenny'] : 0;
     $this_battle_items = !empty($_SESSION[$session_token]['counters']['battle_items']) ? $_SESSION[$session_token]['counters']['battle_items'] : array();
     $this_battle_stars = !empty($_SESSION[$session_token]['counters']['battle_stars']) ? $_SESSION[$session_token]['counters']['battle_stars'] : array();
     $this_battle_abilities = !empty($_SESSION[$session_token]['counters']['battle_abilities']) ? $_SESSION[$session_token]['counters']['battle_abilities'] : array();
     $this_battle_complete = !empty($_SESSION[$session_token]['values']['battle_complete']) ? $_SESSION[$session_token]['values']['battle_complete'] : array();
     $this_battle_failure = !empty($_SESSION[$session_token]['values']['battle_failure']) ? $_SESSION[$session_token]['values']['battle_failure'] : array();
     $this_robot_database = !empty($_SESSION[$session_token]['values']['robot_database']) ? $_SESSION[$session_token]['values']['robot_database'] : array();
     $this_battle_rewards = !empty($_SESSION[$session_token]['values']['battle_rewards']) ? $_SESSION[$session_token]['values']['battle_rewards'] : array();
     $this_battle_items = !empty($_SESSION[$session_token]['values']['battle_items']) ? $_SESSION[$session_token]['values']['battle_items'] : array();
     $this_index_settings = !empty($_SESSION[$session_token]['index_settings']) ? $_SESSION[$session_token]['index_settings'] : array();
     // Automatically unset the session variable entirely
     session_unset();
     // Automatically create the cache date
     $_SESSION[$session_token] = array();
     $_SESSION[$session_token]['CACHE_DATE'] = MMRPG_CONFIG_CACHE_DATE;
     // Redefine the user and file variables in the new session
     $_SESSION[$session_token]['DEMO'] = $this_demo;
     $_SESSION[$session_token]['USER'] = $this_user;
     // Automatically create the battle points counter and start at zero
     $_SESSION[$session_token]['counters']['battle_points'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? 0 : $this_battle_points;
     // Automatically create the battle points counter and start at zero
     $_SESSION[$session_token]['counters']['battle_zenny'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? 0 : $this_battle_zenny;
     // Automatically create the battle complete array and start at empty
     $_SESSION[$session_token]['values']['battle_complete'] = array();
     // Automatically create the battle failure array and start at empty
     $_SESSION[$session_token]['values']['battle_failure'] = array();
     // Automatically create the battle index array and start at empty
     $_SESSION[$session_token]['values']['battle_index'] = array();
     // Automatically create the battle items array and start at empty
     $_SESSION[$session_token]['values']['battle_items'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_items;
     // Automatically create the battle stars array and start at empty
     $_SESSION[$session_token]['values']['battle_stars'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_stars;
     // Automatically create the battle abilities array and start at empty
     $_SESSION[$session_token]['values']['battle_abilities'] = !empty($_REQUEST['action']) && $_REQUEST['action'] == 'reset' ? array() : $this_battle_abilities;
     // Automatically create the robot database array and start at empty
     $_SESSION[$session_token]['values']['robot_database'] = array();
     // Automatically create the index settings array and start at what was before
     $_SESSION[$session_token]['index_settings'] = $this_index_settings;
     // Automatically create the last load and save variable and set to now
     $_SESSION[$session_token]['values']['last_load'] = time();
     $_SESSION[$session_token]['values']['last_save'] = time();
     // -- DEMO MODE UNLOCKS -- //
     if (rpg_game::is_demo()) {
         // Reset the demo flag and user id to defaul
         $_SESSION[$session_token]['USER']['userid'] = MMRPG_SETTINGS_GUEST_ID;
         $_SESSION[$session_token]['DEMO'] = 1;
         // Only unlock Dr. Light as a playable character
         $unlock_player_info = $mmrpg_index['players']['dr-light'];
         self::unlock_player($unlock_player_info, false, true);
         $_SESSION[$session_token]['values']['battle_rewards']['dr-light']['player_points'] = 0;
         $_SESSION[$session_token]['values']['battle_items'] = array('item-energy-pellet' => 3, 'item-energy-capsule' => 2, 'item-weapon-pellet' => 3, 'item-weapon-capsule' => 2);
         // Auto-select Dr. Light as the current playable character
         $_SESSION[$session_token]['battle_settings']['this_player_token'] = 'dr-light';
         // Collect the robot index for calculation purposes
         $this_robot_index = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token');
         // Unlock Mega Man as a playable character
         $unlock_robot_info = $this_robot_index['mega-man'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'super-throw'), array('level' => 0, 'token' => 'fire-storm'), array('level' => 0, 'token' => 'hyper-bomb'), array('level' => 0, 'token' => 'ice-breath'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'mega-buster'), array('level' => 0, 'token' => 'mega-ball'), array('level' => 0, 'token' => 'mega-slide'));
         //$unlock_robot_info['robot_level'] = 5;
         //echo __LINE__.print_r($_SESSION[$session_token]['values']['battle_rewards']['dr-light'], true);
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
         // Unlock Bass as a playable character
         $unlock_robot_info = $this_robot_index['bass'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'air-shooter'), array('level' => 0, 'token' => 'leaf-shield'), array('level' => 0, 'token' => 'bubble-spray'), array('level' => 0, 'token' => 'quick-boomerang'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'bass-buster'), array('level' => 0, 'token' => 'bass-crush'), array('level' => 0, 'token' => 'bass-baroque'));
         //$unlock_robot_info['robot_level'] = 99;
         //$unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
         // Unlock Proto Man as a playable character
         $unlock_robot_info = $this_robot_index['proto-man'];
         $unlock_robot_info['robot_level'] = 1;
         $unlock_robot_info['robot_rewards']['abilities'] = array(array('level' => 0, 'token' => 'drill-blitz'), array('level' => 0, 'token' => 'bright-burst'), array('level' => 0, 'token' => 'dive-missile'), array('level' => 0, 'token' => 'skull-barrier'), array('level' => 0, 'token' => 'buster-shot'), array('level' => 0, 'token' => 'proto-buster'), array('level' => 0, 'token' => 'proto-shield'), array('level' => 0, 'token' => 'proto-strike'));
         //$unlock_robot_info['robot_level'] = 99;
         //$unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
     } else {
         // Unlock Dr. Light as a playable character
         $unlock_player_info = $mmrpg_index['players']['dr-light'];
         self::unlock_player($unlock_player_info, true, true);
         $_SESSION[$session_token]['values']['battle_rewards']['dr-light']['player_points'] = 0;
         $_SESSION[$session_token]['values']['battle_items'] = array();
         // Auto-select Dr. Light as the current playable character
         $_SESSION[$session_token]['battle_settings']['this_player_token'] = 'dr-light';
         // Unlock Mega Man as a playable character
         $unlock_robot_info = rpg_robot::get_index_info('mega-man');
         $unlock_robot_info['robot_level'] = 1;
         //!empty($this_level_bonus) ? $this_level_bonus : 1;
         $unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience_required(1) - 1;
         self::unlock_robot($unlock_player_info, $unlock_robot_info, true, false);
     }
     // Return true on success
     return true;
 }
コード例 #14
0
<?php

// Include the application TOP file
$temp_path = str_replace('\\', '/', dirname(dirname(__FILE__)));
require $temp_path . '/_top.php';
// Unset the database variable
unset($db);
// Collect the password string from the URL, if set
$password_string = !empty($_REQUEST['password']) ? $_REQUEST['password'] : false;
// If the password was not empty and is valid, continue
$valid_passwords = '#^([-_a-z0-9]+)$#i';
if (!empty($password_string) && preg_match($valid_passwords, $password_string)) {
    // Ensure the user and file details have already been loaded to the session
    if (!empty($_SESSION['GAME']['USER'])) {
        // Process the password based on a predefined list
        if (preg_match('#^(dr-light|dr-wily|dr-cossack)_#i', $password_string)) {
            //($password_string == 'dr-light_proto-man'){
            // UNLOCK ROBOTS
            list($player_token, $robot_token) = explode('_', $password_string);
            $unlock_player_info = $mmrpg_index['players'][$player_token];
            $unlock_robot_info = rpg_robot::get_index_info($robot_token);
            rpg_game::unlock_robot($unlock_player_info, $unlock_robot_info);
            exit('success:unlock_' . $player_token . '_' . $robot_token);
        } else {
            // UNLOCK NOTHING!!!
            die('error:password-invalid');
        }
    }
} else {
    die('error:password-empty');
}
コード例 #15
0
}
// Now that we have a new item attached, we should re-evaluate compatibile abilities
$robot_ability_settings = !empty($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_robot]['robot_abilities']) ? $_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_robot]['robot_abilities'] : array();
$player_ability_rewards = !empty($_SESSION[$session_token]['values']['battle_abilities']) ? $_SESSION[$session_token]['values']['battle_abilities'] : array('buster-shot' => array('ability_token' => 'buster-shot'));
$allowed_ability_ids = array();
if (!empty($player_ability_rewards)) {
    foreach ($player_ability_rewards as $ability_token => $ability_info) {
        if (empty($ability_info['ability_token'])) {
            continue;
        } elseif ($ability_info['ability_token'] == '*') {
            continue;
        } elseif ($ability_info['ability_token'] == 'ability') {
            continue;
        } elseif (!isset($mmrpg_database_abilities[$ability_info['ability_token']])) {
            continue;
        } elseif (!rpg_robot::has_ability_compatibility($temp_robot_info['robot_token'], $ability_token, $temp_item)) {
            if (isset($robot_ability_settings[$ability_token])) {
                unset($robot_ability_settings[$ability_token]);
            }
            continue;
        }
        $ability_info['ability_id'] = $mmrpg_database_abilities[$ability_info['ability_token']]['ability_id'];
        $allowed_ability_ids[] = $ability_info['ability_id'];
    }
}
$allowed_ability_ids = implode(',', $allowed_ability_ids);
if (empty($robot_ability_settings)) {
    $robot_ability_settings['buster-shot'] = array('buster-shot' => array('ability_token' => 'buster-shot'));
}
$_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_robot]['robot_abilities'] = $robot_ability_settings;
// Regardless of what happened before, update this robot's item in the session and save
コード例 #16
0
     break;
     // If this was a robot request
 // If this was a robot request
 case 'robots':
     $key_counter = array_search($this_token, array_keys($mmrpg_database_robots));
     $temp_robot_info = $mmrpg_database_robots[$this_token];
     $temp_robot_markup = rpg_robot::print_database_markup($temp_robot_info, array('show_key' => $key_counter));
     $temp_robot_markup = preg_replace('/\\s+/', ' ', $temp_robot_markup);
     echo 'success : ' . $temp_robot_markup;
     break;
     // If this was a mecha request
 // If this was a mecha request
 case 'mechas':
     $key_counter = array_search($this_token, array_keys($mmrpg_database_mechas));
     $temp_mecha_info = $mmrpg_database_mechas[$this_token];
     $temp_mecha_markup = rpg_robot::print_database_markup($temp_mecha_info, array('show_key' => $key_counter));
     $temp_mecha_markup = preg_replace('/\\s+/', ' ', $temp_mecha_markup);
     echo 'success : ' . $temp_mecha_markup;
     break;
     // If this was a ability request
 // If this was a ability request
 case 'abilities':
     $key_counter = array_search($this_token, array_keys($mmrpg_database_abilities));
     $temp_ability_info = $mmrpg_database_abilities[$this_token];
     $temp_ability_markup = rpg_ability::print_database_markup($temp_ability_info, array('show_key' => $key_counter));
     $temp_ability_markup = preg_replace('/\\s+/', ' ', $temp_ability_markup);
     echo 'success : ' . $temp_ability_markup;
     break;
     // If this was a field request
 // If this was a field request
 case 'fields':
コード例 #17
0
    public static function print_editor_markup($player_info)
    {
        // Define the global variables
        global $mmrpg_index, $this_current_uri, $this_current_url, $db;
        global $allowed_edit_players, $allowed_edit_fields, $global_allow_editing;
        global $allowed_edit_data_count, $allowed_edit_player_count, $first_player_token;
        global $key_counter, $player_key, $player_counter, $player_rewards, $player_field_rewards, $player_item_rewards, $temp_player_totals, $player_options_markup;
        global $mmrpg_database_robots, $mmrpg_database_items;
        $session_token = rpg_game::session_token();
        // If either fo empty, return error
        if (empty($player_info)) {
            return 'error:player-empty';
        }
        // Collect the approriate database indexes
        if (empty($mmrpg_database_robots)) {
            $mmrpg_database_robots = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_flag_complete = 1;", 'robot_token');
        }
        if (empty($mmrpg_database_items)) {
            $mmrpg_database_items = $db->get_array_list("SELECT * FROM mmrpg_index_abilities WHERE ability_class = 'item' AND ability_flag_complete = 1;", 'ability_token');
        }
        // Define the quick-access variables for later use
        $player_token = $player_info['player_token'];
        if (!isset($first_player_token)) {
            $first_player_token = $player_token;
        }
        // Define the player's image and size if not defined
        $player_info['player_image'] = !empty($player_info['player_image']) ? $player_info['player_image'] : $player_info['player_token'];
        $player_info['player_image_size'] = !empty($player_info['player_image_size']) ? $player_info['player_image_size'] : 40;
        // Define the player's battle points total, battles complete, and other details
        $player_info['player_points'] = rpg_game::player_points($player_token);
        $player_info['player_battles_complete'] = rpg_prototype::battles_complete($player_token);
        $player_info['player_battles_complete_total'] = rpg_prototype::battles_complete($player_token, false);
        $player_info['player_battles_failure'] = rpg_prototype::battles_failure($player_token);
        $player_info['player_battles_failure_total'] = rpg_prototype::battles_failure($player_token, false);
        $player_info['player_robots_count'] = 0;
        $player_info['player_abilities_count'] = rpg_game::abilities_unlocked($player_token);
        $player_info['player_field_stars'] = rpg_game::stars_unlocked($player_token, 'field');
        $player_info['player_fusion_stars'] = rpg_game::stars_unlocked($player_token, 'fusion');
        $player_info['player_screw_counter'] = 0;
        $player_info['player_heart_counter'] = 0;
        // Define the player's experience points total
        $player_info['player_experience'] = 0;
        // Collect this player's current defined omega item list
        if (!empty($_SESSION[$session_token]['values']['battle_rewards'])) {
            //$debug_experience_sum = $player_token.' : ';
            foreach ($_SESSION[$session_token]['values']['battle_rewards'] as $temp_player => $temp_player_info) {
                if (!empty($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'])) {
                    $temp_player_robot_rewards = $_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'];
                    $temp_player_robot_settings = $_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'];
                    if (empty($temp_player_robot_rewards) || empty($temp_player_robot_settings)) {
                        unset($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots']);
                        unset($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots']);
                        continue;
                    }
                    foreach ($temp_player_robot_rewards as $temp_key => $temp_robot_info) {
                        if (empty($temp_robot_info['robot_token'])) {
                            unset($_SESSION[$session_token]['values']['battle_rewards'][$temp_player]['player_robots'][$temp_key]);
                            unset($_SESSION[$session_token]['values']['battle_settings'][$temp_player]['player_robots'][$temp_key]);
                            continue;
                        }
                        $temp_robot_settings = $temp_player_robot_settings[$temp_robot_info['robot_token']];
                        $temp_robot_rewards = $temp_player_robot_settings[$temp_robot_info['robot_token']];
                        // If this robot is not owned by the player, skip it as it doesn't count towards their totals
                        if (empty($temp_robot_settings['original_player']) && $temp_player != $player_token) {
                            continue;
                        } elseif (empty($temp_robot_settings['original_player'])) {
                            $temp_robot_settings['original_player'] = $temp_player;
                        }
                        if ($temp_robot_settings['original_player'] != $player_token) {
                            continue;
                        }
                        //$debug_experience_sum .= $temp_robot_info['robot_token'].', ';
                        $player_info['player_robots_count']++;
                        if (!empty($temp_robot_info['robot_level'])) {
                            $player_info['player_experience'] += $temp_robot_info['robot_level'] * MMRPG_SETTINGS_BATTLEPOINTS_PERROBOT;
                        }
                        if (!empty($temp_robot_info['robot_experience'])) {
                            $player_info['player_experience'] += $temp_robot_info['robot_experience'];
                        }
                    }
                }
            }
            //die($debug_experience_sum);
        }
        // Collect this player's current field selection from the omega session
        $temp_session_key = $player_info['player_token'] . '_target-robot-omega_prototype';
        $player_info['target_robot_omega'] = !empty($_SESSION[$session_token]['values'][$temp_session_key]) ? $_SESSION[$session_token]['values'][$temp_session_key] : array();
        $player_info['player_fields_current'] = array();
        //die('<pre>$player_info[\'target_robot_omega\'] = '.print_r($player_info['target_robot_omega'], true).'</pre>');
        if (count($player_info['target_robot_omega']) == 2) {
            $player_info['target_robot_omega'] = array_shift($player_info['target_robot_omega']);
        }
        foreach ($player_info['target_robot_omega'] as $key => $info) {
            $field = rpg_field::get_index_info($info['field']);
            if (empty($field)) {
                continue;
            }
            $player_info['player_fields_current'][] = $field;
        }
        // Define this player's stat type boost for display purposes
        $player_info['player_stat_type'] = '';
        if (!empty($player_info['player_energy'])) {
            $player_info['player_stat_type'] = 'energy';
        } elseif (!empty($player_info['player_attack'])) {
            $player_info['player_stat_type'] = 'attack';
        } elseif (!empty($player_info['player_defense'])) {
            $player_info['player_stat_type'] = 'defense';
        } elseif (!empty($player_info['player_speed'])) {
            $player_info['player_stat_type'] = 'speed';
        }
        // Define whether or not field switching is enabled
        $temp_allow_field_switch = rpg_prototype::campaign_complete($player_info['player_token']) || rpg_prototype::campaign_complete();
        // Collect a temp robot object for printing items
        if ($player_info['player_token'] == 'dr-light') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['mega-man']);
        } elseif ($player_info['player_token'] == 'dr-wily') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['bass']);
        } elseif ($player_info['player_token'] == 'dr-cossack') {
            $robot_info = rpg_robot::parse_index_info($mmrpg_database_robots['proto-man']);
        }
        // Define the markup variable
        $this_markup = '';
        // Start the output buffer
        ob_start();
        // DEBUG
        //die(print_r($player_field_rewards, true));
        ?>
            <div class="event event_double event_<?php 
        echo $player_key == $first_player_token ? 'visible' : 'hidden';
        ?>
" data-token="<?php 
        echo $player_info['player_token'] . '_' . $player_info['player_token'];
        ?>
">
                <div class="this_sprite sprite_left" style="height: 40px;">
                    <?php 
        $temp_margin = -1 * ceil(($player_info['player_image_size'] - 40) * 0.5);
        ?>
                    <div style="margin-top: <?php 
        echo $temp_margin;
        ?>
px; margin-bottom: <?php 
        echo $temp_margin * 3;
        ?>
px; background-image: url(i/p/<?php 
        echo !empty($player_info['player_image']) ? $player_info['player_image'] : $player_info['player_token'];
        ?>
/mr<?php 
        echo $player_info['player_image_size'];
        ?>
.png?<?php 
        echo MMRPG_CONFIG_CACHE_DATE;
        ?>
); " class="sprite sprite_player sprite_player_sprite sprite_<?php 
        echo $player_info['player_image_size'] . 'x' . $player_info['player_image_size'];
        ?>
 sprite_<?php 
        echo $player_info['player_image_size'] . 'x' . $player_info['player_image_size'];
        ?>
_mug player_status_active player_position_active"><?php 
        echo $player_info['player_name'];
        ?>
</div>
                </div>
                <div class="header header_left player_type player_type_<?php 
        echo !empty($player_info['player_stat_type']) ? $player_info['player_stat_type'] : 'none';
        ?>
" style="margin-right: 0;"><?php 
        echo $player_info['player_name'];
        ?>
&#39;s Data <span class="player_type"><?php 
        echo !empty($player_info['player_stat_type']) ? ucfirst($player_info['player_stat_type']) : 'Neutral';
        ?>
 Type</span></div>
                <div class="body body_left" style="margin-right: 0; padding: 2px 3px; height: auto;">
                    <table class="full" style="margin-bottom: 5px;">
                        <colgroup>
                            <col width="48.5%" />
                            <col width="1%" />
                            <col width="48.5%" />
                        </colgroup>
                        <tbody>

                            <tr>
                                <td  class="right">
                                    <label style="display: block; float: left;">Name :</label>
                                    <span class="player_name player_type player_type_none"><?php 
        echo $player_info['player_name'];
        ?>
</span>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td class="right">
                                    <label style="display: block; float: left;">Bonus :</label>
                                    <?php 
        // Display any special boosts this player has
        if (!empty($player_info['player_stat_type'])) {
            echo '<span class="player_name player_type player_type_' . $player_info['player_stat_type'] . '">Robot ' . ucfirst($player_info['player_stat_type']) . ' +' . $player_info['player_' . $player_info['player_stat_type']] . '%</span>';
        } else {
            echo '<span class="player_name player_type player_type_none">None</span>';
        }
        ?>
                                </td>
                            </tr>

                            <tr>
                                <td  class="right">
                                    <label style="display: block; float: left;">Exp Points :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_experience']) ? 'cutter' : 'none';
        ?>
"><?php 
        echo number_format($player_info['player_experience'], 0, '.', ',');
        ?>
 EXP</span>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td  class="right">
                                    <label style="display: block; float: left;">Unlocked Robots :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_robots_count']) ? 'cutter' : 'none';
        ?>
"><?php 
        echo $player_info['player_robots_count'] . ' ' . ($player_info['player_robots_count'] == 1 ? 'Robot' : 'Robots');
        ?>
</span>
                                </td>
                            </tr>
                            <tr>
                                <td  class="right">
                                    <label style="display: block; float: left;">Battle Points :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_points']) ? 'cutter' : 'none';
        ?>
"><?php 
        echo number_format($player_info['player_points'], 0, '.', ',');
        ?>
 BP</span>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td  class="right">
                                    <label style="display: block; float: left;">Unlocked Abilities :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_abilities_count']) ? 'cutter' : 'none';
        ?>
"><?php 
        echo $player_info['player_abilities_count'] . ' ' . ($player_info['player_abilities_count'] == 1 ? 'Ability' : 'Abilities');
        ?>
</span>
                                </td>
                            </tr>

                            <tr>
                                <td  class="right">
                                    <label style="display: block; float: left;">Missions Completed :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_battles_complete']) ? 'energy' : 'none';
        ?>
"><?php 
        echo $player_info['player_battles_complete'];
        ?>
 Missions</span>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td  class="right">
                                    <label style="display: block; float: left;">Total Victories :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_battles_complete_total']) ? 'energy' : 'none';
        ?>
"><?php 
        echo $player_info['player_battles_complete_total'];
        ?>
 Victories</span>
                                </td>
                            </tr>
                            <tr>
                                <td  class="right">
                                    <label style="display: block; float: left;">Missions Failed :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_battles_failure']) ? 'attack' : 'none';
        ?>
"><?php 
        echo $player_info['player_battles_failure'];
        ?>
 Missions</span>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td  class="right">
                                    <label style="display: block; float: left;">Total Defeats :</label>
                                    <span class="player_stat player_type player_type_<?php 
        echo !empty($player_info['player_battles_failure_total']) ? 'attack' : 'none';
        ?>
"><?php 
        echo $player_info['player_battles_failure_total'];
        ?>
 Defeats</span>
                                </td>
                            </tr>

                            <tr>
                                <td  class="right">
                                    <?php 
        if (!empty($player_info['player_field_stars'])) {
            ?>
                                    <label style="display: block; float: left;">Field Stars :</label>
                                    <span class="player_stat player_type player_type_<?php 
            echo !empty($player_info['player_field_stars']) ? 'electric' : 'empty';
            ?>
"><?php 
            echo $player_info['player_field_stars'] . ' ' . ($player_info['player_field_stars'] == 1 ? 'Star' : 'Stars');
            ?>
</span>
                                    <?php 
        } else {
            ?>
                                    <label style="display: block; float: left; opacity: 0.5; filter: alpha(opacity=50); ">??? :</label>
                                    <span class="player_stat player_type player_type_empty" style=" opacity: 0.5; filter: alpha(opacity=50); ">0</span>
                                    <?php 
        }
        ?>
                                </td>
                                <td class="center">&nbsp;</td>
                                <td  class="right">
                                    <?php 
        if (!empty($player_info['player_fusion_stars'])) {
            ?>
                                    <label style="display: block; float: left;">Fusion Stars :</label>
                                    <span class="player_stat player_type player_type_<?php 
            echo !empty($player_info['player_fusion_stars']) ? 'time' : 'empty';
            ?>
"><?php 
            echo $player_info['player_fusion_stars'] . ' ' . ($player_info['player_fusion_stars'] == 1 ? 'Star' : 'Stars');
            ?>
</span>
                                    <?php 
        } else {
            ?>
                                    <label style="display: block; float: left; opacity: 0.5; filter: alpha(opacity=50); ">??? :</label>
                                    <span class="player_stat player_type player_type_empty" style=" opacity: 0.5; filter: alpha(opacity=50); ">0</span>
                                    <?php 
        }
        ?>
                                </td>
                            </tr>

                        </tbody>
                    </table>



                    <?php 
        if (false && !empty($player_item_rewards)) {
            ?>

                        <table class="full">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right" style="padding-top: 4px;">
                                    <label class="item_header">Player Items :</label>
                                        <div class="item_container" style="height: auto;">
                                        <?php 
            // Define the array to hold ALL the reward option markup
            $item_rewards_options = '';
            // Collect this player's item rewards and add them to the dropdown
            //$player_item_rewards = !empty($player_rewards['player_items']) ? $player_rewards['player_items'] : array();
            //if (!empty($player_item_rewards)){ sort($player_item_rewards); }
            // DEBUG
            //$debug_tokens = array();
            //foreach ($player_item_rewards AS $info){ $debug_tokens[] = $info['ability_token']; }
            //echo 'before:'.implode(',', array_keys($debug_tokens)).'<br />';
            // Sort the item index based on item group
            uasort($player_item_rewards, array('rpg_functions', 'items_sort_for_editor'));
            // DEBUG
            //echo 'after:'.implode(',', array_keys($player_item_rewards)).'<br />';
            // DEBUG
            //$debug_tokens = array();
            //foreach ($player_item_rewards AS $info){ $debug_tokens[] = $info['ability_token']; }
            //echo 'after:'.implode(',', $debug_tokens).'<br />';
            // Dont' bother generating option dropdowns if editing is disabled
            if ($global_allow_editing) {
                $player_item_rewards_options = array();
                foreach ($player_item_rewards as $temp_item_key => $temp_item_info) {
                    if (empty($temp_item_info['ability_token'])) {
                        continue;
                    }
                    $temp_token = $temp_item_info['ability_token'];
                    $temp_item_info = rpg_ability::parse_index_info($mmrpg_database_items[$temp_token]);
                    $temp_option_markup = rpg_ability::print_editor_option_markup($robot_info, $temp_item_info);
                    if (!empty($temp_option_markup)) {
                        $player_item_rewards_options[] = $temp_option_markup;
                    }
                }
                $player_item_rewards_options = '<optgroup label="Player Items">' . implode('', $player_item_rewards_options) . '</optgroup>';
                $item_rewards_options .= $player_item_rewards_options;
                /*
                // Collect this robot's item rewards and add them to the dropdown
                $player_item_rewards = !empty($player_rewards['player_items']) ? $player_rewards['player_items'] : array();
                $player_item_settings = !empty($player_settings['player_items']) ? $player_settings['player_items'] : array();
                foreach ($player_item_settings AS $token => $info){ if (empty($player_item_rewards[$token])){ $player_item_rewards[$token] = $info; } }
                if (!empty($player_item_rewards)){ sort($player_item_rewards); }
                $player_item_rewards_options = array();
                foreach ($player_item_rewards AS $temp_item_info){
                    if (empty($temp_item_info['ability_token'])){ continue; }
                    $temp_token = $temp_item_info['ability_token'];
                    $temp_item_info = rpg_ability::parse_index_info($mmrpg_database_items[$temp_token]);
                    $temp_option_markup = rpg_ability::print_editor_option_markup($robot_info, $temp_item_info);
                    if (!empty($temp_option_markup)){ $player_item_rewards_options[] = $temp_option_markup; }
                }
                $player_item_rewards_options = '<optgroup label="Player Items">'.implode('', $player_item_rewards_options).'</optgroup>';
                $item_rewards_options .= $player_item_rewards_options;
                */
                // Add an option at the bottom to remove the ability
                $item_rewards_options .= '<optgroup label="Item Actions">';
                $item_rewards_options .= '<option value="" title="">- Remove Item -</option>';
                $item_rewards_options .= '</optgroup>';
            }
            // Loop through the robot's current items and list them one by one
            $empty_item_counter = 0;
            $temp_string = array();
            $temp_inputs = array();
            $item_key = 0;
            if (!empty($player_info['player_items_current'])) {
                // DEBUG
                //echo 'robot-ability:';
                foreach ($player_info['player_items_current'] as $key => $player_item) {
                    if (empty($player_item['ability_token'])) {
                        continue;
                    } elseif ($player_item['ability_token'] == '*') {
                        continue;
                    } elseif ($player_item['ability_token'] == 'ability') {
                        continue;
                    } elseif ($item_key > 7) {
                        continue;
                    }
                    $this_item = rpg_ability::parse_index_info($mmrpg_database_items[$player_item['ability_token']]);
                    if (empty($this_item)) {
                        continue;
                    }
                    $this_item_token = $this_item['ability_token'];
                    $this_item_name = $this_item['ability_name'];
                    $this_item_type = !empty($this_item['ability_type']) ? $this_item['ability_type'] : false;
                    $this_item_type2 = !empty($this_item['ability_type2']) ? $this_item['ability_type2'] : false;
                    if (!empty($this_item_type) && !empty($mmrpg_index['types'][$this_item_type])) {
                        $this_item_type = $mmrpg_index['types'][$this_item_type]['type_name'] . ' Type';
                        if (!empty($this_item_type2) && !empty($mmrpg_index['types'][$this_item_type2])) {
                            $this_item_type = str_replace(' Type', ' / ' . $mmrpg_index['types'][$this_item_type2]['type_name'] . ' Type', $this_item_type);
                        }
                    } else {
                        $this_item_type = '';
                    }
                    $this_item_energy = isset($this_item['ability_energy']) ? $this_item['ability_energy'] : 4;
                    $this_item_damage = !empty($this_item['ability_damage']) ? $this_item['ability_damage'] : 0;
                    $this_item_damage2 = !empty($this_item['ability_damage2']) ? $this_item['ability_damage2'] : 0;
                    $this_item_damage_percent = !empty($this_item['ability_damage_percent']) ? true : false;
                    $this_item_damage2_percent = !empty($this_item['ability_damage2_percent']) ? true : false;
                    if ($this_item_damage_percent && $this_item_damage > 100) {
                        $this_item_damage = 100;
                    }
                    if ($this_item_damage2_percent && $this_item_damage2 > 100) {
                        $this_item_damage2 = 100;
                    }
                    $this_item_recovery = !empty($this_item['ability_recovery']) ? $this_item['ability_recovery'] : 0;
                    $this_item_recovery2 = !empty($this_item['ability_recovery2']) ? $this_item['ability_recovery2'] : 0;
                    $this_item_recovery_percent = !empty($this_item['ability_recovery_percent']) ? true : false;
                    $this_item_recovery2_percent = !empty($this_item['ability_recovery2_percent']) ? true : false;
                    if ($this_item_recovery_percent && $this_item_recovery > 100) {
                        $this_item_recovery = 100;
                    }
                    if ($this_item_recovery2_percent && $this_item_recovery2 > 100) {
                        $this_item_recovery2 = 100;
                    }
                    $this_item_accuracy = !empty($this_item['ability_accuracy']) ? $this_item['ability_accuracy'] : 0;
                    $this_item_description = !empty($this_item['ability_description']) ? $this_item['ability_description'] : '';
                    $this_item_description = str_replace('{DAMAGE}', $this_item_damage, $this_item_description);
                    $this_item_description = str_replace('{RECOVERY}', $this_item_recovery, $this_item_description);
                    $this_item_description = str_replace('{DAMAGE2}', $this_item_damage2, $this_item_description);
                    $this_item_description = str_replace('{RECOVERY2}', $this_item_recovery2, $this_item_description);
                    $this_item_title = rpg_ability::print_editor_title_markup($robot_info, $this_item);
                    $this_item_title_plain = strip_tags(str_replace('<br />', '&#10;', $this_item_title));
                    $this_item_title_tooltip = htmlentities($this_item_title, ENT_QUOTES, 'UTF-8');
                    $this_item_title_html = str_replace(' ', '&nbsp;', $this_item_name);
                    $temp_select_options = str_replace('value="' . $this_item_token . '"', 'value="' . $this_item_token . '" selected="selected" disabled="disabled"', $item_rewards_options);
                    $this_item_title_html = '<label style="background-image: url(i/a/' . $this_item_token . '/il40.png?' . MMRPG_CONFIG_CACHE_DATE . ');">' . $this_item_title_html . '</label>';
                    if ($global_allow_editing) {
                        $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '">' . $temp_select_options . '</select>';
                    }
                    $temp_string[] = '<a class="ability_name ability_type ability_type_' . (!empty($this_item['ability_type']) ? $this_item['ability_type'] : 'none') . (!empty($this_item['ability_type2']) ? '_' . $this_item['ability_type2'] : '') . '" style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-item="' . $this_item_token . '" title="' . $this_item_title_plain . '" data-tooltip="' . $this_item_title_tooltip . '">' . $this_item_title_html . '</a>';
                    $item_key++;
                }
                if ($item_key <= 7) {
                    for ($item_key; $item_key <= 7; $item_key++) {
                        $empty_item_counter++;
                        if ($empty_item_counter >= 2) {
                            $empty_item_disable = true;
                        } else {
                            $empty_item_disable = false;
                        }
                        $temp_select_options = str_replace('value=""', 'value="" selected="selected" disabled="disabled"', $item_rewards_options);
                        $this_item_title_html = '<label>-</label>';
                        if ($global_allow_editing) {
                            $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_item_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>';
                        }
                        $temp_string[] = '<a class="ability_name " style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_item_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-item="" title="" data-tooltip="">' . $this_item_title_html . '</a>';
                    }
                }
            } else {
                for ($item_key = 0; $item_key <= 7; $item_key++) {
                    $empty_item_counter++;
                    if ($empty_item_counter >= 2) {
                        $empty_item_disable = true;
                    } else {
                        $empty_item_disable = false;
                    }
                    $temp_select_options = str_replace('value=""', 'value="" selected="selected"', $item_rewards_options);
                    $this_item_title_html = '<label>-</label>';
                    if ($global_allow_editing) {
                        $this_item_title_html .= '<select class="ability_name" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" ' . ($empty_item_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>';
                    }
                    $temp_string[] = '<a class="ability_name " style="' . (($item_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_item_disable ? 'opacity:0.25; ' : '') . (!$global_allow_editing ? 'cursor: default; ' : '') . '" data-key="' . $item_key . '" data-player="' . $player_info['player_token'] . '" data-robot="' . $robot_info['robot_token'] . '" data-ability="">' . $this_item_title_html . '</a>';
                }
            }
            // DEBUG
            //echo 'temp-string:';
            echo !empty($temp_string) ? implode(' ', $temp_string) : '';
            // DEBUG
            //echo '<br />temp-inputs:';
            echo !empty($temp_inputs) ? implode(' ', $temp_inputs) : '';
            // DEBUG
            //echo '<br />';
            ?>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                    <?php 
        }
        ?>

                    <?php 
        if (!empty($player_field_rewards) && rpg_prototype::campaign_complete($player_info['player_token'])) {
            ?>

                        <table class="full">
                            <colgroup>
                                <col width="100%" />
                            </colgroup>
                            <tbody>
                                <tr>
                                    <td class="right" style="padding-top: 4px;">
                                        <label class="field_header"><?php 
            echo $global_allow_editing ? 'Edit ' : '';
            ?>
Player Fields :</label>
                                        <div class="field_container" style="height: auto;">
                                        <?php 
            // Define the array to hold ALL the reward option markup
            $field_rewards_options = '';
            // Collect this player's field rewards and add them to the dropdown
            //$player_field_rewards = !empty($player_rewards['player_fields']) ? $player_rewards['player_fields'] : array();
            //if (!empty($player_field_rewards)){ sort($player_field_rewards); }
            // DEBUG
            //echo 'start:player_field_rewards:<pre style="font-size: 80%;">'.print_r($player_field_rewards, true).'</pre><br />';
            // DEBUG
            //echo 'before:player_field_rewards(keys):'.implode(',', array_keys($player_field_rewards)).'<br />';
            // DEBUG
            //$debug_tokens = array();
            //foreach ($player_field_rewards AS $info){ $debug_tokens[] = $info['field_token']; }
            //echo 'before:player_field_rewards(field_tokens):'.implode(',', array_values($debug_tokens)).'<br />';
            // Sort the field index based on field number
            uasort($player_field_rewards, array('rpg_functions', 'fields_sort_for_editor'));
            // DEBUG
            //echo 'after:player_field_rewards(keys):'.implode(',', array_keys($player_field_rewards)).'<br />';
            // DEBUG
            //$debug_tokens = array();
            //foreach ($player_field_rewards AS $info){ $debug_tokens[] = $info['field_token']; }
            //echo 'after:player_field_rewards(field_tokens):'.implode(',', array_values($debug_tokens)).'<br />';
            // Don't bother generating the option markup if disabled editing
            if ($global_allow_editing) {
                // Define the field group index for displau
                $temp_group_index = array('MMRPG' => 'Mega Man RPG Fields', 'MM00' => 'Mega Man Bonus Fields', 'MM01' => 'Mega Man 1 Fields', 'MM02' => 'Mega Man 2 Fields', 'MM03' => 'Mega Man 3 Fields', 'MM04' => 'Mega Man 4 Fields', 'MM05' => 'Mega Man 5 Fields', 'MM06' => 'Mega Man 6 Fields', 'MM07' => 'Mega Man 7 Fields', 'MM08' => 'Mega Man 8 Fields', 'MM09' => 'Mega Man 9 Fields', 'MM10' => 'Mega Man 10 Fields');
                // Loop through the group index and display any fields that match
                $player_field_rewards_backup = $player_field_rewards;
                foreach ($temp_group_index as $group_key => $group_name) {
                    $player_field_rewards_options = array();
                    foreach ($player_field_rewards_backup as $temp_field_key => $temp_field_info) {
                        if (empty($temp_field_info['field_game']) || $temp_field_info['field_game'] != $group_key) {
                            continue;
                        }
                        $temp_option_markup = rpg_field::print_editor_option_markup($temp_field_info);
                        if (!empty($temp_option_markup)) {
                            $player_field_rewards_options[] = $temp_option_markup;
                        }
                        unset($player_field_rewards_backup[$temp_field_key]);
                    }
                    if (empty($player_field_rewards_options)) {
                        continue;
                    }
                    $player_field_rewards_options = '<optgroup label="' . $group_name . '">' . implode('', $player_field_rewards_options) . '</optgroup>';
                    $field_rewards_options .= $player_field_rewards_options;
                }
            }
            // Add an option at the bottom to remove the field
            //$field_rewards_options .= '<optgroup label="Field Actions">';
            //$field_rewards_options .= '<option value="" title="">- Remove Field -</option>';
            //$field_rewards_options .= '</optgroup>';
            // Loop through the player's current fields and list them one by one
            $empty_field_counter = 0;
            $temp_string = array();
            $temp_inputs = array();
            $field_key = 0;
            if (!empty($player_info['player_fields_current'])) {
                // DEBUG
                //echo 'player-field:';
                $rpg_field_index = rpg_field::get_index();
                $player_info['player_fields_current'] = $player_info['player_fields_current'];
                //array_reverse($player_info['player_fields_current']);
                foreach ($player_info['player_fields_current'] as $player_field) {
                    if ($player_field['field_token'] == '*') {
                        continue;
                    } elseif (!isset($rpg_field_index[$player_field['field_token']])) {
                        continue;
                    } elseif ($field_key > 7) {
                        continue;
                    }
                    $this_field = rpg_field::parse_index_info($rpg_field_index[$player_field['field_token']]);
                    $this_field_token = $this_field['field_token'];
                    $this_robot_token = $this_field['field_master'];
                    $this_robot = rpg_robot::parse_index_info($mmrpg_database_robots[$this_robot_token]);
                    $this_field_name = $this_field['field_name'];
                    $this_field_type = !empty($this_field['field_type']) ? $this_field['field_type'] : false;
                    $this_field_type2 = !empty($this_field['field_type2']) ? $this_field['field_type2'] : false;
                    if (!empty($this_field_type) && !empty($mmrpg_index['types'][$this_field_type])) {
                        $this_field_type = $mmrpg_index['types'][$this_field_type]['type_name'] . ' Type';
                        if (!empty($this_field_type2) && !empty($mmrpg_index['types'][$this_field_type2])) {
                            $this_field_type = str_replace(' Type', ' / ' . $mmrpg_index['types'][$this_field_type2]['type_name'] . ' Type', $this_field_type);
                        }
                    } else {
                        $this_field_type = '';
                    }
                    $this_field_description = !empty($this_field['field_description']) ? $this_field['field_description'] : '';
                    $this_field_title = rpg_field::print_editor_title_markup($this_field);
                    $this_field_title_plain = strip_tags(str_replace('<br />', '&#10;', $this_field_title));
                    $this_field_title_tooltip = htmlentities($this_field_title, ENT_QUOTES, 'UTF-8');
                    $this_field_title_html = str_replace(' ', '&nbsp;', $this_field_name);
                    $temp_select_options = str_replace('value="' . $this_field_token . '"', 'value="' . $this_field_token . '" selected="selected" disabled="disabled"', $field_rewards_options);
                    $temp_field_type_class = 'field_type_' . (!empty($this_field['field_type']) ? $this_field['field_type'] : 'none') . (!empty($this_field['field_type2']) ? '_' . $this_field['field_type2'] : '');
                    if ($global_allow_editing && $temp_allow_field_switch) {
                        $this_field_title_html = '<label class="field_type  ' . $temp_field_type_class . '" style="">' . $this_field_title_html . '</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '">' . $temp_select_options . '</select>';
                    } elseif (!$global_allow_editing && $temp_allow_field_switch) {
                        $this_field_title_html = '<label class="field_type  ' . $temp_field_type_class . '" style="cursor: default !important;">' . $this_field_title_html . '</label>';
                    } else {
                        $this_field_title_html = '<label class="field_type ' . $temp_field_type_class . '" style="cursor: default !important;">' . $this_field_title_html . '</label>';
                    }
                    $temp_string[] = '<a class="field_name field_type ' . $temp_field_type_class . '" style="background-image: url(i/f/' . $this_field_token . '/bfp.png?' . MMRPG_CONFIG_CACHE_DATE . '); ' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . (!$temp_allow_field_switch || !$global_allow_editing ? 'cursor: default !important; ' : '') . (!$temp_allow_field_switch ? 'opacity: 0.50; filter: alpha(opacity=50); ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="' . $this_field_token . '" data-tooltip="' . $this_field_title_tooltip . '">' . $this_field_title_html . '</a>';
                    $field_key++;
                }
                if ($field_key <= 7) {
                    for ($field_key; $field_key <= 7; $field_key++) {
                        $empty_field_counter++;
                        if ($empty_field_counter >= 2) {
                            $empty_field_disable = true;
                        } else {
                            $empty_field_disable = false;
                        }
                        $temp_select_options = str_replace('value=""', 'value="" selected="selected" disabled="disabled"', $field_rewards_options);
                        $this_field_title_html = '<label>-</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_field_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>';
                        $temp_string[] = '<a class="field_name " style="' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_field_disable ? 'opacity:0.25; ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="" title="">' . $this_field_title_html . '</a>';
                    }
                }
            } else {
                for ($field_key = 0; $field_key <= 7; $field_key++) {
                    $empty_field_counter++;
                    if ($empty_field_counter >= 2) {
                        $empty_field_disable = true;
                    } else {
                        $empty_field_disable = false;
                    }
                    $temp_select_options = str_replace('value=""', 'value="" selected="selected"', $field_rewards_options);
                    $this_field_title_html = '<label>-</label><select class="field_name" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" ' . ($empty_field_disable ? 'disabled="disabled" ' : '') . '>' . $temp_select_options . '</select>';
                    $temp_string[] = '<a class="field_name " style="' . (($field_key + 1) % 4 == 0 ? 'margin-right: 0; ' : '') . ($empty_field_disable ? 'opacity:0.25; ' : '') . '" data-key="' . $field_key . '" data-player="' . $player_info['player_token'] . '" data-player="' . $player_info['player_token'] . '" data-field="" title="">' . $this_field_title_html . '</a>';
                }
            }
            // DEBUG
            //echo 'temp-string:';
            echo !empty($temp_string) ? implode(' ', $temp_string) : '';
            // DEBUG
            //echo '<br />temp-inputs:';
            echo !empty($temp_inputs) ? implode(' ', $temp_inputs) : '';
            // DEBUG
            //echo '<br />';
            // Collect the available star counts for this player
            $temp_star_counts = rpg_game::stars_available($player_token);
            ?>
                                        <div class="field_stars">
                                            <label class="label">stars</label>
                                            <span class="star star_field" data-star="field"><?php 
            echo $temp_star_counts['field'];
            ?>
 field</span>
                                            <span class="star star_fusion" data-star="fusion"><?php 
            echo $temp_star_counts['fusion'];
            ?>
 fusion</span>
                                        </div>
                                        <?php 
            // Print the sort wrapper and options if allowed
            if ($global_allow_editing) {
                ?>
                                            <div class="field_tools">
                                                <label class="label">tools</label>
                                                <a class="tool tool_shuffle" data-tool="shuffle" data-player="<?php 
                echo $player_token;
                ?>
">shuffle</a>
                                                <a class="tool tool_randomize" data-tool="randomize" data-player="<?php 
                echo $player_token;
                ?>
">randomize</a>
                                            </div>
                                            <?php 
            }
            ?>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                    <?php 
        }
        ?>


                </div>
            </div>
            <?php 
        $key_counter++;
        // Collect the outbut buffer contents
        $this_markup = trim(ob_get_clean());
        // Return the generated markup
        return $this_markup;
    }
コード例 #18
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;
 }
コード例 #19
0
<?php

// -- DR. LIGHT PASSWORDS -- //
// Collect the temp battle flags
$temp_flags = !empty($_SESSION['GAME']['flags']) ? $_SESSION['GAME']['flags'] : array();
// If the UNLOCK ROLL password was created
if (!empty($temp_flags['drlight_password_robotgetletsrocknroll'])) {
    if (!rpg_game::robot_unlocked(false, 'roll')) {
        // Unlock Roll as a playable character
        $unlock_player_info = $mmrpg_index['players']['dr-light'];
        $unlock_robot_info = rpg_robot::get_index_info('roll');
        $unlock_robot_info['robot_level'] = 1;
        $unlock_robot_info['robot_experience'] = rpg_prototype::calculate_experience(1) - 1;
        rpg_game::unlock_robot($unlock_player_info, $unlock_robot_info, true);
        header('Location: prototype.php');
        exit;
    }
}
// If the UNLOCK DEMO COMPLETE BONUS password was created
if (!empty($temp_flags['drlight_password_abilitygetdemocompletebonus'])) {
    // Only process if the Mega Buster has not yet been unlocked
    if ($_SESSION['GAME']['values']['battle_rewards']['dr-light']['player_points'] <= 0) {
        // Increase this player's score by 10,000 points
        $temp_bonus_points = 10000;
        $_SESSION['GAME']['counters']['battle_points'] += $temp_bonus_points;
        $_SESSION['GAME']['values']['battle_rewards']['dr-light']['player_points'] += $temp_bonus_points;
        // Unlock the Copy Shot for use in battle early
        rpg_game::unlock_ability($mmrpg_index['players']['dr-light'], false, array('ability_token' => 'copy-shot'), true);
        // Reset and return to the main menu
        header('Location: prototype.php');
        exit;
コード例 #20
0
 public static function player_select_markup($prototype_data, $player_token, $this_button_size = '1x4')
 {
     global $mmrpg_index, $db;
     $session_token = rpg_game::session_token();
     // Collect the player info
     $player_info = rpg_player::get_index_info($player_token);
     switch ($player_token) {
         case 'dr-light':
             $player_symbol = '&hearts;';
             $player_face = ':D';
             break;
         case 'dr-wily':
             $player_symbol = '&clubs;';
             $player_face = 'XD';
             break;
         case 'dr-cossack':
             $player_symbol = '&diams;';
             $player_face = '8D';
             break;
         default:
             $player_symbol = '';
             $player_face = ':|';
             break;
     }
     // Generate the markup for each of the robot sprites
     $temp_offset_x = 14;
     $temp_offset_z = 50;
     $temp_offset_y = -2;
     $temp_offset_opacity = 0.75;
     $text_sprites_markup = '';
     $temp_player_robots = rpg_game::robot_tokens_unlocked($player_token);
     //$_SESSION[$session_token]['values']['battle_settings'][$player_token]['player_robots'];
     // Collect the base index data for these robots
     $temp_token_string = array();
     foreach ($temp_player_robots as $token) {
         $temp_token_string[] = "'{$token}'";
     }
     $temp_token_string = implode(', ', $temp_token_string);
     $temp_robot_index = $db->get_array_list("SELECT * FROM mmrpg_index_robots WHERE robot_token IN ({$temp_token_string}) AND robot_flag_complete = 1;", 'robot_token');
     foreach ($temp_player_robots as $key => $robot_token) {
         $index = rpg_robot::parse_index_info($temp_robot_index[$robot_token]);
         $rewards = rpg_game::robot_rewards($player_token, $robot_token);
         $settings = rpg_game::robot_settings($player_token, $robot_token);
         $info = array_merge($index, $rewards, $settings);
         exit(PHP_EOL . PHP_EOL . $player_token . ' : ' . $robot_token . ' = ' . PHP_EOL . '$index = ' . print_r($index, true) . '$rewards = ' . print_r($rewards, true) . '$settings = ' . print_r($settings, true) . PHP_EOL . PHP_EOL);
         if (rpg_game::robot_unlocked($player_token, $robot_token)) {
             $temp_size = !empty($info['robot_image_size']) ? $info['robot_image_size'] : 40;
             $temp_size_text = $temp_size . 'x' . $temp_size;
             $temp_offset_x += $temp_size > 40 ? 0 : 20;
             $temp_offset_y = $temp_size > 40 ? -42 : -2;
             $temp_offset_z -= 1;
             $temp_offset_opacity -= 0.05;
             if ($temp_offset_opacity <= 0) {
                 $temp_offset_opacity = 0;
                 break;
             }
             $text_sprites_markup .= '<span class="sprite sprite_nobanner sprite_' . $temp_size_text . ' sprite_' . $temp_size_text . '_base" style="background-image: url(i/r/' . (!empty($info['robot_image']) ? $info['robot_image'] : $info['robot_token']) . '/sr' . $temp_size . '.png?' . MMRPG_CONFIG_CACHE_DATE . '); top: ' . $temp_offset_y . 'px; right: ' . $temp_offset_x . 'px;">' . $info['robot_name'] . '</span>';
             if ($temp_size > 40) {
                 $temp_offset_x += 20;
             }
         }
     }
     exit(PHP_EOL . PHP_EOL . $player_token . ' = ' . print_r($temp_robot_index, true) . PHP_EOL . PHP_EOL);
     // Generate the markup for the rest of the player container
     $text_robots_unlocked = number_format($prototype_data['robots_unlocked'], 0, '.', ',') . ' Robot' . ($prototype_data['robots_unlocked'] != 1 ? 's' : '');
     $text_abilities_unlocked = number_format($prototype_data['abilities_unlocked'], 0, '.', ',') . ' Ability' . ($prototype_data['abilities_unlocked'] != 1 ? 's' : '');
     $text_points_unlocked = number_format($prototype_data['points_unlocked'], 0, '.', ',') . ' Point' . ($prototype_data['points_unlocked'] != 1 ? 's' : '');
     $text_battles_complete = number_format($prototype_data['battles_complete'], 0, '.', ',') . ' Mission' . ($prototype_data['battles_complete'] != 1 ? 's' : '');
     $text_player_special = $prototype_data['prototype_complete'] ? true : false;
     $text_player_music = rpg_prototype::get_player_mission_music($player_token, $session_token);
     $text_sprites_markup = '<span class="sprite sprite_player sprite_40x40 sprite_40x40_base" style="background-image: url(images/sprites/players/' . $player_token . '/sprite_right_40x40.png); top: -2px; right: 14px;">' . $player_info['player_name'] . '</span>';
     $text_sprites_markup .= $text_sprites_markup;
     $text_player_subtext = $text_robots_unlocked;
     $text_player_subtext = $text_abilities_unlocked;
     // Put it all together for the player select markup
     $player_select_markup = '';
     $player_select_markup .= '<a data-music-token="' . $text_player_music . '" data-battle-complete="' . $prototype_data['battles_complete'] . '" class="option option_' . $this_button_size . ' option_this-player-select option_this-' . $player_token . '-player-select option_' . $player_token . ' block_1" data-token="' . $player_token . '">';
     $player_select_markup .= '<div class="platform"><div class="chrome"><div class="inset">';
     $player_select_markup .= '<label class="has_image">';
     $player_select_markup .= '<span class="multi">';
     $player_select_markup .= $text_sprites_markup;
     $player_select_markup .= '<span class="maintext">';
     $player_select_markup .= $player_info['player_name'] . (!empty($text_player_special) ? ' <span style="position: relative; bottom: 2px;" title="Thank you for playing!!! ' . $player_face . '">' . $player_symbol . '</span>' : '') . '</span><span class="subtext">' . $text_player_subtext . '</span><span class="subtext2">' . $text_points_unlocked . '</span></span><span class="arrow">&#9658;</span></label>';
     $player_select_markup .= '</div></div></div>';
     $player_select_markup .= '</a>' . "\n";
     // Return the generated markup
     return $player_select_markup;
 }
コード例 #21
0
ファイル: robots.php プロジェクト: AdrianMarceau/mmrpg-world
// Collect the database robots and fields
$field_fields = rpg_field::get_index_fields(true);
$robot_fields = rpg_robot::get_index_fields(true);
$db->query("SET @robot_row_number = 0;");
$mmrpg_database_fields = $db->get_array_list("SELECT {$field_fields} FROM mmrpg_index_fields WHERE field_flag_published = 1;", 'field_token');
$mmrpg_database_robots = $db->get_array_list("SELECT {$robot_fields} FROM mmrpg_index_robots WHERE robot_flag_published = 1 AND (robot_flag_hidden = 0 OR robot_token = '{$this_current_token}') {$temp_condition} ORDER BY robot_flag_hidden ASC, robot_order ASC;", 'robot_token');
$mmrpg_database_robots_count = $db->get_value("SELECT COUNT(robot_id) AS robot_count FROM mmrpg_index_robots WHERE robot_flag_published = 1 AND robot_flag_hidden = 0 {$temp_condition_unfiltered};", 'robot_count');
$mmrpg_database_robots_numbers = $db->get_array_list("SELECT robot_token, (@robot_row_number:=@robot_row_number + 1) AS robot_key FROM mmrpg_index_robots WHERE robot_flag_published = 1 {$temp_condition_unfiltered} ORDER BY robot_flag_hidden ASC, robot_order ASC;", 'robot_token');
// Remove unallowed robots from the database, and increment type counters
foreach ($mmrpg_database_robots as $temp_token => $temp_info) {
    // Define first robot token if not set
    if (!isset($first_robot_token)) {
        $first_robot_token = $temp_token;
    }
    // Send this data through the robot index parser
    $temp_info = rpg_robot::parse_index_info($temp_info);
    // Collect this robot's key in the index
    $temp_info['robot_key'] = $mmrpg_database_robots_numbers[$temp_token]['robot_key'];
    // Ensure this robot's image exists, else default to the placeholder
    if ($temp_info['robot_flag_complete']) {
        $temp_info['robot_image'] = $temp_token;
    } else {
        $temp_info['robot_image'] = 'robot';
    }
    // Modify the name of this robot if it is of the mecha class
    if ($temp_info['robot_class'] == 'mecha' && defined('DATA_DATABASE_SHOW_MECHAS')) {
        // Collect this mecha's field token, then robot master token, then robot master number
        $temp_field_token = $temp_info['robot_field'];
        $temp_field_info = !empty($mmrpg_database_fields[$temp_field_token]) ? rpg_field::parse_index_info($mmrpg_database_fields[$temp_field_token]) : array();
        $temp_master_token = !empty($temp_field_info['field_master']) ? $temp_field_info['field_master'] : 'met';
        $temp_master_number = $mmrpg_database_robots[$temp_master_token]['robot_number'];
コード例 #22
0
            unset($temp_index);
        } else {
            break;
        }
    }
} else {
    $temp_top_robots_method = 'most-used';
}
if (count($temp_top_robots) < $temp_top_robots_counter) {
    foreach ($temp_counter_levels as $token => $value) {
        if (in_array($token, $temp_top_robots_tokens)) {
            continue;
        }
        if (count($temp_top_robots) < $temp_top_robots_counter) {
            $temp_top_robots_tokens[] = $token;
            $temp_index = rpg_robot::parse_index_info($temp_robots_index[$token]);
            $temp_top_robots[] = '<strong>' . $temp_index['robot_name'] . '</strong>';
            unset($temp_index);
        } else {
            break;
        }
    }
}
//die('<pre>$temp_top_robots = '.print_r($temp_top_robots, true).'</pre>');
// Require the leaderboard data file
define('MMRPG_SKIP_MARKUP', true);
define('MMRPG_SHOW_MARKUP_' . $this_playerinfo['user_id'], true);
require 'includes/leaderboard.php';
// Define whether or not the players or starforce tabs should be open
$temp_remote_session = $this_playerinfo['user_id'] != $_SESSION['GAME']['USER']['userid'] ? true : false;
$temp_show_players = true;
コード例 #23
0
    $player_options_markup = '';
    foreach ($allowed_edit_data as $ptoken => $pinfo) {
        $temp_robot_totals[$ptoken] = !empty($pinfo['player_robots']) ? count($pinfo['player_robots']) : 0;
        $temp_player_battles = rpg_prototype::battles_complete($ptoken);
        $temp_player_transfer = $temp_player_battles >= 1 ? true : false;
        $player_options_markup .= '<option value="' . $pinfo['player_token'] . '" data-label="' . $pinfo['player_token'] . '" title="' . $pinfo['player_name'] . '" ' . (!$temp_player_transfer ? 'disabled="disabled"' : '') . '>' . $pinfo['player_name'] . '</option>';
        $player_counter++;
    }
    foreach ($allowed_edit_data as $temp_player_token => $temp_player_info) {
        if ($temp_player_token == $temp_new_player) {
            $debug_robot_tokens = array();
            foreach ($temp_player_info['player_robots'] as $rtoken => $rinfo) {
                $debug_robot_tokens[] = $rtoken;
            }
            $player_rewards = rpg_game::player_rewards($temp_player_token);
            $player_ability_rewards = !empty($player_rewards['player_abilities']) ? $player_rewards['player_abilities'] : array();
            if (!empty($player_ability_rewards)) {
                asort($player_ability_rewards);
            }
            //exit('success|player-swapped|<pre style="text-align: left; width: 300px;">'.implode(',', $debug_robot_tokens).'</pre>');
            $temp_robot_info = $temp_player_info['player_robots'][$temp_robot];
            $temp_robot_info['robot_settings'] = $temp_robot_settings;
            $temp_robot_info['robot_rewards'] = $temp_robot_rewards;
            $first_robot_token = $temp_robot_info['robot_token'];
            exit('success|player-swapped|' . rpg_robot::print_editor_markup($temp_player_info, $temp_robot_info));
        }
    }
} else {
    // Produce the error message
    exit('error|robot-undefined|false');
}
コード例 #24
0
echo '<a class="ability_name" style="" data-id="0" data-key="0" data-player="player" data-robot="robot" data-ability="" title="" data-tooltip=""><label>- Remove Ability -</label></a>';
// Loop through and print abilities
$key_counter = 1;
if (!empty($mmrpg_database_abilities)) {
    $row_count = 4;
    $column_count = ceil(count($mmrpg_database_abilities) / $row_count);
    // Collect this player's ability rewards and add them to the dropdown
    if (!empty($_SESSION[$session_token]['values']['battle_abilities'])) {
        $player_ability_rewards = $_SESSION[$session_token]['values']['battle_abilities'];
    } elseif (!empty($player_rewards['player_abilities'])) {
        $player_ability_rewards = array('buster-shot' => array('ability_token' => 'buster-shot'));
    }
    // Create a fake player and robot to pass the info check
    $player_info = $mmrpg_index['players']['player'];
    //rpg_player::get_index_info('player'); //array('player_token' => 'player', 'player_name' => 'Player');
    $robot_info = rpg_robot::get_index_info('robot');
    //array('robot_token' => 'robot', 'robot_name' => 'Robot');
    // Sort the ability rewards based on ability number and such
    uasort($player_ability_rewards, array('rpg_functions', 'abilities_sort_for_editor'));
    $robot_ability_rewards = array();
    // Collect the ability reward options to be used on all selects
    $ability_rewards_options = $global_allow_editing ? rpg_ability::print_editor_options_list_markup($player_ability_rewards, $robot_ability_rewards, $player_info, $robot_info) : '';
    foreach ($mmrpg_database_abilities as $ability_token => $ability_info) {
        if (!rpg_game::ability_unlocked('', '', $ability_token)) {
            continue;
        }
        //if ($key_counter > 0 && $key_counter % 5 == 0){ echo '</tr><tr>'; }
        //echo '<td>';
        $temp_select_markup = rpg_ability::print_editor_select_markup($ability_rewards_options, $player_info, $robot_info, $ability_info, $key_counter);
        //echo $ability_token.'<br />';
        echo $temp_select_markup . ' ';
コード例 #25
0
                     elseif ($active && $sort_direction == 'desc'){ echo ' <sup>&#8593;</sup>'; }
                 echo '</th>'.PHP_EOL;
             } else {
                 echo '<th class="'.$class.'">&nbsp;</th>'.PHP_EOL;
             }
         }
         ?>
     </tr>
 </thead>
 <tbody>
     <?
     // Loop through collected robots and list their details
     if (!empty($robot_index)){
         foreach ($robot_index AS $robot_id => $robot_info){
             // Parse the robot info before displaying it
             $robot_info = rpg_robot::parse_index_info($robot_info);
             // Collect the display fields from the array
             $robot_token = $robot_info['robot_token'];
             $robot_name = $robot_info['robot_name'];
             $robot_group = '<span class="token">'.$robot_info['robot_group'].'</span>';
             $robot_type1 = !empty($robot_info['robot_core']) && !empty($type_index[$robot_info['robot_core']]) ? $type_index[$robot_info['robot_core']] : $type_index['none'];
             $robot_type2 = !empty($robot_info['robot_core2']) && !empty($type_index[$robot_info['robot_core2']]) ? $type_index[$robot_info['robot_core2']] : false;
             if (!empty($robot_type2)){ $type_string = '<span class="type '.$robot_type1['type_token'].'_'.$robot_type2['type_token'].'">'.$robot_type1['type_name'].' / '.$robot_type2['type_name'].'</span>'; }
             else { $type_string = '<span class="type '.$robot_type1['type_token'].'">'.$robot_type1['type_name'].'</span>'; }
             $edit_link = 'admin/'.$object_multi_token.'/'.$robot_id.'/';
             $view_link = 'database/'.$object_multi_token.'/'.$robot_token.'/';
             $complete = $robot_info['robot_flag_complete'] ? true : false;
             $published = $robot_info['robot_flag_published'] ? true : false;
             $hidden = $robot_info['robot_flag_hidden'] ? true : false;
             // Print out the robot info as a table row
             ?>
コード例 #26
0
 public static function print_editor_option_markup($robot_info, $item_info)
 {
     // Pull in global variables
     $session_token = rpg_game::session_token();
     // Require the function file
     $this_option_markup = '';
     // Generate the item option markup
     if (empty($robot_info)) {
         return false;
     }
     if (empty($item_info)) {
         return false;
     }
     //$item_info = rpg_item::get_index_info($temp_item_token);
     $temp_robot_token = $robot_info['robot_token'];
     $temp_item_token = $item_info['item_token'];
     $robot_item_core = !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : '';
     $robot_flag_copycore = !empty($robot_info['robot_core']) && $robot_info['robot_core'] == 'copy' ? true : false;
     $temp_item_type = !empty($item_info['item_type']) ? rpg_type::get_index_info($item_info['item_type']) : false;
     $temp_item_type2 = !empty($item_info['item_type2']) ? rpg_type::get_index_info($item_info['item_type2']) : false;
     $temp_item_energy = rpg_robot::calculate_weapon_energy_static($robot_info, $item_info);
     $temp_type_array = array();
     $temp_incompatible = false;
     $temp_global_items = self::get_global_items();
     $temp_index_items = !empty($robot_info['robot_index_items']) ? $robot_info['robot_index_items'] : array();
     $temp_current_items = !empty($robot_info['robot_items']) ? array_keys($robot_info['robot_items']) : array();
     $temp_compatible_items = array_merge($temp_global_items, $temp_index_items, $temp_current_items);
     //while (!in_array($temp_item_token, $robot_info['robot_items'])){
     while (!in_array($temp_item_token, $temp_compatible_items)) {
         if (!$robot_flag_copycore) {
             if (empty($robot_item_core)) {
                 $temp_incompatible = true;
                 break;
             } elseif (empty($temp_item_type) && empty($temp_item_type2)) {
                 $temp_incompatible = true;
                 break;
             } else {
                 if (!empty($temp_item_type)) {
                     $temp_type_array[] = $temp_item_type['type_token'];
                 }
                 if (!empty($temp_item_type2)) {
                     $temp_type_array[] = $temp_item_type2['type_token'];
                 }
                 if (!in_array($robot_item_core, $temp_type_array)) {
                     $temp_incompatible = true;
                     break;
                 }
             }
         }
         break;
     }
     if ($temp_incompatible == true) {
         return false;
     }
     $temp_item_label = $item_info['item_name'];
     $temp_item_title = rpg_item::print_editor_title_markup($robot_info, $item_info);
     $temp_item_title_plain = strip_tags(str_replace('<br />', '&#10;', $temp_item_title));
     $temp_item_title_tooltip = htmlentities($temp_item_title, ENT_QUOTES, 'UTF-8');
     $temp_item_option = $item_info['item_name'];
     if (!empty($temp_item_type)) {
         $temp_item_option .= ' | ' . $temp_item_type['type_name'];
     }
     if (!empty($temp_item_type2)) {
         $temp_item_option .= ' / ' . $temp_item_type2['type_name'];
     }
     if (!empty($item_info['item_damage'])) {
         $temp_item_option .= ' | D:' . $item_info['item_damage'];
     }
     if (!empty($item_info['item_recovery'])) {
         $temp_item_option .= ' | R:' . $item_info['item_recovery'];
     }
     if ($item_info['item_class'] != 'item' && !empty($item_info['item_accuracy'])) {
         $temp_item_option .= ' | A:' . $item_info['item_accuracy'];
     } elseif ($item_info['item_class'] == 'item' && !empty($_SESSION[$session_token]['values']['battle_items'][$temp_item_token])) {
         $temp_item_option .= ' | U:' . $_SESSION[$session_token]['values']['battle_items'][$temp_item_token];
     } elseif ($item_info['item_class'] == 'item') {
         $temp_item_option .= ' | U:0';
     }
     if (!empty($temp_item_energy)) {
         $temp_item_option .= ' | E:' . $temp_item_energy;
     }
     // Return the generated option markup
     $this_option_markup = '<option value="' . $temp_item_token . '" data-label="' . $temp_item_label . '" data-type="' . (!empty($temp_item_type) ? $temp_item_type['type_token'] : 'none') . '" data-type2="' . (!empty($temp_item_type2) ? $temp_item_type2['type_token'] : '') . '" title="' . $temp_item_title_plain . '" data-tooltip="' . $temp_item_title_tooltip . '">' . $temp_item_option . '</option>';
     // Return the generated option markup
     return $this_option_markup;
 }
コード例 #27
0
        $allow_player_selector_backup = $allow_player_selector;
        // Collect this player's ability rewards and add them to the dropdown
        if (!empty($_SESSION[$session_token]['values']['battle_abilities'])) {
            $player_ability_rewards = $_SESSION[$session_token]['values']['battle_abilities'];
        } elseif (!empty($player_rewards['player_abilities'])) {
            $player_ability_rewards = $player_rewards['player_abilities'];
        } else {
            $player_ability_rewards = array();
        }
        //$player_ability_rewards = !empty($player_rewards['player_abilities']) ? $player_rewards['player_abilities'] : array();
        if (!empty($player_ability_rewards)) {
            asort($player_ability_rewards);
        }
        // Collect and print the editor markup for this robot
        if (!empty($_REQUEST['player']) && $_REQUEST['player'] == $player_info['player_token'] && !empty($_REQUEST['robot']) && $_REQUEST['robot'] == $robot_info['robot_token']) {
            $temp_editor_markup = rpg_robot::print_editor_markup($player_info, $robot_info);
            echo $temp_editor_markup;
            // Collect the contents of the buffer
            $edit_console_markup = ob_get_clean();
            $edit_console_markup = preg_replace('/\\s+/', ' ', trim($edit_console_markup));
            exit($edit_console_markup);
        }
        $key_counter++;
        // Return the backup of the player selector
        $allow_player_selector = $allow_player_selector_backup;
    }
}
// Collect the contents of the buffer
$edit_console_markup = ob_get_clean();
$edit_console_markup = preg_replace('/\\s+/', ' ', trim($edit_console_markup));
exit($edit_console_markup);
コード例 #28
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;
    }