Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/action/recruit/recruitmonsternest.class.php
<?php
include_once $PATH_TO_CODE."/modules/dungeon/action/abstractrecruitaction.class.php";

class RecruitMonsterNestAction extends DungeonAbstractRecruitAction {
	function __construct() {
		parent::__construct(DungeonConstante::$ACTION_BUILD_MONSTER_NEST,
		DungeonConstante::$ACTION_BUY_MONSTER_NEST_COST, true);
		$this->isBarrackNecessary = false;
		$this->targetMustNotOccuped = false;
		$this->costIsCash2 = true;
	}

	public function isOkToRecruit($locBlock, $locZone, $locPlayer) {
		global $gloObjectManager;
		list($x, $y, $z) = Zone::getZoneCoord($locZone->zoneId);
		$locManageAction = ManageAction::getInstance();
		$locCountOfMonsterNest = $locBlock->getAllianceObjectNearCount(1, 0, 0, 0, DungeonConstante::$REAL_OBJECT_TYPE_MONSTER_NEST);
		if($locCountOfMonsterNest > 0) {
			$locManageAction->addPlayerInfo("At least one monster nest is already present here");
			return false;
		}
		if($locBlock->allianceId > 0) {
			$locManageAction->addPlayerInfo("You can't build a monster nest on an occuped area");
			return false;
		}
		if($locBlock->isOtherAllianceObjectNear(1, 1, 1, 1)) {
			$locManageAction->addPlayerInfo("Units are present in a range of 1 block, upper or lower, you can't recruit a monster nest on it");
			return false;
		}
		return $this->verifyPlayerEnoughCash($this->getCost());
	}

	public function create($locZone, $locPlayer) {
		global $gloObjectManager;
		$locBlock = $gloObjectManager->getBlock($locZone->blockId);
		$locManageAction = ManageAction::getInstance();
		$locResult = MonsterNest::create($locZone, $locPlayer->playerId, false);
		$locManageAction->addPlayerInfo("monster nest built");
		$locResultPlayerId = $locBlock->getPlayersIdAround(4, 4, 4);
		foreach($locResultPlayerId as $locPlayerId) {
			PlayerMessage::getInstance()->addPlayerInfo($locPlayerId,
			"a monster nest has been created",
			PlayerMessage::$VERY_BAD, $locZone->zoneId);
		}
		return $locResult;
	}
}
?>
Return current item: PhpBlock