コード例 #1
0
ファイル: dojo.php プロジェクト: reillo/ninjawars
            // Class change requested, not a page refresh, and requested class is existant.
            if (!$class_change_requirement_error) {
                // Class change conditions are ok, so:
                // subtract the cost in turns
                // ...and change the class.
                $class_change_error = set_class($char_id, $destination_class_identity);
                if (!$class_change_error) {
                    $char->changeTurns(-1 * $class_change_cost);
                }
            }
        }
        $possibly_changed_class = char_class_identity($char_id);
        $possibly_changed_class_name = char_class_name($char_id);
        $possibly_changed_class_theme = class_theme($possibly_changed_class);
        $upgrade_requested = $in_upgrade && $in_upgrade == 1;
        $levelled = false;
        if ($upgrade_requested) {
            // Try to level up.
            $levelled = level_up_if_possible($char_id);
            $char = $player = new Player($char_id);
            $userLevel = $char->level();
            $char_data = $char->data();
            // Get the info for the next level, especially if that has changed.
            $nextLevel = min($userLevel + 1, $max_level);
            $userKills = char_kills($char_id);
            $required_kills = required_kills_to_level($userLevel);
        }
    }
    // End of the logged in processing.
    display_page('dojo.tpl', 'Dojo', get_defined_vars(), array('quickstat' => 'player'));
}
コード例 #2
0
ファイル: commands.php プロジェクト: reillo/ninjawars
function change_kills($char_id, $amount, $auto_level_check = true)
{
    $amount = (int) $amount;
    if (abs($amount) > 0) {
        // Ignore changes that amount to zero.
        if ($amount > 0 && $auto_level_check) {
            // For positive kill changes, check whether levelling occurs.
            level_up_if_possible($char_id, $auto_levelling = true);
        }
        query("UPDATE players SET kills = kills + \n\t\t   CASE WHEN kills + :amount1 < 0 THEN kills*(-1) ELSE :amount2 END\n\t\t   WHERE player_id = :player_id", array(':amount1' => array($amount, PDO::PARAM_INT), ':amount2' => array($amount, PDO::PARAM_INT), ':player_id' => $char_id));
    }
    return get_kills($char_id);
}