public static function has_ability_compatibility($robot_token, $ability_token, $item_token = '') { global $mmrpg_index; if (empty($robot_token) || empty($ability_token)) { return false; } $robot_info = is_array($robot_token) ? $robot_token : self::get_index_info($robot_token); $ability_info = is_array($ability_token) ? $ability_token : rpg_ability::get_index_info($ability_token); $item_info = is_array($item_token) ? $item_token : rpg_ability::get_index_info($item_token); if (empty($robot_info) || empty($ability_info)) { return false; } $ability_token = !empty($ability_info) ? $ability_info['ability_token'] : ''; $item_token = !empty($item_info) ? $item_info['ability_token'] : ''; $robot_token = $robot_info['robot_token']; $robot_core = !empty($robot_info['robot_core']) ? $robot_info['robot_core'] : ''; $robot_core2 = !empty($item_token) && preg_match('/-core$/i', $item_token) ? preg_replace('/-core$/i', '', $item_token) : ''; //echo 'has_ability_compatibility('.$robot_token.', '.$ability_token.', '.$robot_core.', '.$robot_core2.')'."\n"; // Define the compatibility flag and default to false $temp_compatible = false; // Collect the global list and return true if match is found $global_abilities = rpg_ability::get_global_abilities(); // If this ability is in the list of globally compatible if (in_array($ability_token, $global_abilities)) { $temp_compatible = true; } elseif (!empty($ability_info['ability_type']) || !empty($ability_info['ability_type2'])) { //$debug_fragment .= 'has-type '; // DEBUG if (!empty($robot_core) || !empty($robot_core2)) { //$debug_fragment .= 'has-core '; // DEBUG if ($robot_core == 'copy') { //$debug_fragment .= 'copy-core '; // DEBUG $temp_compatible = true; } elseif (!empty($ability_info['ability_type']) && ($ability_info['ability_type'] == $robot_core || $ability_info['ability_type'] == $robot_core2)) { //$debug_fragment .= 'core-match1 '; // DEBUG $temp_compatible = true; } elseif (!empty($ability_info['ability_type2']) && ($ability_info['ability_type2'] == $robot_core || $ability_info['ability_type2'] == $robot_core2)) { //$debug_fragment .= 'core-match2 '; // DEBUG $temp_compatible = true; } } } // Otherwise, check to see if this ability is in the robot's level up set if (!$temp_compatible && !empty($robot_info['robot_rewards']['abilities'])) { //$debug_fragment .= 'has-levelup '; // DEBUG foreach ($robot_info['robot_rewards']['abilities'] as $info) { if ($info['token'] == $ability_info['ability_token']) { //$debug_fragment .= ''.$ability_info['ability_token'].'-matched '; // DEBUG $temp_compatible = true; break; } } } // Otherwise, see if this robot can be taught vis player only if (!$temp_compatible && in_array($ability_info['ability_token'], $robot_info['robot_abilities'])) { //$debug_fragment .= 'has-playeronly '; // DEBUG $temp_compatible = true; } //$robot_info['robot_abilities'] // DEBUG //die('Found '.$debug_fragment.' - robot '.($temp_compatible ? 'is' : 'is not').' compatible!'); // Return the temp compatible result return $temp_compatible; }