Location: PHPKode > projects > PhpBlock > A9.8/script/zone.class.php
<?php

include_once $PATH_TO_CODE."/script/imagemanager.class.php";
include_once $PATH_TO_CODE."/script/realobject.class.php";
include_once $PATH_TO_CODE."/script/block.class.php";

class Zone {

	public function __construct($parZoneId=false) {
		if($parZoneId) {
			Log::debug("1 Zone::__construct $parZoneId<br>");
			$this->zoneId = $parZoneId;
			$this->initZone();
			Log::debug("2 Zone::__construct $parZoneId<br>");
		}
	}

	private function initZone() {
		Log::debug("Zone::initZone $this->zoneId<br>");
		$res = executer("SELECT zoneId, x, y, z, zoneType, blockId, occuped, occupedWithMovable, gold FROM zone WHERE zoneId=$this->zoneId");
		$row = mysql_fetch_array($res);
		if(!$row) {
			die("Zone->initZone(): $this->zoneId doesn't exist in database");
		}
		$this->initZoneWithRow($this, $row);
	}
	
	public function initZoneWithRow($zone, $row) {
		Zone::staticGetZoneWithRow($this, $row);
	}

	public static function staticGetZoneWithRow($zone, $row) {
		$zone->zoneId=$row[0];
		Log::debug("Zone::staticGetZoneWithRow $zone->zoneId<br>");
		$zone->x = $row[1];
		$zone->y = $row[2];
		$zone->z = $row[3];
		$zone->zoneType = $row[4];
		$zone->blockId = $row[5];
		$zone->occuped = $row[6];
		$zone->occupedWithMovable = $row[7];
		$zone->gold = $row[8];
		Log::debug("Zone this->blockId $zone->blockId <br>");
	}

	public static function staticGetResForBlockId($parBlockId) {
		return executer("SELECT zoneId, x, y, z, zoneType, blockId, occuped, occupedWithMovable, gold FROM zone WHERE blockId=$parBlockId");
	}

	public function leave() {
		$this->occuped = max($this->occuped - 1, 0);
		executer("UPDATE zone SET occuped=$this->occuped WHERE zoneId=$this->zoneId");
	}
	public function leaveWithMovable(){
		$this->occupedWithMovable = max($this->occupedWithMovable - 1, 0);
		executer("UPDATE zone SET occupedWithMovable=$this->occupedWithMovable WHERE zoneId=$this->zoneId");
	}
	public function occuped($parCount=1) {
		$this->occuped = $this->occuped + $parCount;
		executer("UPDATE zone SET occuped=$this->occuped WHERE zoneId=$this->zoneId");
	}
	public function occupedWithMovable() {
		$this->occupedWithMovable = $this->occupedWithMovable + 1;
		executer("UPDATE zone SET occupedWithMovable=$this->occupedWithMovable WHERE zoneId=$this->zoneId");
	}

	public function isOccuped() {
		return ($this->occuped > 0 || $this->isOccupedWithMovable());
	}
	public function isOccupedWithMovable() {
		return ($this->occupedWithMovable > 0);
	}
	/**@return if zone is not occuped or only with movable*/
	public function isOccupedWithOnlyNonMovable() {
		return $this->occuped > 0 && !$this->isOccupedWithMovable();
	}

	public function getInfo($parType1, $parType2) {
		$res = executer("SELECT value FROM zoneInfo WHERE type1=$parType1 AND type2=$parType2 AND zoneId=$this->zoneId");
		$row = mysql_fetch_array($res);
		return $row[0];
	}
	public function setInfo($parType1, $parType2, $parValue) {
		executer("UPDATE zoneInfo SET value=$parValue WHERE zoneId=$this->zoneId AND type1=$parType1 AND type2=$parType2");
	}
	public function addInfo($parType1, $parType2, $parValue) {
		executer("UPDATE zoneInfo SET value=value+$parValue WHERE zoneId=$this->zoneId AND type1=$parType1 AND type2=$parType2");
	}
	public static function insertInfo($parZoneId, $parType1, $parType2, $parValue) {
		executer("REPLACE INTO zoneInfo (zoneId, type1, type2, value) VALUES ($parZoneId, $parType1, $parType2, $parValue)");
	}

