function rpg_attachment()
 {
     // Update the session keys for this object
     $this->session_key = 'ATTACHMENTS';
     $this->session_token = 'ability_token';
     $this->session_id = 'ability_id';
     $this->class = 'ability';
     // Collect any provided arguments
     $args = func_get_args();
     // Define the internal battle pointer
     $this->battle = rpg_battle::get_battle();
     $this->battle_id = $this->battle->battle_id;
     $this->battle_token = $this->battle->battle_token;
     // Define the internal battle pointer
     $this->field = rpg_field::get_field;
     $this->field_id = $this->field->field_id;
     $this->field_token = $this->field->field_token;
     // Define the internal player values using the provided array
     $this->player = isset($args[0]) && is_a($args[0], 'rpg_player') ? $args[0] : new rpg_player();
     $this->player_id = $this->player->player_id;
     $this->player_token = $this->player->player_token;
     // Define the internal robot values using the provided array
     $this->robot = isset($args[1]) && is_a($args[1], 'rpg_robot') ? $args[0] : new rpg_robot();
     $this->robot_id = $this->robot->robot_id;
     $this->robot_token = $this->robot->robot_token;
     // Collect current ability data from the function if available
     $attachment_info = isset($args[2]) && is_array($args[2]) && !empty($args[2]) ? $args[2] : array('ability_id' => 0, 'ability_token' => 'ability');
     // Load the ability data based on the ID and fallback token
     $attachment_info = $this->ability_load($attachment_info['ability_id'], $attachment_info['ability_token']);
     // Now load the ability data from the session or index
     if (empty($attachment_info)) {
         // Attachment data could not be loaded
         die('Attachment data could not be loaded :<br />$attachment_info = <pre>' . print_r($attachment_info, true) . '</pre>');
         return false;
     }
     // Update the session variable
     $this->update_session();
     // Return true on success
     return true;
 }
示例#2
0
 /**
  * Create a new RPG field object
  * @param array $field_info (optional)
  * @return rpg_field
  */
 public function __construct($field_info = array())
 {
     // Update the session keys for this object
     $this->session_key = 'FIELDS';
     $this->session_token = 'field_token';
     $this->session_id = 'field_id';
     $this->class = 'field';
     // Collect any provided arguments
     $args = func_get_args();
     // Define the internal class identifier
     $this->class = 'field';
     // Define the internal battle pointer
     $this->battle = rpg_battle::get_battle();
     $this->battle_id = $this->battle->battle_id;
     $this->battle_token = $this->battle->battle_token;
     // Collect current field data from the function if available
     $field_info = !empty($field_info) ? $field_info : array();
     if (!isset($this_fieldinfo['field_id'])) {
         $this_fieldinfo['field_id'] = 0;
     }
     if (!isset($this_fieldinfo['field_token'])) {
         $this_fieldinfo['field_token'] = 'field';
     }
     // Load the field data based on the ID and fallback token
     $field_info = $this->field_load($field_info['field_id'], $field_info['field_token'], $field_info);
     // Now load the field data from the session or index
     if (empty($field_info)) {
         // Player data could not be loaded
         die('Field data could not be loaded :<br />$this_fieldinfo = <pre>' . print_r($this_fieldinfo, true) . '</pre>');
         return false;
     }
     // Update the session variable
     $this->update_session();
     // Return true on success
     return true;
 }
