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

abstract class AbstractBeginPlayer extends DungeonAbstractAction {
    function __construct($parActionType) {
        parent::__construct($parActionType);
    }

    public abstract function beginPlayer($locCenterZone);
    public abstract function isOk($locCenterZone);

    public function action($parZoneActionArray) {
        $locManageAction = ManageAction::getInstance();
        $locPlayer = $locManageAction->getPlayer();
        if($this->getZoneAndBlock($parZoneActionArray, $locZone, $locBlock)) {
            if(count($locBlock->getAllRealObjectId()) > 0) {
                ManageAction::getInstance()->addPlayerInfo("you can't get this block, it contains units");
            } else {
                global $gloObjectManager;
                $locZoneCenterId=$locBlock->blockId;
                $locCenterZone = $gloObjectManager->getZone($locZoneCenterId);
                if($locBlock->playerId == 0) {
                    if($locBlock->isOtherAllianceObjectNear($locPlayer->allianceId, 2, 2, 1)
                            || $locBlock->isOtherAllianceObjectNear($locPlayer->allianceId, 1, 1, 2)
                            || $locBlock->isOtherAllianceBlockNear($locPlayer->allianceId, 1, 1, 2)
                            || $locBlock->isOtherAllianceBlockNear($locPlayer->allianceId, 2, 2, 1)
                            ) {
                        $locManageAction->addPlayerInfo(" Enemy are near, you can't begin here");
                        return false;
                    } else {
                        list($locXCenter, $locYCenter, $locZ) = Block::getBlockCoord($locBlock->blockId);
                        if($locCenterZone && $this->isOk($locCenterZone)) {
                            $locListZoneIdToModify = Zone::getStaticZoneIdsFromXY($locZoneCenterId, 1, 0);
                            foreach($locListZoneIdToModify as $locZoneIdToModify) {
                                $locZoneToModify = $gloObjectManager->getZone($locZoneIdToModify);
                                $locZoneToModify->setZoneType(Constante::$ZONE_TYPE_PLAIN);
                            }

                            $locBlock->setPlayerId($locPlayer->playerId);
                            $locNearZoneCenterId=Zone::getZoneId($locXCenter+1, $locYCenter, $locZ);
                            $locNearCenterZone = $gloObjectManager->getZone($locNearZoneCenterId);
                            $locNearCenterZone->setZoneType(DungeonConstante::$ZONE_TYPE_BARRACK);
                            $locPlayer->setCash(16000);
                            $atLeastOneActionIsOk=true;
                            ManageAction::getInstance()->addPlayerInfo("REFRESH YOUR PAGE !!!");
                            ManageAction::getInstance()->addPlayerInfo("REFRESH YOUR PAGE !!!");
                            ManageAction::getInstance()->addPlayerInfo("REFRESH YOUR PAGE !!!");
                            $this->beginPlayer($locCenterZone);
                        }
                    }
                } else {
                    ManageAction::getInstance()->addPlayerInfo("WRONG playerId locBlock->playerId=$locBlock->playerId block already owned");
                }
            }
        }
    }
}
?>
Return current item: PhpBlock