	public function setZoneType($parNewZoneType) {
		$this->debug("setZoneType", "parNewZoneType=$parNewZoneType");
		if($parNewZoneType <> $this->zoneType) {
			$this->eraseCurrentZoneType();
			$this->initZoneType($parNewZoneType);
			$this->zoneType=$parNewZoneType;

			executer("UPDATE zone SET zoneType=$parNewZoneType WHERE zoneId=$this->zoneId");
			global $gloObjectManager;
			$locBlock = $gloObjectManager->getBlock($this->blockId);
			$this->zoneHasBeenModified($locBlock);
		}
	}

	protected function eraseCurrentZoneType() {
		$this->debug("eraseCurrentZoneType", "");
		global $gloObjectManager;
		switch($this->zoneType) {
			case Constante::$ZONE_TYPE_PLAIN:
				break;
			default:
				//Nothing todo
				break;
		}
	}

	public function initZoneType($parNewZoneType) {
		$this->debug("initZoneType", "parNewZoneType=$parNewZoneType");
		switch($parNewZoneType) {
			case Constante::$ZONE_TYPE_PLAIN:
				break;
			default:
				//Nothing todo
		}
	}

	public function notifyTopHole() {
		$locTopZone = $this->getTopZone();
		if($locTopZone && $locTopZone->zoneType == Constante::$ZONE_TYPE_PLAIN) {
			global $gloObjectManager;
			$locTopBlock = $gloObjectManager->getBlock($locTopZone->blockId);
			$locTopZone->zoneHasBeenModified($locTopBlock);
		}
	}

	public function isAboveEmpty() {
		$locBottomZone = $this->getBottomZone();
		if($locBottomZone) {
			return ($locBottomZone->zoneType == Constante::$ZONE_TYPE_PLAIN);
		}
	}
	public function isHole() {
		if($this->zoneType == Constante::$ZONE_TYPE_PLAIN) {
			$locBottomZone = $this->getBottomZone();
			if($locBottomZone) {
				return ($locBottomZone->zoneType == Constante::$ZONE_TYPE_PLAIN);
			}
		}
		return false;
	}

	public function getBottomZone() {
		if(Zone::staticCanExistXYZ($this->x, $this->y, $this->z-1)) {
			$locZoneId = Zone::getZoneId($this->x, $this->y, $this->z-1);
			global $gloObjectManager;
			return $gloObjectManager->getZone($locZoneId);
		} else {
			return false;
		}
	}

	public function getTopZone() {
		$locZoneId = Zone::getZoneId($this->x, $this->y, $this->z+1);
		if(Zone::staticCanExistXYZ($this->x, $this->y, $this->z+1)) {
			global $gloObjectManager;
			return $gloObjectManager->getZone($locZoneId);
		} else {
			return false;
		}
	}

