<?php
class ZoneGenerator{
public function __construct($parZoneType, $parOccupedCount=0) {
$this->zoneType = $parZoneType;
$this->occupedCount = $parOccupedCount;
}
public function createZone($parBlockId, $parZoneId) {
if($this->zoneType == DungeonConstante::$ZONE_TYPE_ROCK) {
$locZoneTypeToInsert = $this->zoneType;
$locFree = 1;
} else {
$locZoneTypeToInsert=Constante::$ZONE_TYPE_PLAIN;
$locFree = 0;
}
DungeonZone::create($parZoneId, $parBlockId, $locZoneTypeToInsert, $locFree);
}
public function randomZone($parZoneId) {
list($x, $y, $z) = Zone::getZoneCoord($parZoneId);
$locZoneTypeToModify = false;
if(Site::$ZONE_COORD_Z_GROUND_LEVEL == $z) {
$locZoneTypeToModify = false;
} else {
$locRand = rand(1, 100);
if($locRand <= 1) {
$locZoneTypeToInsert = DungeonConstante::$ZONE_TYPE_GOLD;
$locZoneTypeToModify = true;
} elseif($locRand <= 15) {
$locZoneTypeToInsert = DungeonConstante::$ZONE_TYPE_STONE;
$locZoneTypeToModify = true;
} elseif($locRand <= 18) {
$locZoneTypeToInsert = Constante::$ZONE_TYPE_PLAIN;
$locZoneTypeToModify = true;
}
if($locZoneTypeToModify) {
global $gloObjectManager;
$locZone = $gloObjectManager->getZone($parZoneId);
$locZone->setZoneType($locZoneTypeToInsert);
}
}
if($this->occupedCount > 0) {
global $gloObjectManager;
$locZone = $gloObjectManager->getZone($parZoneId);
$locZone->occuped($this->occupedCount);
}
}
}
?>