phudbase/
phudbase/client/
phudbase/client/css/
phudbase/client/images/colorbox/CVS/
phudbase/client/js/
phudbase/server/
phudbase/server/includes/actions/
phudbase/server/includes/classes/
phudbase/server/includes/classes/GameObjects/
<?php
class Character extends GameObject
{
	private $room; // Room EID

	function __construct($eid, $name, $desc, $type=GO_TYPE_CHAR)
	{	
		parent::__construct($eid, $name, $desc, $type);
		
		global $rooms;
		$this->room = $rooms[0][0]->getEID();	
		
		$this->getRoom()->addCharacter($this);
		$this->loadToCache();
	}
	
	function loadToCache()
	{		
		setCharMem($this);
	}
		
	function setRoom($room)
	{
		$this->room = $room->getEID();		
	}	
	
	function getRoom()
	{		
		return getRoomMem($this->room);
	}	
	
	function getX()
	{
		return $this->getRoom()->getX();
	}
	
	function getY()
	{
		return $this->getRoom()->getY();
	}
	
	function setOffline()
	{
		$this->getRoom()->removeCharacter($this);
		$this->getRoom()->send("{$this->getName()} has departed the land of Phud, to be seen again soon. Or not.", "sysmessage");
		if (is_object($this->getConnection())) $this->getConnection()->close();
	}
	
	// ****** Communication Features ****** //
		
	// Retrieve the socket connection for a logged in player //
	function getConnection()
	{
		global $game;
		if (is_object($game) && $game->isRunning())
		{
			$cConn = $game->getConnection($this->getEID());
			if (is_object($cConn))
				return $cConn;
		}
		
		return false;
	}
	
	// Send a message to the player (via socket connection) //
	function send($message, $mType="notify")
	{		
		$cConn = $this->getConnection();
		
		if (is_object($cConn))
		{			
			// +++++++++++ Format the message ++++++++++++ //
			
			$message = formatMessage($message, $mType, $cConn->getClientType());			
			$message = stripSysCalls($message, $this, $cConn->getClientType());
									
			$cConn->send($message);			
		}
	}
	
	function sendDirect($message)
	{
		$cConn = $this->getConnection();
		
		if (is_object($cConn))
		{
			$cConn->send($message);			
		}
	}	
}
?>