	public function getZoneTypeImagePath() {
		switch($this->zoneType) {
			case Constante::$ZONE_TYPE_PLAIN:
				$locImagePath = "zoneplain.png";
				break;
			default:
				$locImagePath = "zonerandom.png";
		}
		$locImagePath = Constante::getPathToImage()."/$locImagePath";
		return $locImagePath;
	}
	public function createImage($parSize) {
		$this->debug("createImage", "parSize=$parSize");
		$parArrayOfDataType = array();

		$locZoneUniqueString = $this->getUniqueString($parSize, $parArrayOfDataType);

		$locImageManager = ImageManager::getInstance();
		global $gloObjectManager;

		$locImgZone = imagecreatetruecolor($parSize, $parSize);
		imagealphablending($locImgZone, false);
		imagesavealpha($locImgZone, true);

		$locImageColorTransparent = imagecolorallocatealpha($locImgZone, 255, 255, 255, 127);
		imagefill($locImgZone, 0, 0, $locImageColorTransparent);
		imagealphablending($locImgZone, true);

		$locGetImageOfImageType=True;
		if($this->isHole()) {
			$locFactor = 80;
			$locPrevBottomZone=$this->getBottomZone();
			$locBottomZone=$this->getBottomZone();
			while($locBottomZone && $locBottomZone->isHole() && ($locFactor > 1)) {
				$locPrevBottomZone = $locBottomZone;
				$locBottomZone = $locBottomZone->getBottomZone();
				$locFactor=$locFactor*0.9;
			}

			if($locFactor < 1) {
				$locGetImageOfImageType=false;
				$locBlack = imagecolorallocate($locImgZone, 0, 0, 0);
				imagefill($locImgZone, 0, 0, $locBlack);
			} else {
				if($locPrevBottomZone) {
					$locArrayOfDataType = array();
					$locBottomZoneImage = $locPrevBottomZone->getImage($parSize, $locArrayOfDataType);
					if($locBottomZoneImage) {
						$locGetImageOfImageType=false;
						$locSize = $parSize*$locFactor/100;
						imagecopyresampled($locImgZone, $locBottomZoneImage,
						($parSize-$locSize)/2, ($parSize-$locSize)/2,
						0, 0,
						$locSize, $locSize,
						$parSize, $parSize);
					}
				}
			}
		}

		if ($locGetImageOfImageType) {
			$locImagePath = $this->getZoneTypeImagePath();
			list($locWidthImageFromFile, $locHeightImageFromFile, $locType, $locAttr) = getimagesize($locImagePath);
			//Faire un cache pour les images qui sont fixes comme celles ci-dessus pour �viter de tous r��chantillonner � chaque fois
			$locImgZoneFromFile = imagecreatefrompng($locImagePath);
			imagecopyresampled($locImgZone, $locImgZoneFromFile, 0, 0, 0, 0, $parSize, $parSize, $locWidthImageFromFile, $locHeightImageFromFile);
		}

		$res=executer("
            SELECT objectId
            FROM object
            WHERE zoneId=$this->zoneId
            AND isBackground = 1
            ORDER BY displayPriority ASC");

		while($row=mysql_fetch_array($res)) {
			$locRealObject = $gloObjectManager->getRealObject($row[0]);
			$locRealObjectImage = $locRealObject->getImage($parSize, true);
			$locRes = imagecopyresampled($locImgZone, $locRealObjectImage, 0, 0, 0, 0, $parSize, $parSize, $parSize, $parSize);
			//bool imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h)
			Log::debug("Zone($this->zoneId)::getImage, imagecopyresampled(image of ".$row[0].")=".$locRes);
		}

		$locImageManager->setZoneImage($locImgZone, $this->blockId, $this->zoneId, $locZoneUniqueString);
	}

	public function isSurface() {
		return $this->z == Site::$ZONE_COORD_Z_GROUND_LEVEL;
	}

	//TODO faire un block static image pour am�liorer les perfs ?
	public function getImage($parSize, &$parArrayOfDataType) {
		Log::debug("Zone($this->zoneId)::getImage");
		$locImageManager = ImageManager::getInstance();
		$locZoneUniqueString = $this->getUniqueString($parSize, $parArrayOfDataType);
		$locImgZone = $locImageManager->getImage($this->blockId, $this->zoneId, $locZoneUniqueString);

		return $locImgZone;
	}

	public function isOtherAllianceObjectNear($parAllianceId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ) {
		$res = executer("SELECT objectId
			FROM object 
			WHERE object.allianceId<>$parAllianceId 
			AND canTakeControl>0
			AND isLobotomize<>".RealObject::$UNIT_IS_DEAD." 
			AND object.zoneId IN ".Zone::getStaticZoneIdsWhereClauseList($this->zoneId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ));
		return mysql_fetch_array($res);
	}
	public function isOtherAllianceZoneNear($parAllianceId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ) {
		return mysql_fetch_array($this->getOtherAllianceObjectNearRes($parAllianceId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ));
	}
	public function getOtherAllianceObjectNearRes($parAllianceId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ) {
		return executer("SELECT objectId
			FROM object 
			WHERE object.allianceId<>$parAllianceId 
			AND canTakeControl>0
			AND isLobotomize<>".RealObject::$UNIT_IS_DEAD." 
			AND object.zoneId IN ".Zone::getStaticZoneIdsWhereClauseList($this->zoneId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ));
	}
	public function getObjectsIdRes($parObjectType=-1, $parAllianceId=False) {
		$req="SELECT objectId FROM object WHERE zoneId=$this->zoneId";
		if($parObjectType != -1) {
			$req.=" AND objectType=$parObjectType";
		}
		if($parAllianceId) {
			$req.=" AND allianceId=$parAllianceId";
		}
		return executer($req);
	}

	public function getObjects($parObjectType=-1, $parAllianceId=False) {
		$res=$this->getObjectsIdRes($parObjectType, $parAllianceId);
		return RealObject::getObjectsWithResult($res);
	}

	public function getObjectsDisplayPriority($parDisplayPriority, $parAllianceId) {
		$res = executer("
                SELECT objectId
                FROM object
                WHERE zoneId=$this->zoneId
                AND allianceId=$parAllianceId
                AND displayPriority=$parDisplayPriority");
		return RealObject::getObjectsWithResult($res);
	}

	public function getObjectsNotAlliance($parObjectType, $parAllianceId, $parZoneRangeX=0, $parZoneRangeY=0, $parZoneRangeZ=0) {
		$locResult=array();
		$res=executer("SELECT objectId
				FROM object 
				WHERE zoneId IN ".Zone::getStaticZoneIdsWhereClauseList($this->zoneId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ)."
				".($parObjectType==-1?"":"AND objectType=$parObjectType")." 
				AND allianceId<>$parAllianceId");
		return RealObject::getObjectsWithResult($res);
	}

	public function debug($parMethodName, $parMessage) {
		Log::debug("Zone($this->zoneId)::$parMethodName => $parMessage");
	}

	public function getUniqueString($parSize, &$parArrayOfDataType) {
		if(in_array(Constante::$MAP_MODE_SATELLITE_VIEW, $parArrayOfDataType))
		{
			return "$parSize".SEP_URL_UNIQUE_STRING.Constante::$MAP_MODE_SATELLITE_VIEW;
		} else
		{
			return "$parSize";
		}
	}

	/**
	 * modified this zone
	 * @param $parbLock if false then it gets it
	 */
	public function zoneHasBeenModified($parBlock=false) {
		/*if(!$parBlock) {
			global $gloObjectManager;
			$parBlock = $gloObjectManager->getBlock($this->blockId);
		}*/
		$locImageManager = ImageManager::getInstance();
		$locImageManager->addImageZoneToGenerate($this->zoneId);
		$locImageManager->addImageBlockToGenerate($this->blockId);
		
		$this->notifyTopHole();
		RealObject::forceTakeDecisionNear($this->zoneId);
	}
	public static function staticGetTextZoneCoord($parZoneId) {
		list($x, $y, $z) = Zone::getZoneCoord($parZoneId);
		return "($x, $y, ".Constante::normalizeZ($z).")";
	}
	public static function getZoneId($parX, $parY, $parZ) {
		//Log::debug("Zone::getZoneId $parX, $parY, $parZ = ".$parX.formatNumber($parY, Constante::$ZONE_COORD_STRING_SIZE).formatNumber($parZ, Constante::$ZONE_COORD_Z_STRING_SIZE)."<br>");
		return $parX.formatNumber($parY, Constante::$ZONE_COORD_STRING_SIZE).formatNumber($parZ, Constante::$ZONE_COORD_Z_STRING_SIZE);
	}

	public static function getZoneCoord($parZoneId) {
		$locX = intval(substr($parZoneId, 0, Constante::$ZONE_COORD_STRING_SIZE));
		$locY = intval(substr($parZoneId, Constante::$ZONE_COORD_STRING_SIZE, Constante::$ZONE_COORD_STRING_SIZE));
		$locZ = intval(substr($parZoneId, 2*Constante::$ZONE_COORD_STRING_SIZE, Constante::$ZONE_COORD_Z_STRING_SIZE));
		//Log::debug("Zone::getZoneCoord($parZoneId)=($locX, $locY, $locZ)");
		return array($locX, $locY, $locZ);
	}
	public static function getRange($parZoneId1, $parZoneId2) {
		list($x1, $y1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2) = Zone::getZoneCoord($parZoneId2);
		return max(abs($x1-$x2), abs($y1-$y2));
	}
	public static function getRange3d($parZoneId1, $parZoneId2) {
		return Zone::staticGetRange3d($parZoneId1, $parZoneId2);
	}
	public static function staticGetRange3d($parZoneId1, $parZoneId2) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return max(abs($x1-$x2), abs($y1-$y2), abs($z1-$z2));
	}
	public static function staticGetEuclideanDistance2dAndZ($parZoneId1, $parZoneId2, $parMuxZ=1) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return sqrt(pow($x1-$x2, 2.0) + pow($y1-$y2, 2.0)) + abs($z1-$z2)*$parMuxZ;
	}
	public static function staticGetEuclideanDistance3d($parZoneId1, $parZoneId2) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return sqrt(pow($x1-$x2, 2.0) + pow($y1-$y2, 2.0) + pow($z1-$z2, 2.0));
	}
	public static function staticSum2d($parZoneId1, $parZoneId2) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return abs($x1-$x2) + abs($y1-$y2);
	}
	public static function staticMax2d($parZoneId1, $parZoneId2) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return max(abs($x1-$x2), abs($y1-$y2));
	}
	public static function staticSum3d($parZoneId1, $parZoneId2) {
		list($x1, $y1, $z1) = Zone::getZoneCoord($parZoneId1);
		list($x2, $y2, $z2) = Zone::getZoneCoord($parZoneId2);
		return abs($x1-$x2) + abs($y1-$y2) + abs($z1-$z2);
	}

