<?php
include_once $PATH_TO_CODE."/script/connect.php";
include_once $PATH_TO_CODE."/script/fonction.php";
include_once $PATH_TO_CODE."/script/update/abstractupdate.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/objectmanager.class.php";
class DungeonUpdate extends AbstractUpdate {
public function __construct($parArguments, $parPlayer) {
parent::__construct($parArguments, $parPlayer, "dungeon");
}
public function echoUpdate() {
echo "<dungeon>";
//Echo current money
echo $this->player->cash;
echo Constante::$SEP_URL_1;
echo $this->player->cash2;
echo "</dungeon>";
}
}
class RockUpdate extends AbstractUpdate {
public function __construct($parArguments, $parPlayer) {
parent::__construct($parArguments, $parPlayer, "dungeonrock");
$this->timestampRock = $this->getOptions("timestampRock", 0);
}
public function echoUpdate() {
if($this->getOptions("rockActivated")) {
echo "<dungeonRock>";
global $gloObjectManager;
if($this->timestampRock > 0 && ((time()-$this->timestampRock) > Constante::$SYNC_OUT_TIME))
{
$this->timestampRock = 0;
}
//Echo timestamp for client
echo time();
echo Constante::$SEP_URL_1;
//TODO as soon scrolling is activated send equally the center which is used for this update ! (scrolling change the center, and client will not have image name based on the source image but on his position in the screen. A translation will be done on client side.
$locWhereListForNewBlocks = False;
$locNewBlockIds = $this->newBlocksId;
if(count($locNewBlockIds) > 1) {
$locWhereListForNewBlocks = getWhereClauseList($locNewBlockIds);
}
$locNewBlockIds = getWhereClauseList($locNewBlockIds);
$locBlockIdsWhereClauseList = Block::getStaticBlockIdsWhereClauseList(Block::getBlockIdWithCenterCoord($this->blockX, $this->blockY, $this->blockZ), $this->blockHalfWidth, $this->blockHalfHeight);
//Block update
$locRequestToGetModifiedBlock =
"SELECT DISTINCT blockId
FROM blockInfo
WHERE
type1=".DungeonConstante::$BLOCK_INFO_TYPE1_ROCK_IMAGE."
AND type2=".DungeonConstante::$BLOCK_INFO_TYPE2_ROCK_IMAGE_TIMESTAMP."
AND
(
(
value >= ".($this->timestampRock - Constante::$BLOCK_TIMESTAMP_MARGE)."
AND blockId IN $locBlockIdsWhereClauseList
)";
if($locWhereListForNewBlocks) {
$locRequestToGetModifiedBlock .= " OR blockId IN $locWhereListForNewBlocks";
}
$locRequestToGetModifiedBlock.=")";
$locRes = executer($locRequestToGetModifiedBlock);
while($row=mysql_fetch_array($locRes))
{
$locBlockId = $row[0];
$locBlock = $gloObjectManager->getBlock($locBlockId);
$locImagePath=$locBlock->getImagePathIdentifier();
echo $locBlockId.Constante::$SEP_URL_3."".$locImagePath.Constante::$SEP_URL_2;
}
echo "</dungeonRock>";
}
}
}
?>