<?php
/***************************************************************************
* Copyright (C) 2003 by Sebastian Hess *
* hide@address.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
class CharInfo {
var $__Data;
var $__Skills;
var $__Events;
var $__Tags;
var $__Stats;
var $__UID;
/*
Constructor of the class
It needs the UID of the Player or the Object
@param SphereChars(OBJ) $__SphereChars
@param int $UID
@return CharInfo
*/
function CharInfo(&$__SphereChars,$UID) {
/*
Check if $__SphereChars is an Object and
if the data has already been read
*/
if(!is_object($__SphereChars))
return false;
if(!$__SphereChars->Ready)
return false;
/*
Save the UID for later use
*/
$this->__UID = $UID;
/*
Init the local vars
*/
$this->__Data = array();
$this->__Skills = array();
$this->__Events = array();
$this->__Stats = array();
$this->__init(&$__SphereChars);
arsort($this->__Skills);
}
function getUID() {
return $this->__UID;
}
function getProp($index) {
/*
Check if the key exists. If not return false
If the key is an integer check if the index is in the
array. If it's a String check If the key exists
*/
if(array_key_exists($index,$this->__Data)
|| (is_numeric($index) && $index < count($this->__Data)))
return $this->__Data[$index];
return false;
}
function getCountofProps() {
return count($this->__Data);
}
function getSkill($index) {
if(array_key_exists($index,$this->_Skills)
|| (is_numeric($index) && $index < count($this->__Skills)))
return $this->__Skills[$index];
return false;
}
function getCountofSkills() {
return count($this->__Skills);
}
function getTag($index) {
if(array_key_exists($index,$this->_Tags)
|| (is_numeric($index) && $index < count($this->__Tags)))
return $this->__Tags[$index];
return false;
}
function getCountofTags() {
return count($this->__Tags);
}
function getEvent($index) {
if(array_key_exists($index,$this->_Events)
|| (is_numeric($index) && $index < count($this->__Events)))
return $this->__Events[$index];
return false;
}
function getCountofEvents() {
return count($this->__Events);
}
function __init(&$chars) {
$data = $chars->getData($this->__UID);
/*
No Player or item for this UID found
*/
if(!$data)
return false;
/*
Read the Player flags and Stats
*/
if(count($data)) {
foreach($data as $key=>$value) {
if(($key=="EVENTS") && count($value))
{
/*
Set the Events of the player (if some exist)
*/
foreach($data["EVENTS"] as $key=>$value)
$this->__Events[] = $value;
}
elseif(in_array($key,$chars->Skilltable))
{
/*
We found a Skill
*/
$this->__Skills[$key] = $value;
}
elseif(in_array($key,$chars->Statstable))
{
/*
We found a Stat of the Char ...
*/
$this->__Stats[$key] = $value;
}
elseif(substr($key,0,4) == "TAG.")
{
/*
We found a Tag
*/
$this->__Tags[substr($key,4)] = $value;
} else {
/*
We found something else ;)
*/
$this->__Data[$key] = $value;
}
}
}
}
}
?>