<?php
include_once "../../../site.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/dungeonconstante.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/unit/dungeonrealobject.class.php";
include_once $PATH_TO_CODE."/modules/dungeon/dungeonconstante.class.php";
include_once $PATH_TO_CODE."/script/connect.php";
include_once $PATH_TO_CODE."/script/fonction.php";
function getX($locX) {
global $locSize;
return (($locX - Constante::$HALF_BLOCK_SIZE- Constante::getMinX())*$locSize)/Constante::$BLOCK_SIZE;
}
function getY($locY) {
global $locImageSize;
global $locSize;
return $locImageSize-(($locY + Constante::$HALF_BLOCK_SIZE + 1 - Constante::getMinY())*$locSize)/Constante::$BLOCK_SIZE;
}
function getXZone($locX) {
global $locZoneSize;
return ($locX - Constante::getMinX())*$locZoneSize;
}
function getYZone($locY) {
global $locImageSize;
global $locZoneSize;
return $locImageSize-(($locY + 1 - Constante::getMinY())*$locZoneSize);
}
$locAllianceColor = array();
$z = getGetPost("z", Constante::getMinZ()+4);
$locRedPlayerId= getGetPost("redPlayerId", -1);
$locGreenPlayerId= getGetPost("greenPlayerId", -1);
$locBluePlayerId= getGetPost("bluePlayerId", -1);
$locImageSize = getGetPost("imageSize", 800);
$locZoneSize = floor($locImageSize/Constante::getWorldWidthInZone());
$locSize = $locZoneSize*Constante::$BLOCK_SIZE;
$locImageSize = $locSize * Constante::getWorldWidth();
$locImgColor = imagecreatetruecolor($locImageSize, $locImageSize);
imagealphablending( $locImgColor, false);
imagesavealpha($locImgColor, true);
$res=executer("SELECT x, y, playerLeader.color
FROM block, alliance, player playerLeader
WHERE z=$z
AND alliance.allianceId=block.allianceId
AND playerLeader.playerId = alliance.leaderId
ORDER BY y ASC, x ASC");
while($row=mysql_fetch_array($res)) {
$locX = getX($row[0]);
$locY = getY($row[1]);
$locColor = $row[2];
$locImageColor1 = &getImageColorFromHex($locImgColor,
Constante::getColor(intval(substr($locColor, 0, 2))));
$locImageColor2 = &getImageColorFromHex($locImgColor,
Constante::getColor(intval(substr($locColor, 2, 2))));
$locImageColor3 = &getImageColorFromHex($locImgColor,
Constante::getColor(intval(substr($locColor, 4, 2))));
//echo Constante::getMinY()." ".$locCoord[0]." $locX+$locSize*1/3, $locY+$locSize,<br>";
imagefilledrectangle($locImgColor, $locX, $locY,
$locX+$locSize*1/3, $locY+$locSize,
$locImageColor1);
imagefilledrectangle($locImgColor, $locX+$locSize*1/3, $locY,
$locX+$locSize*2/3, $locY+$locSize,
$locImageColor2);
imagefilledrectangle($locImgColor, $locX+$locSize*2/3, $locY,
$locX+$locSize, $locY+$locSize,
$locImageColor3);
}
$locRedColor = imagecolorallocate($locImgColor, 255, 0, 0);
$locGreenColor = imagecolorallocate($locImgColor, 0, 255, 0);
$locBlueColor = imagecolorallocate($locImgColor, 0, 0, 255);
showUnit($locImgColor, $locRedColor, $locBlueColor, $locRedPlayerId);
showUnit($locImgColor, $locGreenColor, $locBlueColor, $locGreenPlayerId);
showUnit($locImgColor, $locBlueColor, $locRedColor, $locBluePlayerId);
showUnit($locImgColor, $locRedColor, $locBlueColor, $locRedPlayerId, true);
showUnit($locImgColor, $locGreenColor, $locBlueColor, $locGreenPlayerId, true);
showUnit($locImgColor, $locBlueColor, $locRedColor, $locBluePlayerId, true);
function showUnit($locImgColor, $parColor, $parColorBis, $parPlayerId, $parIgnoreAll=false) {
if($parIgnoreAll && $parPlayerId==-1) {
return;
}
global $z;
global $locZoneSize;
$res=executer("SELECT object.zoneId, player.color, object.isBattling
FROM object, player
WHERE player.allianceId=object.allianceId
".($parPlayerId!=-1?"AND player.allianceId=$parPlayerId":"")."
AND visibleState=".RealObject::$REAL_OBJECT_VISIBLE_STATE_VISIBLE_BY_ALL."
AND isLobotomize<>".RealObject::$UNIT_IS_DEAD);
while($row = mysql_fetch_array($res)) {
list($locX, $locY, $locZ) = Zone::getZoneCoord($row[0]);
$locIsBattling = ("1" == $row[2]);
if($locZ == $z) {
if($locIsBattling) {
imagefilledrectangle($locImgColor, getXZone($locX), getYZone($locY),
getXZone($locX)+$locZoneSize/2, getYZone($locY)+$locZoneSize,
$parColorBis);
imagefilledrectangle($locImgColor, getXZone($locX)+$locZoneSize/2, getYZone($locY),
getXZone($locX)+$locZoneSize, getYZone($locY)+$locZoneSize,
$parColor);
} else {
imagefilledrectangle($locImgColor, getXZone($locX), getYZone($locY),
getXZone($locX)+$locZoneSize, getYZone($locY)+$locZoneSize,
$parColor);
}
imagerectangle($locImgColor, getXZone($locX), getYZone($locY),
getXZone($locX)+$locZoneSize, getYZone($locY)+$locZoneSize,
$parColorBis);
}
}
}
//TODO factorize all this !!!
$locGoldColor1= imagecolorallocate($locImgColor, 255, 255, 0);
$locGoldColor2= imagecolorallocate($locImgColor, 130, 127, 0);
$res = executer("SELECT x, y FROM zone
WHERE zoneType IN (".DungeonConstante::$ZONE_TYPE_GOLD_EXPLOITED.", ".DungeonConstante::$ZONE_TYPE_GOLD.")
AND z=$z");
while($row = mysql_fetch_array($res)) {
$locX=$row[0];
$locY=$row[1];
imagefilledrectangle($locImgColor, getXZone($locX), getYZone($locY),
getXZone($locX)+$locZoneSize, getYZone($locY)+$locZoneSize,
$locGoldColor2);
imagerectangle($locImgColor, getXZone($locX), getYZone($locY),
getXZone($locX)+$locZoneSize, getYZone($locY)+$locZoneSize,
$locGoldColor1);
}
header("Content-Type: image/png");
header("Expires: ".date("r", time() + 3600));
ImagePng($locImgColor);
ImageDestroy($locImgColor);
?>