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

class BuildBarrack extends DungeonAbstractChangeZoneTypeAction {
    function __construct() {
        $locManageAction = ManageAction::getInstance();
        $locPlayer = $locManageAction->getPlayer();
        if($locPlayer->getBarrackCount() == 0) {
            $locBarrackCost = 0;
            $this->shameCost = DungeonConstante::$ACTION_BUY_BARRACK_COST/10.0;
        } else {
            $locBarrackCost = DungeonConstante::$ACTION_BUY_BARRACK_COST;
        }
        parent::__construct(DungeonConstante::$ACTION_BUILD_BARRACK, DungeonConstante::$ZONE_TYPE_BARRACK, $locBarrackCost);
    }

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

        if($locZone->isOccuped()) {
            $locManageAction->addPlayerInfo("Target zone is occupied");
        } else {
            if($locPlayer->playerType==DungeonConstante::$PLAYER_TYPE_HUMAN_KNIGHT) {
                if(!$locZone->isSurface()) {
                    $locManageAction->addPlayerInfo("Barrack of human knight must begin on ground");
                    return false;
                }
            } else {
            	$locMaxLevel = Site::$ZONE_COORD_Z_GROUND_LEVEL - 3;
                if($locZone->z > $locMaxLevel) {
                    $locManageAction->addPlayerInfo("Dungeon master barrack must begin under or at level ".Constante::normalizeZ($locMaxLevel));
                    return false;
                }
            }
            return parent::isOkToChange($locBlock, $locZone);
        }
        return false;
    }
}
?>
Return current item: PhpBlock