public static function get_index_info($ability_token)
 {
     // Pull in global variables
     $db = cms_database::get_database();
     // Collect this ability's info from the database index
     $lookup = !is_numeric($ability_token) ? "ability_token = '{$ability_token}'" : "ability_id = {$ability_token}";
     $ability_fields = self::get_index_fields(true);
     $ability_index = $db->get_array("SELECT {$ability_fields} FROM mmrpg_index_abilities WHERE {$lookup};", 'ability_token');
     // Parse and return the data if not empty, else nothing
     if (!empty($ability_index)) {
         $ability_index = self::parse_index_info($ability_index);
         return $ability_index;
     } else {
         return array();
     }
 }
 /**
  * Collect the database info for a specific role by ID or token
  * @param bool $role_lookup (int or string)
  * @return array
  */
 public static function get_info($role_lookup)
 {
     // Pull in global variables
     $db = cms_database::get_database();
     // Collect this role's info from the database index
     $lookup = !is_numeric($role_lookup) ? "role_name_clean = '{$role_lookup}'" : "role_id = {$role_lookup}";
     $role_fields = self::get_index_fields(true);
     $role_index = $db->get_array("SELECT {$role_fields} FROM mmrpg_roles WHERE {$lookup};");
     // Parse and return the data if not empty, else nothing
     if (!empty($role_index)) {
         $role_index = self::parse_index_info($role_index);
         return $role_index;
     } else {
         return array();
     }
 }
Beispiel #3
0
// Turn on error reporting
if (MMRPG_CONFIG_ADMIN_MODE) {
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(-1);
}
// Include mandatory core class files
require 'classes/cms_website.php';
require 'classes/cms_database.php';
require 'classes/rpg_functions.php';
// Create the global database object
if (!defined('MMRPG_INDEX_SESSION') && !defined('MMRPG_INDEX_STYLES')) {
    if (MMRPG_CONFIG_DEBUG_MODE) {
        $_SESSION['DEBUG'] = array();
    }
    $db = new cms_database();
    // If the database could not be created, critical error mode!
    if ($db->CONNECT === false) {
        define('MMRPG_CRITICAL_ERROR', true);
        $_GET = array();
        $_GET['page'] = 'error';
    }
}
// Include mandatory user class files
require 'classes/rpg_user.php';
require 'classes/rpg_user_role.php';
// Include mandatory game class files
require 'classes/rpg_game.php';
require 'classes/rpg_prototype.php';
require 'classes/rpg_mission.php';
// Include mandatory object class files
 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);
         }
     }
 }
