Пример #1
0
/**
 * Returns the state of the player from the database,
 * uses a user_id if one is present, otherwise
 * defaults to the currently logged in player, but can act on any player
 * if another username is passed in.
 * @param $user user_id or username
**/
function char_info($p_id)
{
    if (!$p_id) {
        if (defined('DEBUG') && DEBUG) {
            nw_error('DEPRECATED: call to char_info with a null argument.  For clarity reasons, this is now deprecated, use the player object instead. Backtrace: ' . print_r(debug_backtrace(), true));
        }
        return self_info();
    }
    $id = whichever($p_id, SESSION::get('player_id'));
    // *** Default to current player. ***
    if (!is_numeric($id)) {
        // If there's no id, don't try to get any data.
        return null;
    }
    $player = new Player($id);
    // Constructor uses DAO to get player object.
    $player_data = array();
    if ($player instanceof Player && $player->id()) {
        // Turn the player data vo into a simple array.
        $player_data = (array) $player->vo;
        $player_data['clan_id'] = $player->getClan() ? $player->getClan()->getID() : null;
        $player_data = add_data_to_player_row($player_data);
    }
    return $player_data;
}
Пример #2
0
    		}
    		$$type = $char->$type(); // Default to current values.
    	}*/
    $changed = PlayerDAO::saveDetails($char);
    redirect('/stats.php?changed=' . (int) $changed . ($profile_changed ? '&profile_changed=1' : ''));
}
/*
if(false && DEBUG){
	$description = 'This is a description here and all';
	$goals = 'Kill ninja of the ramen clan';
	$beliefs = 'I believe in a one true ninja god';
	$instincts = 'When I hear whistling, I duck';
	$traits = 'Hardy, nervous, meaty, silent';
}
*/
$player = self_info();
//$player['created_date']=$player['created_date']? date("c", strtotime($player['created_date'])) : null;
$class_theme = class_theme($char->class_identity());
$level_category = level_category($player['level']);
$status_list = get_status_list();
$gravatar_url = generate_gravatar_url($player['player_id']);
$gurl = $gravatar_url;
$rank_display = get_rank($char_id);
// rank display.
$profile_editable = $player['messages'];
$parts = get_certain_vars(get_defined_vars(), ['player', 'level_category', 'status_list', 'description', 'goals', 'beliefs', 'instincts', 'traits', 'dev', 'changed']);
// Set the parts array's player clan if any is found.
if ($parts['player_clan'] = get_clan_by_player_id($char_id)) {
    // Set the char clan name and id for later usage.
    $parts['clan_name'] = $parts['player_clan']->getName();
    $parts['clan_id'] = $parts['player_clan']->getID();
Пример #3
0
<?php

require_once LIB_ROOT . "control/lib_player_list.php";
require_once LIB_ROOT . "control/lib_grouping.php";
require_once LIB_ROOT . "data/lib_npc.php";
$private = true;
$alive = false;
if ($error = init($private, $alive)) {
    header('Location: list.php');
} else {
    $char_name = self_name();
    $peers = nearby_peers(self_char_id());
    $active_ninjas = get_active_players(5, true);
    // Get the currently active ninjas
    $char_info = self_info();
    $char = new Player(self_char_id());
    $match_string = in('enemy_match', null, 'no filter');
    $add_enemy = in('add_enemy', null, 'toInt');
    $remove_enemy = in('remove_enemy', null, 'toInt');
    $enemy_limit = 20;
    $max_enemies = false;
    $enemy_list = null;
    if ($match_string) {
        $found_enemies = get_enemy_matches($match_string);
    } else {
        $found_enemies = null;
    }
    if (is_numeric($remove_enemy) && $remove_enemy != 0) {
        remove_enemy($remove_enemy);
    }
    if (is_numeric($add_enemy) && $add_enemy != 0) {
Пример #4
0
<?php

$char_id = self_char_id();
// Initialize page display vars.
$player_info = array();
$title = 'Mini-chat Solo Page';
$unread_message_count = 0;
// Get the actual values of the vars.
$player_info = self_info();
$username = $player_info['uname'];
// Create the settings to pass to the page.
$options = array('is_index' => true);
// Assign these vars to the template.
$parts = array('body_classes' => 'mini-chat-solo-page', 'version' => 'NW Version 1.7.5 2010.12.05', 'logged_in' => (bool) $char_id, 'is_not_logged_in' => !$char_id, 'username' => $username);
// Logged in display.
display_page('mini-chat.section.tpl', $title, $parts, $options);
Пример #5
0
<?php

require_once LIB_ROOT . "control/lib_status.php";
// Status alterations.
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 ***