/** * 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; }
public function data($specific = null) { static $data; if (!$data) { $data = add_data_to_player_row($this->as_array()); // Cache this data over the live of the player object. } if ($specific) { return $data[$specific]; } else { return $data; } }