Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/tick/pillage.class.php
<?php
include_once $PATH_TO_CODE."/script/tick/allincludefortick.php";
class PillageTick extends Tick {
    public function getName() {
        return "Pillage";
    }
    public function run() {
        //FIXME : do JOIN
        $res=executer("SELECT DISTINCT o.zoneId, b.playerId, o.playerId, z.population
                        FROM object o, block b, zone z, player p
                        WHERE
                            b.allianceId <> o.allianceId AND z.zoneId = o.zoneId AND o.blockId = b.blockId
                            AND p.playerId = o.playerId
                            AND z.blockId = b.blockId
                        AND z.population > 0");

        global $gloObjectManager;
        while($row=mysql_fetch_array($res)) {
            $locZoneId = $row[0];
            $locPlayerIdOfBlock = $row[1];
            $locPlayerIdOfObject = $row[2];
            $locPopulation = $row[3];
            $locPlayerOfObject = $gloObjectManager->getPlayer($locPlayerIdOfObject);
            $locZone = $gloObjectManager->getZone($locZoneId);
            $locPopulationToRemove = min($locPopulation, DungeonConstante::$PILLAGE_POPULATION_PER_TURN);

            $locZone->setPopulation($locPopulation - $locPopulationToRemove);
            if($locPlayerIdOfBlock <> 0) {
                $locPlayerOfBlock = $gloObjectManager->getPlayer($locPlayerIdOfBlock);
                PlayerMessage::getInstance()->addPlayerInfo($locPlayerOfBlock->playerId, 
                	"one of your block is under pillage", PlayerMessage::$BAD, $locZone->blockId);
                $locPlayerOfBlock->addCash2(DungeonConstante::$PILLAGE_EVIL_POINTS_EARNED);
                $locPlayerOfObject->addCash2(DungeonConstante::$PILLAGE_EVIL_POINTS_EARNED_PAR_LE_PILLARD);
            }
        }
    }
}
?>
Return current item: PhpBlock