예제 #1
0
 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…';
         } 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;
 }