示例#3
0
 public function ability_load($ability_id = 0, $ability_token = 'ability', $custom_info = array())
 {
     /*
     // If this is a special system ability, hard-code its ID, otherwise base off robot
     $temp_system_abilities = array('attachment-defeat');
     if (in_array($ability_token, $temp_system_abilities)){
         $ability_id = $this->player_id.player_id.str_pad(array_search($ability_token, $temp_system_abilities), 3, '0', STR_PAD_LEFT);
     }
     // Else if this is an item, tweak it's ID as well
     elseif (in_array($ability_token, $this->player->player_items)){
         $ability_id = $this->player_id.str_pad(array_search($ability_token, $this->player->player_items), 3, '0', STR_PAD_LEFT);
     }
     // Else if this was any other ability, combine ID with robot owner
     else {
         $ability_id = $this->robot_id.str_pad($ability_id, 3, '0', STR_PAD_LEFT);
     }
     */
     // If the ability token was not provided, return false
     if (!isset($ability_token)) {
         die("ability token must be set!\n\$this_abilityinfo\n" . print_r($this_abilityinfo, true));
         return false;
     }
     // Collect current ability data from the session if available
     if (isset($_SESSION['ABILITIES'][$ability_id])) {
         $this_abilityinfo = $_SESSION['ABILITIES'][$ability_id];
         if ($this_abilityinfo['ability_token'] != $ability_token) {
             die("ability token and ID mismatch {$ability_id}:{$ability_token}!\n");
             return false;
         }
     } else {
         $this_abilityinfo = self::get_index_info($ability_token);
         if (empty($this_abilityinfo)) {
             die("ability data could not be loaded for {$ability_id}:{$ability_token}!\n");
             return false;
         }
     }
     // If the custom data was not empty, merge now
     if (!empty($custom_info)) {
         $this_abilityinfo = array_merge($this_abilityinfo, $custom_info);
     }
     // Define the internal ability values using the provided array
     $this->flags = isset($this_abilityinfo['flags']) ? $this_abilityinfo['flags'] : array();
     $this->counters = isset($this_abilityinfo['counters']) ? $this_abilityinfo['counters'] : array();
     $this->values = isset($this_abilityinfo['values']) ? $this_abilityinfo['values'] : array();
     $this->history = isset($this_abilityinfo['history']) ? $this_abilityinfo['history'] : array();
     $this->ability_id = isset($this_abilityinfo['ability_id']) ? $this_abilityinfo['ability_id'] : $ability_id;
     $this->ability_key = isset($this_abilityinfo['ability_key']) ? $this_abilityinfo['ability_key'] : 0;
     $this->ability_name = isset($this_abilityinfo['ability_name']) ? $this_abilityinfo['ability_name'] : 'Ability';
     $this->ability_token = isset($this_abilityinfo['ability_token']) ? $this_abilityinfo['ability_token'] : 'ability';
     $this->ability_description = isset($this_abilityinfo['ability_description']) ? $this_abilityinfo['ability_description'] : '';
     $this->ability_class = isset($this_abilityinfo['ability_class']) ? $this_abilityinfo['ability_class'] : 'master';
     $this->ability_subclass = isset($this_abilityinfo['ability_subclass']) ? $this_abilityinfo['ability_subclass'] : '';
     $this->ability_master = isset($this_abilityinfo['ability_master']) ? $this_abilityinfo['ability_master'] : '';
     $this->ability_number = isset($this_abilityinfo['ability_number']) ? $this_abilityinfo['ability_number'] : '';
     $this->ability_type = isset($this_abilityinfo['ability_type']) ? $this_abilityinfo['ability_type'] : '';
     $this->ability_type2 = isset($this_abilityinfo['ability_type2']) ? $this_abilityinfo['ability_type2'] : '';
     $this->ability_speed = isset($this_abilityinfo['ability_speed']) ? $this_abilityinfo['ability_speed'] : 1;
     $this->ability_energy = isset($this_abilityinfo['ability_energy']) ? $this_abilityinfo['ability_energy'] : 4;
     $this->ability_energy_percent = isset($this_abilityinfo['ability_energy_percent']) ? $this_abilityinfo['ability_energy_percent'] : true;
     $this->ability_damage = isset($this_abilityinfo['ability_damage']) ? $this_abilityinfo['ability_damage'] : 0;
     $this->ability_damage2 = isset($this_abilityinfo['ability_damage2']) ? $this_abilityinfo['ability_damage2'] : 0;
     $this->ability_damage_percent = isset($this_abilityinfo['ability_damage_percent']) ? $this_abilityinfo['ability_damage_percent'] : false;
     $this->ability_damage2_percent = isset($this_abilityinfo['ability_damage2_percent']) ? $this_abilityinfo['ability_damage2_percent'] : false;
     $this->ability_recovery = isset($this_abilityinfo['ability_recovery']) ? $this_abilityinfo['ability_recovery'] : 0;
     $this->ability_recovery2 = isset($this_abilityinfo['ability_recovery2']) ? $this_abilityinfo['ability_recovery2'] : 0;
     $this->ability_recovery_percent = isset($this_abilityinfo['ability_recovery_percent']) ? $this_abilityinfo['ability_recovery_percent'] : false;
     $this->ability_recovery2_percent = isset($this_abilityinfo['ability_recovery2_percent']) ? $this_abilityinfo['ability_recovery2_percent'] : false;
     $this->ability_accuracy = isset($this_abilityinfo['ability_accuracy']) ? $this_abilityinfo['ability_accuracy'] : 0;
     $this->ability_target = isset($this_abilityinfo['ability_target']) ? $this_abilityinfo['ability_target'] : 'auto';
     $this->ability_functions = isset($this_abilityinfo['ability_functions']) ? $this_abilityinfo['ability_functions'] : 'abilities/ability.php';
     $this->ability_image = isset($this_abilityinfo['ability_image']) ? $this_abilityinfo['ability_image'] : $this->ability_token;
     $this->ability_image_size = isset($this_abilityinfo['ability_image_size']) ? $this_abilityinfo['ability_image_size'] : 40;
     $this->ability_frame = isset($this_abilityinfo['ability_frame']) ? $this_abilityinfo['ability_frame'] : 'base';
     $this->ability_frame_span = isset($this_abilityinfo['ability_frame_span']) ? $this_abilityinfo['ability_frame_span'] : 1;
     $this->ability_frame_animate = isset($this_abilityinfo['ability_frame_animate']) ? $this_abilityinfo['ability_frame_animate'] : array($this->ability_frame);
     $this->ability_frame_index = isset($this_abilityinfo['ability_frame_index']) ? $this_abilityinfo['ability_frame_index'] : array('base');
     $this->ability_frame_offset = isset($this_abilityinfo['ability_frame_offset']) ? $this_abilityinfo['ability_frame_offset'] : array('x' => 0, 'y' => 0, 'z' => 1);
     $this->ability_frame_styles = isset($this_abilityinfo['ability_frame_styles']) ? $this_abilityinfo['ability_frame_styles'] : '';
     $this->ability_frame_classes = isset($this_abilityinfo['ability_frame_classes']) ? $this_abilityinfo['ability_frame_classes'] : '';
     $this->ability_results = array();
     $this->ability_options = array();
     $this->target_options = array();
     $this->damage_options = array();
     $this->recovery_options = array();
     $this->attachment_options = array();
     // Collect any functions associated with this ability
     $temp_functions_path = file_exists(MMRPG_CONFIG_ROOTDIR . 'data/' . $this->ability_functions) ? $this->ability_functions : 'abilities/ability.php';
     require MMRPG_CONFIG_ROOTDIR . 'data/' . $temp_functions_path;
     $this->ability_function = isset($ability['ability_function']) ? $ability['ability_function'] : function () {
     };
     $this->ability_function_onload = isset($ability['ability_function_onload']) ? $ability['ability_function_onload'] : function () {
     };
     $this->ability_function_attachment = isset($ability['ability_function_attachment']) ? $ability['ability_function_attachment'] : function () {
     };
     unset($ability);
     // Define the internal robot base values using the robots index array
     $this->ability_base_key = isset($this_abilityinfo['ability_base_key']) ? $this_abilityinfo['ability_base_key'] : $this->ability_key;
     $this->ability_base_name = isset($this_abilityinfo['ability_base_name']) ? $this_abilityinfo['ability_base_name'] : $this->ability_name;
     $this->ability_base_token = isset($this_abilityinfo['ability_base_token']) ? $this_abilityinfo['ability_base_token'] : $this->ability_token;
     $this->ability_base_description = isset($this_abilityinfo['ability_base_description']) ? $this_abilityinfo['ability_base_description'] : $this->ability_description;
     $this->ability_base_image = isset($this_abilityinfo['ability_base_image']) ? $this_abilityinfo['ability_base_image'] : $this->ability_image;
     $this->ability_base_image_size = isset($this_abilityinfo['ability_base_image_size']) ? $this_abilityinfo['ability_base_image_size'] : $this->ability_image_size;
     $this->ability_base_type = isset($this_abilityinfo['ability_base_type']) ? $this_abilityinfo['ability_base_type'] : $this->ability_type;
     $this->ability_base_type2 = isset($this_abilityinfo['ability_base_type2']) ? $this_abilityinfo['ability_base_type2'] : $this->ability_type2;
     $this->ability_base_energy = isset($this_abilityinfo['ability_base_energy']) ? $this_abilityinfo['ability_base_energy'] : $this->ability_energy;
     $this->ability_base_speed = isset($this_abilityinfo['ability_base_speed']) ? $this_abilityinfo['ability_base_speed'] : $this->ability_speed;
     $this->ability_base_damage = isset($this_abilityinfo['ability_base_damage']) ? $this_abilityinfo['ability_base_damage'] : $this->ability_damage;
     $this->ability_base_damage_percent = isset($this_abilityinfo['ability_base_damage_percent']) ? $this_abilityinfo['ability_base_damage_percent'] : $this->ability_damage_percent;
     $this->ability_base_damage2 = isset($this_abilityinfo['ability_base_damage2']) ? $this_abilityinfo['ability_base_damage2'] : $this->ability_damage2;
     $this->ability_base_damage2_percent = isset($this_abilityinfo['ability_base_damage2_percent']) ? $this_abilityinfo['ability_base_damage2_percent'] : $this->ability_damage2_percent;
     $this->ability_base_recovery = isset($this_abilityinfo['ability_base_recovery']) ? $this_abilityinfo['ability_base_recovery'] : $this->ability_recovery;
     $this->ability_base_recovery_percent = isset($this_abilityinfo['ability_base_recovery_percent']) ? $this_abilityinfo['ability_base_recovery_percent'] : $this->ability_recovery_percent;
     $this->ability_base_recovery2 = isset($this_abilityinfo['ability_base_recovery2']) ? $this_abilityinfo['ability_base_recovery2'] : $this->ability_recovery2;
     $this->ability_base_recovery2_percent = isset($this_abilityinfo['ability_base_recovery2_percent']) ? $this_abilityinfo['ability_base_recovery2_percent'] : $this->ability_recovery2_percent;
     $this->ability_base_accuracy = isset($this_abilityinfo['ability_base_accuracy']) ? $this_abilityinfo['ability_base_accuracy'] : $this->ability_accuracy;
     $this->ability_base_target = isset($this_abilityinfo['ability_base_target']) ? $this_abilityinfo['ability_base_target'] : $this->ability_target;
     // Define a the default ability results
     $this->ability_results_reset();
     // Reset the ability options to default
     $this->target_options_reset();
     $this->damage_options_reset();
     $this->recovery_options_reset();
     // Trigger the onload function if it exists
     $this_battle = rpg_battle::get_battle();
     $this_field = rpg_field::get_field();
     $this_player = $this->player;
     $this_robot = $this->robot;
     $target_side = $this_player->player_side != 'right' ? 'right' : 'left';
     $target_player = $this_battle->find_player(array('player_side' => $target_side));
     $target_robot = $this_battle->find_robot(array('robot_side' => $target_side, 'robot_position' => 'active'));
     $temp_function = $this->ability_function_onload;
     $temp_result = $temp_function(array('this_battle' => $this_battle, 'this_field' => $this_field, 'this_player' => $this_player, 'this_robot' => $this_robot, 'target_player' => $target_player, 'target_robot' => $target_robot, 'this_ability' => $this));
     // Return true on success
     return true;
 }
