示例#1
0
function add_data_to_player_row($player_data, $kill_password = true)
{
    if ($kill_password) {
        unset($player_data['pname']);
    }
    $player_data['max_health'] = max_health_by_level($player_data['level']);
    $player_data['hp_percent'] = min(100, round($player_data['health'] / $player_data['max_health'] * 100));
    $player_data['max_turns'] = 100;
    $player_data['turns_percent'] = min(100, round($player_data['turns'] / $player_data['max_turns'] * 100));
    $player_data['next_level'] = required_kills_to_level($player_data['level']);
    $player_data['exp_percent'] = min(100, round($player_data['kills'] / $player_data['next_level'] * 100));
    $player_data['status_list'] = implode(', ', get_status_list($player_data['player_id']));
    $player_data['hash'] = md5(implode($player_data));
    return $player_data;
}
示例#2
0
文件: dojo.php 项目: reillo/ninjawars
/*
 *** IMPORTANT MAINTENANCE NOTES ***
 * To disable class change code: set $classChangeAllowed to boolean false
 * To change order of class change cycling: Update $class_array, key = starting class, value = next class in cycle
 */
$private = false;
$alive = false;
$level_chart = 1;
$kills_chart = 0;
$str_chart = 5;
$speed_chart = 5;
$stamina_chart = 5;
$hp_chart = 150;
$max_level = maximum_level();
// For non-logged in loop through stats.
$max_hp = max_health_by_level(maximum_level() + 1);
if ($error = init($private, $alive)) {
    display_error($error);
} else {
    $msg = '';
    $dim_mak_cost = 70;
    // In turns.
    $dim_mak_strength_requirement = 50;
    // Must have at least a strength of 50 to get and use DimMak, usually level 10.
    $class_change_cost = 50;
    // *** Cost of class change in turns.
    $classes = classes_info();
    $in_upgrade = in('upgrade');
    // Level up request.
    $dimmak_sequence = in('dimmak_sequence', '');
    $classChangeSequence = in('classChangeSequence');
示例#3
0
 public function max_health()
 {
     return max_health_by_level($this->level());
 }
示例#4
0
init(true, false);
// Initialize the environment.
// TODO: Protect this file from unlogged-in displaying.
// *** Turning the header variables into variables for this page.
$section_only = in('section_only') === '1';
// Check whether it's an ajax section.
$command = in('command');
$user_id = get_user_id();
$info = self_info();
$health = $user_id ? $info['health'] : 0;
$strength = $user_id ? $info['strength'] : 0;
$gold = $user_id ? $info['gold'] : 0;
$kills = $user_id ? $info['kills'] : 0;
$turns = $user_id ? $info['turns'] : 0;
$level = $user_id ? $info['level'] : 0;
$class = $user_id ? $info['class'] : 0;
$bounty = $user_id ? $info['bounty'] : 0;
$player = new Player($user_id);
$username = $player->vo->uname;
$next_level = $player->vo->level * 5;
// This needs to have a more centralized formula source.
$max_health = max_health_by_level($level);
$progress = $user_id ? min(100, round($kills / $next_level * 100)) : 0;
$health_pct = $user_id ? min(100, round($health / $max_health * 100)) : 0;
$status_list = get_status_list();
$viewinv = $command == 'viewinv';
// *** TODO: switch this to query() when we switch to SMARTY. Templatelite can't handle iterating over the resultset ***
$items = query_array("SELECT item.item_display_name as item, amount FROM inventory join item on item_type = item.item_id WHERE owner = :user ORDER BY item.item_display_name", array(':user' => $user_id));
$parts = get_certain_vars(get_defined_vars(), array('items', 'status_list'));
// Pull current flat vars + the resultset into the template.
display_page('quickstats.tpl', 'Quickstats', $parts, array('quickstat' => false));