Exemplo n.º 1
0
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;
            }
        }
    }
}
Exemplo n.º 2
0
 }
 //*/
 echo "<a href=\"chart.php\">Upgrade Chart</a><hr>\n";
 $MAX_LEVEL = 250;
 $nextlevel = getLevel($username) + 1;
 $in_upgrade = in('upgrade');
 if ($in_upgrade && $in_upgrade == 1) {
     if ($nextlevel > $MAX_LEVEL) {
         $msg = "There are no trainers that can teach you beyond your current skill. You are legend among the ninja.<br>\n";
     } else {
         if (getKills($username) >= getLevel($username) * 5) {
             subtractKills($username, getLevel($username) * 5);
             addLevel($username, 1);
             addStrength($username, 5);
             addTurns($username, 50);
             addHealth($username, 100);
         } else {
             echo "You do not have enough kills to proceed at this time.<br>\n";
         }
     }
 } else {
     if ($nextlevel > $MAX_LEVEL) {
         $msg = "You enter the dojo as one of the elite ninja. No trainer has anything left to teach you.<br>\n";
     } else {
         if (getKills($username) < getLevel($username) * 5) {
             $msg = "Your trainer finds you lacking. You are instructed to prove your might against more ninja before you return.<br>\n";
         } else {
             echo "<form id=\"level_up\" action=\"dojo.php\" method=\"post\" name=\"level_up\">\n";
             echo "<div>\n";
             echo "<br>Do you wish to upgrade to level " . $nextlevel . "?<br>\n";
             echo "<input id=\"upgrade\" type=\"hidden\" value=\"1\" name=\"upgrade\">\n";
Exemplo n.º 3
0
        $heal_points = $startingGold;
    }
    if ($startingHealth > 0) {
        //Requires the user to be resurrected first.
        if ($heal_points && $heal_points > 0) {
            // Requires a heal number, and a positive one.
            if ($heal_points <= $startingGold) {
                //If there's enough money for the amount that they want to heal.
                if ($startingHealth + $heal_points > $max_health) {
                    // Allows numeric healing to "round off" at the max.
                    $heal_points = $max_health - $startingHealth;
                    //Rounds off.
                }
                subtractGold($username, $heal_points);
                // Having chi increases the amount healed in all cases.
                addHealth($username, $has_chi ? round($heal_points * 1.5) : $heal_points);
                $finalHealth = getHealth($username);
                echo "<p>A monk tends to your wounds and you are " . ($max_health <= $finalHealth ? "fully healed" : "healed to {$finalHealth} hitpoints") . ".</p>\n";
            } else {
                echo "You do not have enough gold for this amount of healing.<br>\n";
            }
        } else {
            echo "You cannot heal with zero gold.<br>\n";
        }
    } else {
        echo "You must resurrect before you can heal.<br>\n";
    }
} else {
    if ($poisoned == 1) {
        //  *** POISON SECTION ***
        if (getHealth($username) > 0) {