<?php
include_once $PATH_TO_CODE."/modules/dungeon/action/spell/dungeonabstractspell.class.php";
class DisbandSpellAction extends DungeonAbstractSpellAction {
function __construct() {
parent::__construct(DungeonConstante::$ACTION_DISBAND_SPELL, DungeonConstante::$ACTION_BUY_DISBAND_SPELL_COST, true);
}
protected function doAction($parZoneActionArray, $locZone, $locBlock) {
$locManageAction = ManageAction::getInstance();
$locPlayer = $locManageAction->getPlayer();
global $gloObjectManager;
$res = $locBlock->getAllianceObjectNear($locPlayer->allianceId, 0, 0, 0);
while($row=mysql_fetch_array($res)) {
$locRealObject = $gloObjectManager->getRealObject($row[0]);
if($locRealObject->getHeroMode() == 0) {
if($locRealObject->isBattling) {
//In battle no retreat
} else if(!$locRealObject->isAlive()) {
//Dead can't be disbanded
} else if($locRealObject->getLife() < $locRealObject->getMaxLife()*0.5) {
//Hurted unit can't be disbanded
} else {
$locManageAction->addPlayerInfo("You disband a unit which returns to your land");
$locRealObject->increasePopulationDueToHumanKillAction();
}
}
}
return true;
}
}
?>