예제 #1
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;
 }
예제 #2
0
if ($this_action != 'start') {
    // Define the battle object using the loaded battle data and update session
    $this_battle = new rpg_battle($this_battleinfo);
    // Load the object data for this field from the session
    $this_field = new rpg_field($this_fieldinfo);
    // Load the object data for this and the target player from the battle
    echo basename(__FILE__) . ' on line ' . __LINE__ . "\n";
    $this_player = $this_battle->get_player($this_player_id);
    echo basename(__FILE__) . ' on line ' . __LINE__ . "\n";
    $target_player = $this_battle->get_player($target_player_id);
    // Load the object data for this and the target robot from the battle
    $this_robot = $this_battle->get_robot($this_robot_id);
    $target_robot = $this_battle->get_robot($target_robot_id);
} elseif ($this_action == 'start') {
    // Collect the preset battle info from the index
    $this_preset_battle = rpg_battle::get_index_info($this_battleinfo['battle_token']);
    if (!empty($this_preset_battle)) {
        $this_battleinfo = array_replace($this_preset_battle, $this_battleinfo);
    }
    // Define the battle object using the loaded battle data and update session
    $this_battle = new rpg_battle($this_battleinfo);
    // Start the battle turn off at zero
    $this_battle->set_counter('battle_turn', 0);
    // Collect preset field info from the battle
    $this_preset_field = $this_battle->get_field_info();
    if (!empty($this_preset_field)) {
        $this_fieldinfo = array_replace($this_preset_field, $this_fieldinfo);
    }
    // Collect this player's preset info from the battle
    $this_preset_player = $this_battle->get_this_player();
    if (!empty($this_preset_player)) {
예제 #3
0
 public static function options_markup(&$battle_options, $player_token)
 {
     // Refence the global config and index objects for easy access
     global $mmrpg_index, $db;
     $mmrpg_index_fields = rpg_field::get_index();
     // Define the variable to collect option markup
     $this_markup = '';
     // Count the number of completed battle options for this group and update the variable
     foreach ($battle_options as $this_key => $this_info) {
         // Define the chapter if not set
         if (!isset($this_info['option_chapter'])) {
             $this_info['option_chapter'] = '0';
         }
         // If this is an event message type option, simply display the text/images
         if (!empty($this_info['option_type']) && $this_info['option_type'] == 'message') {
             // Generate the option markup for the event message
             $temp_optiontitle = $this_info['option_maintext'];
             $temp_optionimages = !empty($this_info['option_images']) ? $this_info['option_images'] : '';
             $temp_optiontext = '<span class="multi"><span class="maintext">' . $this_info['option_maintext'] . '</span></span>';
             $this_markup .= '<a data-chapter="' . $this_info['option_chapter'] . '" class="option option_message option_1x4 option_this-' . $player_token . '-message" style="' . (!empty($this_info['option_style']) ? $this_info['option_style'] : '') . '"><div class="chrome"><div class="inset"><label class="' . (!empty($temp_optionimages) ? 'has_image' : '') . '">' . $temp_optionimages . $temp_optiontext . '</label></div></div></a>' . "\n";
         } else {
             // If the skip flag is set, continue to the next index
             //if (isset($this_info['flag_skip']) && $this_info['flag_skip'] == true){ continue; }
             // Collect the current battle and field info from the index
             if (!isset($this_info['battle_token'])) {
                 echo '$this_key(' . $this_key . ') = ' . print_r($this_info, true);
             }
             $this_battleinfo = rpg_battle::get_index_info($this_info['battle_token']);
             //if (!empty($this_battleinfo)){ $this_battleinfo = array_replace($this_battleinfo, $this_info); }
             $temp_flags = isset($this_battleinfo['flags']) ? $this_battleinfo['flags'] : array();
             $temp_values = isset($this_battleinfo['values']) ? $this_battleinfo['values'] : array();
             $temp_counters = isset($this_battleinfo['counters']) ? $this_battleinfo['counters'] : array();
             if (!empty($this_battleinfo)) {
                 $this_battleinfo = array_merge($this_battleinfo, $this_info);
             } else {
                 $this_battleinfo = $this_info;
             }
             $this_battleinfo['flags'] = !empty($this_battleinfo['flags']) ? array_merge($this_battleinfo['flags'], $temp_flags) : $temp_flags;
             $this_battleinfo['values'] = !empty($this_battleinfo['values']) ? array_merge($this_battleinfo['values'], $temp_values) : $temp_values;
             $this_battleinfo['counters'] = !empty($this_battleinfo['counters']) ? array_merge($this_battleinfo['counters'], $temp_counters) : $temp_counters;
             //if (!is_array($this_battleinfo['battle_field_info'])){ echo('Key '.$this_key.' in $battle_options_reversed = <pre>'.print_r($battle_options_reversed, true).'</pre>'); }
             //if (!is_array($this_battleinfo['battle_field_info'])){ echo('$this_battleinfo[\'battle_field_info\'] = <pre>'.print_r($this_battleinfo, true).'</pre>'); }
             //if (!is_array($this_battleinfo['battle_field_info'])){ echo('$db->INDEX[\'BATTLES\']['.$this_info['battle_token'].'] = <pre>'.print_r($db->INDEX['BATTLES'][$this_info['battle_token']], true).'</pre>'); }
             if (!isset($this_battleinfo['battle_field_info'])) {
                 echo print_r($this_battleinfo, true);
             }
             $this_fieldtoken = $this_battleinfo['battle_field_info']['field_token'];
             $this_fieldinfo = !empty($mmrpg_index_fields[$this_fieldtoken]) ? array_replace(rpg_field::parse_index_info($mmrpg_index_fields[$this_fieldtoken]), $this_battleinfo['battle_field_info']) : $this_battleinfo['battle_field_info'];
             $this_targetinfo = !empty($mmrpg_index['players'][$this_battleinfo['battle_target_player']['player_token']]) ? array_replace($mmrpg_index['players'][$this_battleinfo['battle_target_player']['player_token']], $this_battleinfo['battle_target_player']) : $this_battleinfo['battle_target_player'];
             // 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');
             // Check the GAME session to see if this battle has been completed, increment the counter if it was
             $this_battleinfo['battle_option_complete'] = rpg_prototype::battle_complete($player_token, $this_info['battle_token']);
             $this_battleinfo['battle_option_failure'] = rpg_prototype::battle_failure($player_token, $this_info['battle_token']);
             // Generate the markup fields for display
             $this_option_token = $this_battleinfo['battle_token'];
             $this_option_limit = !empty($this_battleinfo['battle_robots_limit']) ? $this_battleinfo['battle_robots_limit'] : 8;
             $this_option_frame = !empty($this_battleinfo['battle_sprite_frame']) ? $this_battleinfo['battle_sprite_frame'] : 'base';
             $this_option_status = !empty($this_battleinfo['battle_status']) ? $this_battleinfo['battle_status'] : 'enabled';
             $this_option_points = !empty($this_battleinfo['battle_points']) ? $this_battleinfo['battle_points'] : 0;
             $this_option_complete = $this_battleinfo['battle_option_complete'];
             $this_option_failure = $this_battleinfo['battle_option_failure'];
             $this_option_targets = !empty($this_targetinfo['player_robots']) ? count($this_targetinfo['player_robots']) : 0;
             $this_option_encore = isset($this_battleinfo['battle_encore']) ? $this_battleinfo['battle_encore'] : true;
             $this_option_disabled = !empty($this_option_complete) && !$this_option_encore ? true : false;
             $this_has_field_star = !empty($this_battleinfo['values']['field_star']) && !rpg_game::star_unlocked($this_battleinfo['values']['field_star']['star_token']) ? true : false;
             $this_has_dark_tower = !empty($this_battleinfo['flags']['dark_tower']) ? true : false;
             $this_option_class = 'option option_fieldback option_this-' . $player_token . '-battle-select option_' . $this_battleinfo['battle_size'] . ' option_' . $this_option_status . ' block_' . ($this_key + 1) . ' ' . ($this_option_complete && !$this_has_field_star && !$this_has_dark_tower ? 'option_complete ' : '') . ($this_option_disabled ? 'option_disabled ' . ($this_option_encore ? 'option_disabled_clickable ' : '') : '');
             $this_option_style = 'background-position: -' . mt_rand(5, 50) . 'px -' . mt_rand(5, 50) . 'px; ';
             if (!empty($this_fieldinfo['field_type'])) {
                 $this_option_class .= 'field_type field_type_' . $this_fieldinfo['field_type'] . (!empty($this_fieldinfo['field_type2']) && $this_fieldinfo['field_type2'] != $this_fieldinfo['field_type'] ? '_' . $this_fieldinfo['field_type2'] : '');
             } else {
                 $this_option_class .= 'field_type field_type_none';
             }
             if (!empty($this_fieldinfo['field_background'])) {
                 //$this_background_x = $this_background_y = -20;
                 //$this_option_style = 'background-position: 0 0; background-size: 100% auto; background-image: url(images/sprites/fields/'.$this_fieldinfo['field_background'].'/battle-field_preview.png?'.MMRPG_CONFIG_CACHE_DATE.'); ';
                 $this_option_style = 'background-image: url(images/sprites/fields/' . $this_fieldinfo['field_background'] . '/battle-field_preview.png?' . MMRPG_CONFIG_CACHE_DATE . ') !important; ';
             }
             $this_option_label = '';
             $this_option_platform_style = '';
             if (!empty($this_fieldinfo['field_foreground'])) {
                 //$this_background_x = $this_background_y = -20;
                 //$this_option_platform_style = 'background-position: 0 -76px; background-size: 100% auto; background-image: url(images/sprites/fields/'.$this_fieldinfo['field_foreground'].'/battle-field_foreground_base.png?'.MMRPG_CONFIG_CACHE_DATE.'); ';
                 $this_option_platform_style = 'background-image: url(images/sprites/fields/' . $this_fieldinfo['field_foreground'] . '/battle-field_foreground_base.png?' . MMRPG_CONFIG_CACHE_DATE . '); ';
             }
             $this_option_min_level = false;
             $this_option_max_level = false;
             $this_option_star_boost = !empty($this_targetinfo['player_starforce']) ? array_sum($this_targetinfo['player_starforce']) : 0;
             $this_battleinfo['battle_sprite'] = array();
             $this_targetinfo = !empty($mmrpg_index['players'][$this_targetinfo['player_token']]) ? array_merge($mmrpg_index['players'][$this_targetinfo['player_token']], $this_targetinfo) : $mmrpg_index['players']['player'];
             if ($this_targetinfo['player_token'] != 'player') {
                 $this_battleinfo['battle_sprite'][] = array('path' => 'players/' . $this_targetinfo['player_token'], 'size' => !empty($this_targetinfo['player_image_size']) ? $this_targetinfo['player_image_size'] : 40);
             }
             if (!empty($this_targetinfo['player_robots'])) {
                 // Count the number of masters in this battle
                 $this_master_count = 0;
                 $this_mecha_count = 0;
                 $temp_robot_tokens = array();
                 foreach ($this_targetinfo['player_robots'] as $robo_key => $this_robotinfo) {
                     //if (empty($this_robotinfo['robot_token'])){ die('<pre>'.$this_battleinfo['battle_token'].print_r($this_robotinfo, true).'</pre>'); }
                     if ($this_robotinfo['robot_token'] == 'robot') {
                         unset($this_targetinfo['player_robots'][$robo_key]);
                         continue;
                     }
                     if (isset($this_robot_index[$this_robotinfo['robot_token']])) {
                         $this_robotindex = rpg_robot::parse_index_info($this_robot_index[$this_robotinfo['robot_token']]);
                     } else {
                         continue;
                     }
                     $temp_robot_tokens[] = $this_robotinfo['robot_token'];
                     $this_robotinfo = array_merge($this_robotindex, $this_robotinfo);
                     $this_targetinfo['player_robots'][$robo_key] = $this_robotinfo;
                     if (!empty($this_robotinfo['robot_class']) && $this_robotinfo['robot_class'] == 'mecha') {
                         $this_mecha_count++;
                     } elseif (empty($this_robotinfo['robot_class']) || $this_robotinfo['robot_class'] == 'master') {
                         $this_master_count++;
                     }
                     unset($this_robotindex);
                 }
                 $temp_robot_tokens = array_unique($temp_robot_tokens);
                 $temp_robot_tokens_count = count($temp_robot_tokens);
                 $temp_robot_target_count = count($this_targetinfo['player_robots']);
                 // Create a list of the different robot tokens in this battle
                 // Now loop through robots again and display 'em
                 foreach ($this_targetinfo['player_robots'] as $this_robotinfo) {
                     // HIDE MECHAS
                     if (empty($this_battleinfo['flags']['starter_battle']) && empty($this_battleinfo['flags']['player_battle']) && !empty($this_robotinfo['robot_class']) && $this_robotinfo['robot_class'] == 'mecha' && $temp_robot_tokens_count > 1 && $this_master_count > 0) {
                         continue;
                     }
                     // HIDE MECHAS in FORTRESS
                     if (!empty($this_battleinfo['flags']['fortress_battle']) && !empty($this_robotinfo['robot_class']) && $this_robotinfo['robot_class'] == 'mecha') {
                         continue;
                     }
                     // HIDE HIDDEN
                     if (!empty($this_robotinfo['flags']['hide_from_mission_select'])) {
                         continue;
                     }
                     $this_robotinfo['robot_image'] = !empty($this_robotinfo['robot_image']) ? $this_robotinfo['robot_image'] : $this_robotinfo['robot_token'];
                     //if (!empty($this_battleinfo['flags']['player_battle'])){ $this_robotinfo['robot_image'] = 'robot'; }
                     //if (!empty($this_robotinfo['flags']['hide_from_mission_'])){ $temp_path = 'robots/robot'; }
                     //else { $temp_path = 'robots/'.$this_robotinfo['robot_image']; }
                     //$temp_path = 'robots/'.(empty($this_battleinfo['flags']['player_battle']) ? $this_robotinfo['robot_image'] : 'robot');
                     $temp_path = 'robots/' . $this_robotinfo['robot_image'];
                     $temp_size = !empty($this_robotinfo['robot_image_size']) ? $this_robotinfo['robot_image_size'] : 40;
                     if (!empty($this_battleinfo['flags']['player_battle'])) {
                         $temp_path = in_array($this_robotinfo['robot_token'], array('roll', 'disco', 'rhythm', 'splash-woman')) ? 'robots/robot2' : 'robots/robot';
                         $temp_size = 40;
                     }
                     $this_battleinfo['battle_sprite'][] = array('path' => $temp_path, 'size' => $temp_size);
                     $this_robot_level = !empty($this_robotinfo['robot_level']) ? $this_robotinfo['robot_level'] : 1;
                     if ($this_option_min_level === false || $this_option_min_level > $this_robot_level) {
                         $this_option_min_level = $this_robot_level;
                     }
                     if ($this_option_max_level === false || $this_option_max_level < $this_robot_level) {
                         $this_option_max_level = $this_robot_level;
                     }
                 }
             }
             // Add the field/fusion star sprite if one has been added
             if ($this_has_field_star) {
                 //$this_option_complete = false;
                 $this_option_disabled = false;
                 // Check if this is a field star or fusion star
                 $temp_star_data = $this_battleinfo['values']['field_star'];
                 //die('<pre>'.print_r($temp_star_data, true).'</pre>');
                 $temp_star_kind = $temp_star_data['star_kind'];
                 // Collect the star image info from the index based on type
                 $temp_field_type_1 = !empty($temp_star_data['star_type']) ? $temp_star_data['star_type'] : 'none';
                 $temp_field_type_2 = !empty($temp_star_data['star_type2']) ? $temp_star_data['star_type2'] : $temp_field_type_1;
                 // If this is a field star, we can add sprite normally
                 if ($temp_star_kind == 'field') {
                     $temp_star_back_info = rpg_prototype::star_image($temp_field_type_1);
                     $temp_star_front_info = rpg_prototype::star_image($temp_field_type_1);
                     $temp_star_back = array('path' => 'abilities/item-star-base-' . $temp_star_front_info['sheet'], 'size' => 40, 'frame' => $temp_star_front_info['frame']);
                     $temp_star_front = array('path' => 'abilities/item-star-' . $temp_star_kind . '-' . $temp_star_back_info['sheet'], 'size' => 40, 'frame' => $temp_star_back_info['frame']);
                     array_unshift($this_battleinfo['battle_sprite'], $temp_star_back, $temp_star_front);
                 } elseif ($temp_star_kind == 'fusion') {
                     $temp_star_back_info = rpg_prototype::star_image($temp_field_type_2);
                     $temp_star_front_info = rpg_prototype::star_image($temp_field_type_1);
                     $temp_star_back = array('path' => 'abilities/item-star-base-' . $temp_star_front_info['sheet'], 'size' => 40, 'frame' => $temp_star_front_info['frame']);
                     $temp_star_front = array('path' => 'abilities/item-star-' . $temp_star_kind . '-' . $temp_star_back_info['sheet'], 'size' => 40, 'frame' => $temp_star_back_info['frame']);
                     array_unshift($this_battleinfo['battle_sprite'], $temp_star_back, $temp_star_front);
                 }
             }
             // Add the dark tower sprite if one has been added
             if ($this_has_dark_tower) {
                 //$this_option_complete = false;
                 $this_option_disabled = false;
                 // Add the dark tower sprite to the mission select
                 $temp_tower_sprite = array('path' => 'abilities/item-dark-tower', 'size' => 40, 'frame' => 0);
                 array_unshift($this_battleinfo['battle_sprite'], $temp_tower_sprite);
             }
             // Loop through the battle sprites and display them
             if (!empty($this_battleinfo['battle_sprite'])) {
                 $temp_right = false;
                 $temp_layer = 100;
                 $temp_count = count($this_battleinfo['battle_sprite']);
                 $temp_last_size = 0;
                 foreach ($this_battleinfo['battle_sprite'] as $temp_key => $this_battle_sprite) {
                     $temp_opacity = $temp_layer == 10 ? 1 : 1 - $temp_key * 0.09;
                     $temp_path = $this_battle_sprite['path'];
                     $temp_size = $this_battle_sprite['size'];
                     $temp_frame = !empty($this_battle_sprite['frame']) ? $this_battle_sprite['frame'] : '';
                     $temp_size_text = $temp_size . 'x' . $temp_size;
                     $temp_top = -2 + (40 - $temp_size);
                     if (!preg_match('/^abilities/i', $temp_path)) {
                         if ($temp_right === false) {
                             //die('<pre>'.print_r($temp_right, true).'</pre>');
                             if ($temp_size == 40) {
                                 $temp_right_inc = 0;
                                 $temp_right = 18 + $temp_right_inc;
                             } else {
                                 $temp_right_inc = -1 * ceil(($temp_size - 40) * 0.5);
                                 $temp_right = 18 + $temp_right_inc;
                             }
                         } else {
                             if ($temp_size == 40) {
                                 $temp_right_inc = ceil($temp_size * 0.5);
                                 $temp_right += $temp_right_inc;
                             } else {
                                 $temp_right_inc = ceil(($temp_size - 40) * 0.5);
                                 //ceil($temp_size * 0.5);
                                 $temp_right += $temp_right_inc;
                             }
                             if ($temp_size > $temp_last_size) {
                                 $temp_right -= ceil(($temp_size - $temp_last_size) / 2);
                             } elseif ($temp_size < $temp_last_size) {
                                 $temp_right += ceil(($temp_last_size - $temp_size) / 2);
                             }
                         }
                     } else {
                         $temp_right = 5;
                     }
                     $temp_path_full = 'images/sprites/' . $temp_path . '/sprite_left_' . $temp_size_text . '.png';
                     // Find and replace length path names with shorter ones for smaller request sizes
                     $temp_find_paths = array('images/sprites/players/', 'images/shadows/players/', 'images/sprites/robots/', 'images/shadows/robots/', 'images/sprites/abilities/', '/sprite_left_40x40', '/sprite_left_80x80', '/sprite_left_160x160', '/sprite_right_40x40', '/sprite_right_80x80', '/sprite_right_160x160', '/mug_left_40x40', '/mug_left_80x80', '/mug_left_160x160', '/mug_right_40x40', '/mug_right_80x80', '/mug_right_160x160', '/icon_left_40x40', '/icon_left_80x80', '/icon_left_160x160', '/icon_right_40x40', '/icon_right_80x80', '/icon_right_160x160');
                     $temp_replace_paths = array('i/p/', 'i/ps/', 'i/r/', 'i/rs/', 'i/a/', '/sl40', '/sl80', '/sl160', '/sr40', '/sr80', '/sr160', '/ml40', '/ml80', '/ml160', '/mr40', '/mr80', '/mr160', '/il40', '/il80', '/il160', '/ir40', '/ir80', '/ir160');
                     $temp_path_full = str_replace($temp_find_paths, $temp_replace_paths, $temp_path_full);
                     if (preg_match('/^abilities/i', $temp_path)) {
                         $this_option_label .= '<span class="sprite sprite_' . $temp_size_text . ' sprite_' . $temp_size_text . '_' . str_pad($temp_frame, 2, '0', STR_PAD_LEFT) . ' " style="background-image: url(' . $temp_path_full . '?' . MMRPG_CONFIG_CACHE_DATE . '); top: 1px; right: -3px;">&nbsp;</span>';
                     } else {
                         $this_option_label .= '<span class="sprite sprite_' . $temp_size_text . ' ' . ($this_option_complete && !$this_has_field_star && !$this_has_dark_tower && $this_option_frame == 'base' ? 'sprite_' . $temp_size_text . '_defeat ' : 'sprite_' . $temp_size_text . '_' . $this_option_frame . ' ') . '" style="background-image: url(' . $temp_path_full . '?' . MMRPG_CONFIG_CACHE_DATE . '); top: ' . $temp_top . 'px; right: ' . $temp_right . 'px;">&nbsp;</span>';
                     }
                     //'.$this_battleinfo['battle_name'].'
                     $temp_layer -= 1;
                     $temp_last_size = $temp_size;
                 }
             }
             //if ($this_battleinfo['battle_token'] == 'base-spark-man') die('<pre>'.print_r(htmlentities($this_option_label), true).'</pre>');
             //$this_option_button_text = !empty($this_battleinfo['battle_button']) ? $this_battleinfo['battle_button'] : '';
             //$this_option_button_text = !empty($this_fieldinfo['field_name']) ? $this_fieldinfo['field_name'] : '';
             if (!isset($this_battleinfo['battle_robots_limit'])) {
                 $this_battleinfo['battle_robots_limit'] = 1;
             }
             if (!isset($this_battleinfo['battle_points'])) {
                 $this_battleinfo['battle_points'] = 0;
             }
             if (!isset($this_battleinfo['battle_zenny'])) {
                 $this_battleinfo['battle_zenny'] = 0;
             }
             if (!empty($this_battleinfo['battle_button'])) {
                 $this_option_button_text = $this_battleinfo['battle_button'];
             } elseif (!empty($this_fieldinfo['field_name'])) {
                 $this_option_button_text = $this_fieldinfo['field_name'];
             } else {
                 $this_option_button_text = 'Battle';
             }
             if ($this_option_min_level < 1) {
                 $this_option_min_level = 1;
             }
             if ($this_option_max_level > 100) {
                 $this_option_max_level = 100;
             }
             $this_option_level_range = $this_option_min_level == $this_option_max_level ? 'Level ' . $this_option_min_level : 'Levels ' . $this_option_min_level . '-' . $this_option_max_level;
             $this_option_star_force = !empty($this_targetinfo['player_starforce']) ? ' | +' . number_format($this_option_star_boost * MMRPG_SETTINGS_STARS_ATTACKBOOST, 0, '.', ',') . ' Boost' : '';
             $this_option_point_amount = number_format($this_option_points, 0, '.', ',') . ' Point' . ($this_option_points != 1 ? 's' : '');
             //$this_option_label .= (!empty($this_option_button_text) ? '<span class="multi"><span class="maintext">'.$this_option_button_text.'</span><span class="subtext">'.$this_option_level_range.str_replace('|', '<span class="pipe">|</span>', $this_option_star_force).'</span><span class="subtext2">'.$this_option_point_amount.'</span></span>'.(!$this_has_field_star && (!$this_option_complete || ($this_option_complete && $this_option_encore)) ? '<span class="arrow"> &#9658;</span>' : '') : '<span class="single">???</span>');
             if (!empty($this_option_button_text)) {
                 $this_option_label .= '<span class="multi"><span class="maintext">' . $this_option_button_text . '</span><span class="subtext">' . $this_option_point_amount . '</span><span class="subtext2">' . $this_option_level_range . '</span></span>' . (!$this_has_field_star && (!$this_option_complete || $this_option_complete && $this_option_encore) ? '<span class="arrow"> &#9658;</span>' : '');
             } else {
                 $this_option_label .= '<span class="single">???</span>';
             }
             // Generate this options hover tooltip details
             $this_option_title = '';
             //$this_battleinfo['battle_button'];
             //$this_option_title .= '$this_master_count = '.$this_master_count.'; $this_mecha_count = '.$this_mecha_count.'; ';
             //if ($this_battleinfo['battle_button'] != $this_battleinfo['battle_name']){ $this_option_title .= ' | '.$this_battleinfo['battle_name']; }
             $this_option_title .= '&laquo; ' . $this_battleinfo['battle_name'] . ' &raquo;';
             $this_option_title .= ' <br />' . $this_fieldinfo['field_name'];
             if (!empty($this_fieldinfo['field_type'])) {
                 if (!empty($this_fieldinfo['field_type2'])) {
                     $this_option_title .= ' | ' . ucfirst($this_fieldinfo['field_type']) . ' / ' . ucfirst($this_fieldinfo['field_type2']) . ' Type';
                 } else {
                     $this_option_title .= ' | ' . ucfirst($this_fieldinfo['field_type']) . ' Type';
                 }
             }
             $this_option_title .= ' | ' . $this_option_level_range . ' <br />';
             //.$this_option_star_force;
             $this_option_title .= 'Target : ' . ($this_battleinfo['battle_turns_limit'] == 1 ? '1 Turn' : $this_battleinfo['battle_turns_limit'] . ' Turns') . ' with ' . ($this_battleinfo['battle_robots_limit'] == 1 ? '1 Robot' : $this_battleinfo['battle_robots_limit'] . ' Robots') . ' <br />';
             $this_option_title .= 'Reward : ' . ($this_battleinfo['battle_points'] == 1 ? '1 Point' : number_format($this_battleinfo['battle_points'], 0, '.', ',') . ' Points') . ' and ' . ($this_battleinfo['battle_zenny'] == 1 ? '1 Zenny' : number_format($this_battleinfo['battle_zenny'], 0, '.', ',') . ' Zenny');
             $this_option_title .= ' <br />' . $this_battleinfo['battle_description'] . (!empty($this_battleinfo['battle_description2']) ? ' ' . $this_battleinfo['battle_description2'] : '');
             /*
             if (!empty($this_option_complete) || !empty($this_option_failure) || !empty($this_has_field_star)){
                 $this_option_title .= ' <hr />&laquo; Battle Records &raquo;';
                 $this_option_title .= ' <br />Cleared : '.(!empty($this_option_complete['battle_count']) ? ($this_option_complete['battle_count'] == 1 ? '1 Time' : $this_option_complete['battle_count'].' Times') : '0 Times');
                 $this_option_title .= ' | Failed : '.(!empty($this_option_failure['battle_count']) ? ($this_option_failure['battle_count'] == 1 ? '1 Time' : $this_option_failure['battle_count'].' Times') : '0 Times');
                 if (!empty($this_option_complete)){
                     if (!empty($this_option_complete['battle_max_points'])){
                         $this_option_title .= ' <br />Max Points : '.(!empty($this_option_complete['battle_max_points']) ? number_format($this_option_complete['battle_max_points']) : 0).'';
                         $this_option_title .= ' | Min Points : '.(!empty($this_option_complete['battle_min_points']) ? number_format($this_option_complete['battle_min_points']) : 0).'';
                     }
                     if (!empty($this_option_complete['battle_max_turns'])){
                         $this_option_title .= ' <br />Max Turns : '.(!empty($this_option_complete['battle_max_turns']) ? number_format($this_option_complete['battle_max_turns']) : 0).'';
                         $this_option_title .= ' | Min Turns : '.(!empty($this_option_complete['battle_min_turns']) ? number_format($this_option_complete['battle_min_turns']) : 0).'';
                     }
                     if (!empty($this_option_complete['battle_max_robots'])){
                         $this_option_title .= ' <br />Max Robots : '.(!empty($this_option_complete['battle_max_robots']) ? number_format($this_option_complete['battle_max_robots']) : 0).'';
                         $this_option_title .= ' | Min Robots : '.(!empty($this_option_complete['battle_min_robots']) ? number_format($this_option_complete['battle_min_robots']) : 0).'';
                     }
                 }
             }
             */
             $this_option_title_plain = strip_tags(str_replace('<br />', '&#10;', $this_option_title));
             $this_option_title_tooltip = htmlentities($this_option_title, ENT_QUOTES, 'UTF-8');
             // Define the field multipliers
             $temp_field_multipliers = array();
             if (!empty($this_fieldinfo['field_multipliers'])) {
                 $temp_multiplier_list = $this_fieldinfo['field_multipliers'];
                 asort($temp_multiplier_list);
                 $temp_multiplier_list = array_reverse($temp_multiplier_list, true);
                 foreach ($temp_multiplier_list as $temp_type => $temp_multiplier) {
                     if ($temp_multiplier == 1) {
                         continue;
                     }
                     $temp_field_multipliers[] = $temp_type . '*' . number_format($temp_multiplier, 1);
                 }
             }
             $temp_field_multipliers = !empty($temp_field_multipliers) ? implode('|', $temp_field_multipliers) : '';
             // DEBUG DEBUG
             //$this_battleinfo['battle_description'] .= json_encode($this_battleinfo['battle_rewards']);
             // Print out the option button markup with sprite and name
             $this_markup .= '<a data-chapter="' . $this_info['option_chapter'] . '" data-tooltip="' . $this_option_title_tooltip . '" data-field="' . htmlentities($this_fieldinfo['field_name'], ENT_QUOTES, 'UTF-8', true) . '" data-description="' . htmlentities($this_battleinfo['battle_description'] . (!empty($this_battleinfo['battle_description2']) ? ' ' . $this_battleinfo['battle_description2'] : ''), ENT_QUOTES, 'UTF-8', true) . '" data-multipliers="' . $temp_field_multipliers . '" data-background="' . (!empty($this_fieldinfo['field_background']) ? $this_fieldinfo['field_background'] : '') . '" data-foreground="' . (!empty($this_fieldinfo['field_foreground']) ? $this_fieldinfo['field_foreground'] : '') . '" class="' . $this_option_class . '" data-token="' . $this_option_token . '" data-next-limit="' . $this_option_limit . '" style="' . $this_option_style . (!empty($this_info['option_style']) ? ' ' . $this_info['option_style'] : '') . '"><div class="platform" style="' . $this_option_platform_style . '"><div class="chrome"><div class="inset"><label class="' . (!empty($this_battleinfo['battle_sprite']) ? 'has_image' : 'no_image') . '">' . $this_option_label . '</label></div></div></div></a>' . "\r\n";
             // Update the main battle option array with recent changes
             $this_battleinfo['flag_skip'] = true;
             $battle_options[$this_key] = $this_battleinfo;
         }
     }
     // Return the generated markup
     return $this_markup;
 }
예제 #4
0
//$debug_flag_animation = false;
//$debug_flag_scanlines = false;
// Collect the battle tokens from the URL
$this_battle_id = isset($_GET['this_battle_id']) ? $_GET['this_battle_id'] : 0;
$this_battle_token = isset($_GET['this_battle_token']) ? $_GET['this_battle_token'] : '';
$this_field_id = isset($_GET['this_field_id']) ? $_GET['this_field_id'] : 0;
$this_field_token = isset($_GET['this_field_token']) ? $_GET['this_field_token'] : '';
$this_player_id = isset($_GET['this_player_id']) ? $_GET['this_player_id'] : 0;
$this_player_token = isset($_GET['this_player_token']) ? $_GET['this_player_token'] : '';
$this_player_robots = isset($_GET['this_player_robots']) ? $_GET['this_player_robots'] : '';
$target_player_id = isset($_GET['target_player_id']) ? $_GET['target_player_id'] : 0;
$target_player_token = isset($_GET['target_player_token']) ? $_GET['target_player_token'] : '';
// -- COLLECT BATLE INFO -- //
// Collect the battle index data if available
if (!empty($this_battle_token)) {
    $this_battle_data = rpg_battle::get_index_info($this_battle_token);
    if (empty($this_battle_data['battle_id'])) {
        $this_battle_id = !empty($this_battle_id) ? $this_battle_id : 1;
        $this_battle_data['battle_id'] = $this_battle_id;
    }
} else {
    $this_battle_id = 0;
    $this_battle_token = '';
    $this_battle_data = array();
}
// -- COLLECT FIELD INFO -- //
// Define the field data object as empty
$this_field_data = array();
// Collect the field data object values if available
if (!empty($this_field_token)) {
    // Collect the field data from the index directly