	public static function staticIsNear($parZoneId1, $parZoneId2) {
		return Zone::staticGetRange3d($parZoneId1, $parZoneId2)<=1;
	}
	public function getZoneIdsWhereClauseList($parRangeX, $parRangeY, $parRangeZ=0)
	{
		return Zone::getStaticZoneIdsWhereClauseList($this->zoneId, $parRangeX, $parRangeY, $parRangeZ);
	}

	public static function getStaticZoneIdsWhereClauseList($parZoneId, $parRangeX, $parRangeY, $parRangeZ=0)
	{
		$locZoneIds = Zone::getStaticZoneIdsFromXY($parZoneId, $parRangeX, $parRangeY, $parRangeZ);
		$locRequestPieceWithZoneIdIn = " (";
		foreach($locZoneIds as $locZoneId)
		{
			$locRequestPieceWithZoneIdIn.="$locZoneId,";
		}
		$locRequestPieceWithZoneIdIn.="-1)";
		return $locRequestPieceWithZoneIdIn;
	}

	public static function getStaticZoneIdsFromXY($parZoneId, $parZoneRangeX, $parZoneRangeY, $parRangeZ=0)
	{
		return Zone::getStaticZoneIdsFromXYZ($parZoneId, $parZoneRangeX, $parZoneRangeY, $parRangeZ);
	}