Beispiel #5
0
 public static function get_index_info($type_token)
 {
     // Pull in global variables
     $db = cms_database::get_database();
     // Collect this type's info from the database index
     $type_fields = self::get_index_fields(true);
     $type_index = $db->get_array_list("SELECT {$type_fields} FROM mmrpg_index_types WHERE type_token = '{$type_token}';", 'type_token');
     // Parse and return the data if not empty, else nothing
     if (!empty($type_index)) {
         $type_index = self::parse_index_info($type_index);
         return $type_index;
     } else {
         return array();
     }
 }
 /**
  * Generate the console message markup for this frame of battle including players, robots, abilities etc.
  * @param array $eventinfo
  * @param array $options (optional)
  * @return string
  */
 public function get_console_markup($eventinfo, $options = array())
 {
     // Collect references to global objects
     $db = cms_database::get_database();
     $this_battle = self::get_battle();
     $this_field = rpg_field::get_field();
     // Default the return markup to empty
     $this_markup = '';
     // Ensure this side is allowed to be shown before generating any markup
     if ($options['console_show_this'] != false) {
         // Define the necessary text markup for the current player if allowed and exists
         if (!empty($eventinfo['this_player'])) {
             // Collect the console data for this player
             $this_player_data = $eventinfo['this_player']->get_console_markup($options);
         } else {
             // Define empty console data for this player
             $this_player_data = array();
             $options['console_show_this_player'] = false;
         }
         // Define the necessary text markup for the current robot if allowed and exists
         if (!empty($eventinfo['this_robot'])) {
             // Collect the console data for this robot
             $this_robot_data = $eventinfo['this_robot']->get_console_markup($options, $this_player_data);
         } else {
             // Define empty console data for this robot
             $this_robot_data = array();
             $options['console_show_this_robot'] = false;
         }
         // Define the necessary text markup for the current ability if allowed and exists
         if (!empty($options['this_ability'])) {
             // Collect the console data for this ability
             $this_ability_data = $options['this_ability']->get_console_markup($options, $this_player_data, $this_robot_data);
         } else {
             // Define empty console data for this ability
             $this_ability_data = array();
             $options['console_show_this_ability'] = false;
         }
         // Define the necessary text markup for the current star if allowed and exists
         if (!empty($options['this_star'])) {
             // Collect the console data for this star
             $this_star_data = rpg_functions::get_star_console_markup($options['this_star'], $this_player_data, $this_robot_data);
         } else {
             // Define empty console data for this star
             $this_star_data = array();
             $options['console_show_this_star'] = false;
         }
         // If no objects would found to display, turn the left side off
         if (empty($options['console_show_this_player']) && empty($options['console_show_this_robot']) && empty($options['console_show_this_ability']) && empty($options['console_show_this_star'])) {
             // Automatically set the console option to false
             $options['console_show_this'] = false;
         }
     } else {
         // Default all of this side's objects to empty arrays
         $this_player_data = array();
         $this_robot_data = array();
         $this_ability_data = array();
         $this_star_data = array();
     }
     // Ensure the target side is allowed to be shown before generating any markup
     if ($options['console_show_target'] != false) {
         // Define the necessary text markup for the target player if allowed and exists
         if (!empty($eventinfo['target_player'])) {
             // Collect the console data for this player
             $target_player_data = $eventinfo['target_player']->get_console_markup($options);
         } else {
             // Define empty console data for this player
             $target_player_data = array();
             $options['console_show_target_player'] = false;
         }
         // Define the necessary text markup for the target robot if allowed and exists
         if (!empty($eventinfo['target_robot'])) {
             // Collect the console data for this robot
             $target_robot_data = $eventinfo['target_robot']->get_console_markup($options, $target_player_data);
         } else {
             // Define empty console data for this robot
             $target_robot_data = array();
             $options['console_show_target_robot'] = false;
         }
         // Define the necessary text markup for the target ability if allowed and exists
         if (!empty($options['target_ability'])) {
             // Collect the console data for this ability
             $target_ability_data = $options['target_ability']->get_console_markup($options, $target_player_data, $target_robot_data);
         } else {
             // Define empty console data for this ability
             $target_ability_data = array();
             $options['console_show_target_ability'] = false;
         }
         // If no objects would found to display, turn the right side off
         if (empty($options['console_show_target_player']) && empty($options['console_show_target_robot']) && empty($options['console_show_target_ability'])) {
             // Automatically set the console option to false
             $options['console_show_target'] = false;
         }
     } else {
         // Default all of the target side's objects to empty arrays
         $target_player_data = array();
         $target_robot_data = array();
         $target_ability_data = array();
     }
     // Assign player-side based floats for the header and body if not set
     if (empty($options['console_header_float']) && !empty($this_robot_data)) {
         $options['console_header_float'] = $this_robot_data['robot_float'];
     }
     if (empty($options['console_body_float']) && !empty($this_robot_data)) {
         $options['console_body_float'] = $this_robot_data['robot_float'];
     }
     // Append the generated console markup if not empty
     if (!empty($eventinfo['event_header']) && !empty($eventinfo['event_body'])) {
         // Define the container class based on height
         $event_class = 'event ';
         $event_style = '';
         if ($options['console_container_height'] == 1) {
             $event_class .= 'event_single ';
         }
         if ($options['console_container_height'] == 2) {
             $event_class .= 'event_double ';
         }
         if ($options['console_container_height'] == 3) {
             $event_class .= 'event_triple ';
         }
         if (!empty($options['console_container_classes'])) {
             $event_class .= $options['console_container_classes'];
         }
         if (!empty($options['console_container_styles'])) {
             $event_style .= $options['console_container_styles'];
         }
         // Generate the opening event tag
         $this_markup .= '<div class="' . $event_class . '" style="' . $event_style . '">';
         // Generate this side's markup if allowed
         if ($options['console_show_this'] != false) {
             // Append this player's markup if allowed
             if ($options['console_show_this_player'] != false) {
                 $this_markup .= $this_player_data['player_markup'];
             } elseif ($options['console_show_this_robot'] != false) {
                 $this_markup .= $this_robot_data['robot_markup'];
             } elseif ($options['console_show_this_ability'] != false) {
                 $this_markup .= $this_ability_data['ability_markup'];
             } elseif ($options['console_show_this_star'] != false) {
                 $this_markup .= $this_star_data['star_markup'];
             }
         }
         // Generate the target side's markup if allowed
         if ($options['console_show_target'] != false) {
             // Append the target player's markup if allowed
             if ($options['console_show_target_player'] != false) {
                 $this_markup .= $target_player_data['player_markup'];
             } elseif ($options['console_show_target_robot'] != false) {
                 $this_markup .= $target_robot_data['robot_markup'];
             } elseif ($options['console_show_target_ability'] != false) {
                 $this_markup .= $target_ability_data['ability_markup'];
             }
         }
         // Prepend the turn counter to the header if necessary
         if (!empty($this_battle->counters['battle_turn']) && $this_battle->battle_status != 'complete') {
             $eventinfo['event_header'] = 'Turn #' . $this_battle->counters['battle_turn'] . ' : ' . $eventinfo['event_header'];
         }
         // Display the event header and event body
         $this_markup .= '<div class="header header_' . $options['console_header_float'] . '">' . $eventinfo['event_header'] . '</div>';
         $this_markup .= '<div class="body body_' . $options['console_body_float'] . '">' . $eventinfo['event_body'] . '</div>';
         // Displat the closing event tag
         $this_markup .= '</div>';
     }
     // Return the generated markup and robot data
     return $this_markup;
 }