示例#4
0
 /**
  * Reset internal variables of this player object
  * @return rpg_robot
  */
 public function get_active_robot()
 {
     $this_battle = rpg_battle::get_battle();
     $this_robot = $this_battle->find_robot(array('player_id' => $this->player_id, 'robot_status' => 'active', 'robot_position' => 'active'));
     if (empty($this_robot)) {
         $this_robot = $this_battle->find_robot(array('player_id' => $this->player_id, 'robot_status' => 'active'));
         if (empty($this_robot)) {
             $this_robot = $this_battle->find_robot(array('player_id' => $this->player_id));
         }
     }
     return $this_robot;
 }
示例#5
0
 public function check_weapons(rpg_player $target_player, rpg_robot $target_robot, $regen_weapons = true)
 {
     // Collect references to global objects
     $db = cms_database::get_database();
     $this_battle = rpg_battle::get_battle();
     $this_field = rpg_field::get_field();
     // Collect references to relative player and robot objects
     $this_player = $this->player;
     $this_robot = $this;
     // Hide any disabled robots and return
     if ($this_robot->get_status() == 'disabled') {
         $this_robot->set_flag('apply_disabled_state', true);
         $this_battle->events_create();
         return;
     }
     // If this robot is not at full weapon energy, increase it by one
     $temp_weapons = $this_robot->get_weapons();
     $temp_base_weapons = $this_robot->get_base_weapons();
     if ($temp_weapons < $temp_base_weapons) {
         // Ensure the regen weapons flag has been set to true
         if ($regen_weapons) {
             // Define the multiplier based on position
             $temp_multiplier = $this_robot->get_position() == 'bench' ? 2 : 1;
             // Increment this robot's weapons by one point and update
             $temp_weapons += MMRPG_SETTINGS_RECHARGE_WEAPONS * $temp_multiplier;
             $this_robot->set_weapons($temp_weapons);
         }
     }
 }
示例#6
0
 /**
  * Empty all actions in the global battle queue
  */
 public function actions_empty()
 {
     $this_battle = rpg_battle::get_battle();
     $this_battle->actions = array();
     return $this_battle->actions;
 }