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

class BuildTrapAction extends DungeonAbstractRecruitAction {
	function __construct() {
		parent::__construct(DungeonConstante::$ACTION_BUILD_TRAP, DungeonConstante::$ACTION_BUY_TRAP_COST, false, false);
	}

	public function create($locZone, $locPlayer) {
		$locManageAction = ManageAction::getInstance();
		$locObjectId = Trap::create($locZone, $locPlayer->playerId);
		global $gloObjectManager;
		$locObject = $gloObjectManager->getRealObject($locObjectId);
		$locObject->setIAMode(RealObject::$IA_MODE_STATIC);
		$locManageAction->addPlayerInfo("trap installed");
	}

	public function isOkToRecruit($locBlock, $locZone, $locPlayer) {
		$locManageAction = ManageAction::getInstance();
		$locPlayer = $locManageAction->getPlayer();

		if($this->isOtherAllianceProximity($locBlock, $locZone, $locPlayer)) {
			$locManageAction->addPlayerInfo("Enemy are present, you can't recruit anything on this zone");
			return false;
		}
		if(count($locZone->getObjectsDisplayPriority(Constante::$DISPLAY_PRIORITY_LOW, $locPlayer->allianceId)) > 0) {
			$locManageAction->addPlayerInfo("Already a low display unit here");
			return false;
		}
		return parent::isOkToRecruit($locBlock, $locZone, $locPlayer);
	}

	protected function isOtherAllianceProximity($locBlock, $locZone, $locPlayer) {
		return ($locBlock->testIsInLostOfControlForAllianceId($locPlayer->allianceId)
		|| $locZone->isOtherAllianceObjectNear($locPlayer->allianceId, 2, 2, 2)
		|| $locZone->isOtherAllianceObjectNear($locPlayer->allianceId, 5, 5, 1)
		|| $locBlock->isOtherAllianceBlockNear($locPlayer->allianceId, 1, 1, 1)
		|| $locBlock->isOtherAllianceObjectNear($locPlayer->allianceId, 2, 2, 1)
		|| $locBlock->isOtherAllianceObjectNear($locPlayer->allianceId, 1, 1, 2));
	}
}
?>
Return current item: PhpBlock