	public static function getStaticZoneIdsFromXYZ($parZoneId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ)
	{
		if($parZoneRangeX<0)
		die("parZoneRangeX=$parZoneRangeX, negative number is forbidden in Zone::getStaticZoneIdsFromXYZ");
		if($parZoneRangeY<0)
		die("parZoneRangeY=$parZoneRangeY, negative number is forbidden in Zone::getStaticZoneIdsFromXYZ");
		if($parZoneRangeZ<0)
		die("parZoneRangeZ=$parZoneRangeZ, negative number is forbidden in Zone::getStaticZoneIdsFromXYZ");

		list($locZoneX, $locZoneY, $locZoneZ) = Zone::getZoneCoord($parZoneId);
		$locZoneArray = array();
		for($locZ  = max(Constante::getMinZ(), $locZoneZ - $parZoneRangeZ);
		$locZ <= min(Constante::getMaxZ(), $locZoneZ + $parZoneRangeZ);
		$locZ ++)
		{
			for($locX  = max(Constante::getMinX(), $locZoneX - $parZoneRangeX);
			$locX <= min(Constante::getMaxX(), $locZoneX + $parZoneRangeX);
			$locX ++)
			{
				for($locY  = max(Constante::getMinY(), $locZoneY - $parZoneRangeY);
				$locY <= min(Constante::getMaxY(), $locZoneY + $parZoneRangeY);
				$locY ++)
				{
					array_push($locZoneArray, Zone::getZoneId($locX, $locY, $locZ));
				}
			}
		}
		return $locZoneArray;
	}

	public static function staticCanExistXYZ($x, $y, $z) {
		if(        $x < Constante::getMinX()
		|| $x > Constante::getMaxX()
		|| $y < Constante::getMinY()
		|| $y > Constante::getMaxY()
		|| $z < Constante::getMinZ()
		|| $z > Constante::getMaxZ()
		) {
			return false;
		}
		return true;
	}
	public static function staticCanExist($parZoneId) {
		list($x, $y, $z) = Zone::getZoneCoord($parZoneId);
		return Zone::staticCanExistXYZ($x, $y, $z);
	}
	public static function exist($parZoneId)
	{
		list($x, $y, $z) = Zone::getZoneCoord($parZoneId);
		if(!Zone::staticCanExistXYZ($x, $y, $z)) {
			return false;
		}
		$res = executer("SELECT zoneId FROM zone WHERE zoneId=$parZoneId");
		$row = mysql_fetch_array($res);
		return $row[0];
	}

