/** * Returns the list fo all skills available to a ninja. */ private function skills(Player $char) { if ($char->isAdmin()) { // Admins get access to all skills. $skills = $this->skill_map['crane'] + $this->skill_map['dragon'] + $this->skill_map['tiger'] + $this->skill_map['viper'] + $this->skill_map['all']; return $skills; } $class = $char->identity; $class_skills = array(); if ($class) { $class_skills = $this->skill_map[$class]; } return $class_skills + $this->skill_map['all']; }
/** * Returns the list fo all skills available to a ninja. **/ public function skills($char_id = null) { if (!$char_id) { $char_id = self_char_id(); } $char = new Player($char_id); $char_name = $char->name(); if ($char->isAdmin()) { // Admins get access to all skills. $skills = $this->skill_map['crane'] + $this->skill_map['dragon'] + $this->skill_map['tiger'] + $this->skill_map['viper'] + $this->skill_map['all']; return $skills; } $class = char_class_identity($char_id); $class_skills = array(); if ($class) { $class_skills = $this->skill_map[$class]; } return $class_skills + $this->skill_map['all']; }
function level_up_if_possible($char_id, $auto_level = false) { // Setup values: $max_level = maximum_level(); $health_to_add = 100; $turns_to_give = 50; $stat_value_to_add = 5; $char_kills = get_kills($char_id); if ($char_kills < 0) { // If the character doesn't have any kills, shortcut the levelling process. return false; } else { $char_obj = new Player($char_id); $username = $char_obj->name(); $char_level = $char_obj->level(); if ($auto_level && $char_obj->isAdmin()) { // If the character is an admin, do not auto-level them. return false; } else { // For normal characters, do auto-level them. // Check required values: $nextLevel = $char_level + 1; $required_kills = required_kills_to_level($char_level); // Have to be under the max level and have enough kills. $level_up_possible = $nextLevel <= $max_level && $char_kills >= $required_kills; if ($level_up_possible) { // ****** Perform the level up actions ****** // // Explicitly call for the special case of kill changing to prevent an infinite loop. $userKills = change_kills($char_id, -1 * $required_kills, $auto_level_check = false); $userLevel = addLevel($char_id, 1); change_strength($char_id, $stat_value_to_add); change_speed($char_id, $stat_value_to_add); change_stamina($char_id, $stat_value_to_add); change_karma($char_id, 1); // Only add 1 to karma via levelling. change_ki($char_id, 50); // Add 50 ki points via levelling. addHealth($char_id, $health_to_add); addTurns($char_id, $turns_to_give); // Send a level-up message, for those times when auto-levelling happens. send_event($char_id, $char_id, "You levelled up! Your strength raised by {$stat_value_to_add}, speed by {$stat_value_to_add}, stamina by {$stat_value_to_add}, Karma by 1, and your Ki raised 50! You gained some health and turns as well! You are now a level {$userLevel} ninja! Go kill some stuff."); return true; } else { return false; } } } }
$target_damage = 5 * ceil($player->level() / 3) + rand(1, $player->getStrength()); $generic_skill_result_message = "__TARGET__ has taken {$target_damage} damage!"; $victim_alive = $target->harm($target_damage); $msg = "You have had fire bolt cast on you by " . $player->name(); send_event($player->id(), $target->id(), $msg); } else { if ($command == 'Heal' || $command == 'Harmonize') { // This is the starting template for self-use commands, eventually it'll be all refactored. $harmonize = false; if ($command == 'Harmonize') { $harmonize = true; } $hurt = $target->is_hurt_by(); // Check how much the TARGET is hurt (not the originator, necessarily). // Check that the target is not already status healing. if ($target->hasStatus(HEALING) && !$player->isAdmin()) { $turn_cost = 0; $generic_state_change = '__TARGET__ is already under a healing aura.'; } elseif ($hurt < 1) { $turn_cost = 0; $generic_skill_result_message = '__TARGET__ is already fully healed.'; } else { if (!$harmonize) { $original_health = $target->health(); $heal_per_level = 10; // For standard heal. $heal_points = $player->level() * $heal_per_level; $new_health = $target->heal($heal_points); // Won't heal more than possible $healed_by = $new_health - $original_health; } else {
} return $res; } } public static function char_inventory($char_id) { return inventory_counts($char_id); } } // Redirect for any non-admins. $char_id = self_char_id(); $self = null; if (positive_int($char_id)) { $self = new Player($char_id); } if ($self instanceof Player && $self->isAdmin()) { // Admin possibilities start here. $view_char = null; $dupes = AdminViews::duped_ips(); $stats = AdminViews::high_rollers(); $npcs = NpcFactory::allNonTrivialNpcs(); $trivial_npcs = NpcFactory::allTrivialNpcs(); $char_name = in('char_name'); if (is_string($char_name) && trim($char_name)) { $view_char = get_char_id($char_name); } // If a request is made to view a character's info, show it. $view_char = $view_char ? $view_char : in('view'); $char_infos = $char_inventory = $message = null; if ($view_char) { $char_infos = AdminViews::split_char_infos($view_char);