	public function atLeastOneZoneIsOwn($parPlayerId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ)
	{
		$res = executer("SELECT zoneId FROM zone, block WHERE zone.blockId=block.blockId AND block.playerId=$parPlayerId AND zoneId IN ".Zone::getStaticZoneIdsWhereClauseList($this->zoneId, $parZoneRangeX, $parZoneRangeY, $parZoneRangeZ));
		return mysql_fetch_array($res);
	}

	public function getZoneTypeToString() {
		return Zone::staticGetZoneTypeToString($this->zoneType);
	}

	public static function staticGetZoneTypeToString($parZoneType) {
		switch($parZoneType) {
			case Constante::$ZONE_TYPE_PLAIN:
				$locResult.= "empty";
				break;
			default:
				$locResult.= "$parZoneType";
		}
		return $locResult;
	}

	/**@return an array with zoneId*/
	public function getAllZoneId($parRangeX, $parRangeY, $parRangeZ) {
		return $this->getAllZoneIdOfZoneType(-1, $parRangeX, $parRangeY, $parRangeZ);
	}
	/**@return an array with zoneId*/
	public function getAllZoneIdOfZoneType($parZoneType, $parRangeX, $parRangeY, $parRangeZ) {
		$locZoneIds = array();
		$res = executer("SELECT zoneId FROM zone
                WHERE zoneId IN".$this->getZoneIdsWhereClauseList($parRangeX, $parRangeY, $parRangeZ).
				($parZoneType != -1?" AND zoneType=$parZoneType":""));
		while($row = mysql_fetch_array($res)) {
			array_push($locZoneIds, $row[0]);
		}
		return $locZoneIds;
	}

	public static function create($parZoneId, $parBlockId, $parZoneType, $paroccuped) {
		list($x, $y, $z) = Zone::getZoneCoord($parZoneId);
		executer("INSERT INTO zone(zoneId, x, y, z, blockId, zoneType, modified, occuped) VALUES($parZoneId, $x, $y, $z, $parBlockId, $parZoneType, 1, $paroccuped)");

		$locImageManager = ImageManager::getInstance();
		$locImageManager->createDirectories($parBlockId, $parZoneId);
	}

	public function toStringForAlliance($parAllianceId) {
		global $gloObjectManager;
		$locBlock = $gloObjectManager->getBlock($this->blockId);
		$locResult = "(x: $this->x, y: $this->y, z: ".Constante::normalizeZ($this->z).") ";
		$locResult.= "type: ".$this->getZoneTypeToString();
		if($this->isOccuped()) {
			$locResult.= ", occuped";
		}
		if($locBlock->playerId > 0) {
			$locPlayer = $gloObjectManager->getPlayer($locBlock->playerId);
			$locResult.= ", owner: ".$locPlayer->playerName;
		} else {
			$locResult.= ", no owner";
		}
		if($parAllianceId != -1) {
			$res=executer("
	            SELECT objectId
	            FROM object
	            WHERE zoneId=$this->zoneId
	            AND visibleState=".RealObject::$REAL_OBJECT_VISIBLE_STATE_VISIBLE_BY_ALL);
			while($row = mysql_fetch_array($res)) {
				$locRealObjectId = $row[0];
				$locObject = $gloObjectManager->getRealObject($locRealObjectId);
				$locResult.="\n  object on it:\n{";
				$locResult.=$locObject->toStringForAlliance($parAllianceId);
				$locResult.="}";
			}
		}
		return $locResult;
	}
	public function toString() {
		return $this->toStringForAlliance(-1);
	}
	public function isAffectedByUpAndDownCost() {
		return true;
	}
	public function getMoveCostFactor() {
		$locResult = 1.0;
		return $locResult;
	}
	public function isAccessibleForIt($parRealObject) {
		if($this->isOccuped()) {
			return false;
		} else {
			return true;
		}
	}
}
?>
Return current item: PhpBlock