示例#1
0
function getCaveMapContent($caves, $caveID)
{
    global $params, $config, $terrainList;
    $caveData = $caves[$caveID];
    $message = '';
    // template öffnen
    $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'map.ihtml');
    // Grundparameter setzen
    tmpl_set($template, 'modus', MAP);
    // default Werte: Koordinaten dieser Höhle
    $xCoord = $caveData['xCoord'];
    $yCoord = $caveData['yCoord'];
    // Größe der Karte wird benötigt
    $mapSize = getMapSize();
    // wenn in die Minimap geklickt wurde, zoome hinein
    if (isset($params->POST->minimap_x) && isset($params->POST->minimap_y) && $params->POST->scaling != 0) {
        $xCoord = Floor($params->POST->minimap_x * 100 / $params->POST->scaling) + $mapSize['minX'];
        $yCoord = Floor($params->POST->minimap_y * 100 / $params->POST->scaling) + $mapSize['minY'];
    } else {
        if (isset($params->POST->caveName)) {
            $coords = getCaveByName($params->POST->caveName);
            if (sizeof($coords) == 0) {
                $message = sprintf(_('Die Höhle mit dem Namen: "%s" konnte nicht gefunden werden!'), $params->POST->caveName);
            } else {
                $xCoord = $coords['xCoord'];
                $yCoord = $coords['yCoord'];
                $message = sprintf(_('Die Höhle mit dem Namen: "%s" befindet sich in (%d|%d).'), $params->POST->caveName, $xCoord, $yCoord);
            }
        } else {
            if (isset($params->POST->targetCaveID)) {
                $coords = getCaveByID($params->POST->targetCaveID);
                if ($coords === null) {
                    $message = sprintf(_('Die Höhle mit der ID: "%d" konnte nicht gefunden werden!'), $params->POST->targetCaveID);
                } else {
                    $xCoord = $coords['xCoord'];
                    $yCoord = $coords['yCoord'];
                    $message = sprintf(_('Die Höhle mit der ID: "%d" befindet sich in (%d|%d).'), $params->POST->targetCaveID, $xCoord, $yCoord);
                }
            } else {
                if (isset($params->POST->xCoord) && isset($params->POST->yCoord)) {
                    $xCoord = $params->POST->xCoord;
                    $yCoord = $params->POST->yCoord;
                }
            }
        }
    }
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $message);
    }
    // Koordinaten begrenzen
    if ($xCoord < $mapSize['minX']) {
        $xCoord = $mapSize['minX'];
    }
    if ($yCoord < $mapSize['minY']) {
        $yCoord = $mapSize['minY'];
    }
    if ($xCoord > $mapSize['maxX']) {
        $xCoord = $mapSize['maxX'];
    }
    if ($yCoord > $mapSize['maxY']) {
        $yCoord = $mapSize['maxY'];
    }
    // width und height anpassen
    $MAP_WIDTH = min(MAP_WIDTH, $mapSize['maxX'] - $mapSize['minX'] + 1);
    $MAP_HEIGHT = min(MAP_HEIGHT, $mapSize['maxY'] - $mapSize['minY'] + 1);
    // Nun befinden sich in $xCoord und $yCoord die gesuchten Koordinaten.
    // ermittele nun die linke obere Ecke des Bildausschnittes
    $minX = min(max($xCoord - intval($MAP_WIDTH / 2), $mapSize['minX']), $mapSize['maxX'] - $MAP_WIDTH + 1);
    $minY = min(max($yCoord - intval($MAP_HEIGHT / 2), $mapSize['minY']), $mapSize['maxY'] - $MAP_HEIGHT + 1);
    // ermittele nun die rechte untere Ecke des Bildausschnittes
    $maxX = $minX + $MAP_WIDTH - 1;
    $maxY = $minY + $MAP_HEIGHT - 1;
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $map = array();
    foreach ($caveDetails as $cave) {
        $cell = array('terrain' => 'terrain' . $cave['terrain'], 'alt' => "{$cave['cavename']} - ({$cave['xCoord']}|{$cave['yCoord']}) - {$cave['region']}", 'link' => "modus=map_detail&amp;targetCaveID={$cave['caveID']}");
        // unbewohnte Höhle
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen
            if ($cave['takeoverable'] == 1) {
                $text = _('Frei!');
                $file = "icon_cave_empty";
                // als Einöde zeigen
            } else {
                $text = _('Einöde');
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $params->SESSION->player->playerID) {
                $file = "icon_cave_own";
            } else {
                $file = "icon_cave_other";
            }
            // mit Artefakt
            if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->player->tribe == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // link zum Tribe einfügen
            $cell['link_tribe'] = "modus=tribe_detail&amp;tribe=" . urlencode(unhtmlentities($cave['tribe']));
            // Stamm abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['text_tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['text_tribe'] = $cave['tribe'];
            }
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
        if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->player->tribe == GOD_ALLY)) {
            $cell['artefacts'] = $cave['artefacts'];
            $cell['artefacts_text'] = sprintf(_('Artefakte: %d'), $cave['artefacts']);
        }
        $map[$cave['xCoord']][$cave['yCoord']] = $cell;
    }
    // Karte mit Beschriftungen ausgeben
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        tmpl_iterate($template, '/ROWS');
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            tmpl_iterate($template, '/ROWS/CELLS');
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                tmpl_set($template, "/ROWS/CELLS", getCornerCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    tmpl_set($template, "/ROWS/CELLS", getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        tmpl_set($template, "/ROWS/CELLS", getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        tmpl_set($template, "/ROWS/CELLS", getMapCell($map, $i, $j));
                    }
                }
            }
        }
    }
    // Minimap
    $width = $mapSize['maxX'] - $mapSize['minX'] + 1;
    $height = $mapSize['maxY'] - $mapSize['minY'] + 1;
    // compute mapcenter coords
    $mcX = $minX + intval($MAP_WIDTH / 2);
    $mcY = $minY + intval($MAP_HEIGHT / 2);
    tmpl_set($template, "/MINIMAP", array('file' => "images/minimap.png.php?x=" . $xCoord . "&amp;y=" . $yCoord, 'modus' => MAP, 'width' => intval($width * MINIMAP_SCALING / 100), 'height' => intval($height * MINIMAP_SCALING / 100), 'scaling' => MINIMAP_SCALING));
    tmpl_set($template, '/O', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/SO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/S', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/SW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/W', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/NW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/N', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/NO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    // Module "CaveBookmarks" Integration
    // FIXME should know whether the module is installed
    if (TRUE) {
        // show CAVEBOOKMARKS context
        tmpl_set($template, '/CAVEBOOKMARKS/iterate', '');
        // get model
        $cb_model = new CaveBookmarks_Model();
        // get bookmarks
        $bookmarks = $cb_model->getCaveBookmarks(true);
        // set bookmarks
        if (sizeof($bookmarks)) {
            tmpl_set($template, '/CAVEBOOKMARKS/CAVEBOOKMARK', $bookmarks);
        }
    }
    return tmpl_parse($template);
}
示例#2
0
function getCaveMapContent($caves, $caveID, $playerID)
{
    global $params, $config, $terrainList;
    $caveData = $caves[$caveID];
    $message = '';
    // template öffnen
    $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/map.ihtml');
    // Grundparameter setzen
    tmpl_set($template, 'modus', MAP);
    tmpl_set($template, 'cave_book_link', CAVE_BOOK);
    // ADDED by chris--- for cavebook
    // default Werte: Koordinaten dieser Höhle
    $xCoord = $caveData['xCoord'];
    $yCoord = $caveData['yCoord'];
    // Größe der Karte wird benötigt
    $mapSize = getMapSize();
    // wenn in die Minimap geklickt wurde, zoome hinein
    if (!empty($params->POST->minimap_x) && !empty($params->POST->minimap_y) && $params->POST->scaling != 0) {
        $xCoord = Floor($params->POST->minimap_x * 100 / $params->POST->scaling) + $mapSize['minX'];
        $yCoord = Floor($params->POST->minimap_y * 100 / $params->POST->scaling) + $mapSize['minY'];
    } else {
        if (!empty($params->POST->caveName)) {
            $coords = getCaveByName($params->POST->caveName);
            if (sizeof($coords) == 0) {
                $message = 'Die Siedlung mit dem Namen: "' . $params->POST->caveName . '" konnte nicht gefunden werden!';
            } else {
                $xCoord = $coords['xCoord'];
                $yCoord = $coords['yCoord'];
                $message = 'Die Siedlung mit dem Namen: "' . $params->POST->caveName . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
            }
        } else {
            if (!empty($params->POST->targetCaveID)) {
                $coords = getCaveByID($params->POST->targetCaveID);
                if ($coords === null) {
                    $message = 'Die Siedlung mit der ID: "' . $params->POST->targetCaveID . '" konnte nicht gefunden werden!';
                } else {
                    $xCoord = $coords['xCoord'];
                    $yCoord = $coords['yCoord'];
                    $message = 'Die Siedlung mit der ID: "' . $params->POST->targetCaveID . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
                }
            } else {
                if (!empty($params->POST->xCoord) && !empty($params->POST->yCoord)) {
                    $xCoord = $params->POST->xCoord;
                    $yCoord = $params->POST->yCoord;
                }
            }
        }
    }
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $message);
    }
    // Koordinaten begrenzen
    if ($xCoord < $mapSize['minX']) {
        $xCoord = $mapSize['minX'];
    }
    if ($yCoord < $mapSize['minY']) {
        $yCoord = $mapSize['minY'];
    }
    if ($xCoord > $mapSize['maxX']) {
        $xCoord = $mapSize['maxX'];
    }
    if ($yCoord > $mapSize['maxY']) {
        $yCoord = $mapSize['maxY'];
    }
    // width und height anpassen
    $MAP_WIDTH = min(MAP_WIDTH, $mapSize['maxX'] - $mapSize['minX'] + 1);
    $MAP_HEIGHT = min(MAP_HEIGHT, $mapSize['maxY'] - $mapSize['minY'] + 1);
    // Nun befinden sich in $xCoord und $yCoord die gesuchten Koordinaten.
    // ermittele nun die linke obere Ecke des Bildausschnittes
    $minX = min(max($xCoord - intval($MAP_WIDTH / 2), $mapSize['minX']), $mapSize['maxX'] - $MAP_WIDTH + 1);
    $minY = min(max($yCoord - intval($MAP_HEIGHT / 2), $mapSize['minY']), $mapSize['maxY'] - $MAP_HEIGHT + 1);
    // ermittele nun die rechte untere Ecke des Bildausschnittes
    $maxX = $minX + $MAP_WIDTH - 1;
    $maxY = $minY + $MAP_HEIGHT - 1;
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $map = array();
    foreach ($caveDetails as $cave) {
        // ADDED by chris--- for Quests --------------------------------------------------------------------------------
        global $db;
        if ($cave['quest_cave'] && !isCaveInvisibleToPlayer($cave['caveID'], $playerID, $db) && $cave['invisible_name'] != "") {
            $cave['cavename'] = $cave['invisible_name'];
        }
        // -------------------------------------------------------------------------------------------------------
        $cell = array('terrain' => strtolower($terrainList[$cave['terrain']]['name']), 'alt' => "{$cave['cavename']} - ({$cave['xCoord']}|{$cave['yCoord']})", 'link' => "modus=" . MAP_DETAIL . "&targetCaveID={$cave['caveID']}");
        // unbewohnte Höhle
        // ADDED by chris--- for Quests
        // ----------------------------------------------------------
        // checking if this cave is a quest cave and if its visible to the player (than he knows the quest)
        // if he does not know the quest the cave is invisible
        if ($cave['quest_cave'] && isCaveInvisibleToPlayer($cave['caveID'], $playerID, $db)) {
            $cave['playerID'] = 0;
        }
        // ----------------------------------------------------------
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen, wenn man missionieren kann
            if (sizeof($caves) < $params->SESSION->user['takeover_max_caves'] && $cave['takeoverable'] == 1) {
                $text = "Frei!";
                $file = "icon_cave_empty";
                // als Einöde zeigen, wenn man nicht mehr missionieren kann
            } else {
                $text = "Ein&ouml;de";
                $file = "icon_waste";
            }
            // oder Dunkelheit zeigen?
            if ($cave['terrain'] == 4 && $text != "Frei!") {
                $text = "verdorrtes Land";
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $params->SESSION->user['playerID']) {
                $file = "icon_cave_own";
            } else {
                $file = "icon_cave_other";
                if ($cave['quest_cave']) {
                    $file = "icon_cave_quest";
                }
            }
            // mit Artefakt
            if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // link zum Tribe einfügen
            $cell['link_tribe'] = "modus=" . TRIBE_DETAIL . "&tribe=" . urlencode(unhtmlentities($cave['tribe']));
            // Clan abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['text_tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['text_tribe'] = $cave['tribe'];
            }
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
        if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
            $cell['artefacts'] = $cave['artefacts'];
            $cell['artefacts_text'] = "Artefakte: {$cave['artefacts']}";
        }
        $map[$cave['xCoord']][$cave['yCoord']] = $cell;
    }
    // Karte mit Beschriftungen ausgeben
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        tmpl_iterate($template, '/ROWS');
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            tmpl_iterate($template, '/ROWS/CELLS');
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                tmpl_set($template, "/ROWS/CELLS", getEmptyCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    tmpl_set($template, "/ROWS/CELLS", getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        tmpl_set($template, "/ROWS/CELLS", getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        tmpl_set($template, "/ROWS/CELLS", getMapCell($map, $i, $j));
                    }
                }
            }
        }
    }
    // ADDED by chris--- for cavebook:
    // Getting entries
    $cavelist = cavebook_getEntries($params->SESSION->user['playerID']);
    // Show the cave table
    for ($i = 0; $i < sizeof($cavelist[id]); $i++) {
        $cavename = $cavelist[name][$i];
        // the current cavename
        $cavebookID = $cavelist[id][$i];
        $cave_x = $cavelist[x][$i];
        $cave_y = $cavelist[y][$i];
        tmpl_iterate($template, '/BOOKENTRY');
        tmpl_set($template, 'BOOKENTRY/book_entry', $cavename);
        tmpl_set($template, 'BOOKENTRY/book_id', $cavebookID);
        tmpl_set($template, 'BOOKENTRY/book_x', $cave_x);
        tmpl_set($template, 'BOOKENTRY/book_y', $cave_y);
    }
    // Minimap
    $width = $mapSize['maxX'] - $mapSize['minX'] + 1;
    $height = $mapSize['maxY'] - $mapSize['minY'] + 1;
    // compute mapcenter coords
    $mcX = $minX + intval($MAP_WIDTH / 2);
    $mcY = $minY + intval($MAP_HEIGHT / 2);
    tmpl_set($template, "/MINIMAP", array('file' => "images/minimap.png.php?x=" . $xCoord . "&y=" . $yCoord, 'modus' => MAP, 'width' => intval($width * MINIMAP_SCALING / 100), 'height' => intval($height * MINIMAP_SCALING / 100), 'scaling' => MINIMAP_SCALING));
    tmpl_set($template, '/O', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/SO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/S', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/SW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/W', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/NW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/N', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/NO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    return tmpl_parse($template);
}
示例#3
0
文件: map.php 项目: agatho/uaenhanced
function getCaveMapContent()
{
    global $params, $config, $terrainList;
    // template öffnen
    $template = tmpl_open('./templates/map.ihtml');
    // Grundparameter setzen
    tmpl_set($template, 'modus', MAP);
    // Koordinaten eingegeben ?
    if (isset($params->xCoord) && isset($params->yCoord)) {
        $xCoord = $params->xCoord;
        $yCoord = $params->yCoord;
    } else {
        $xCoord = 1;
        $yCoord = 1;
    }
    // Größe der Karte wird benötigt
    $mapSize = getMapSize();
    // wenn in die Minimap geklickt wurde, zoome hinein
    if (!empty($params->POST->minimap_x) && !empty($params->POST->minimap_y) && $params->POST->scaling != 0) {
        $xCoord = Floor($params->POST->minimap_x * 100 / $params->POST->scaling) + $mapSize['minX'];
        $yCoord = Floor($params->POST->minimap_y * 100 / $params->POST->scaling) + $mapSize['minY'];
    } else {
        if (!empty($params->POST->caveName)) {
            $coords = getCaveByName($params->POST->caveName);
            if (sizeof($coords) == 0) {
                $message = 'Die H&ouml;hle mit dem Namen: "' . $params->POST->caveName . '" konnte nicht gefunden werden!';
            } else {
                $xCoord = $coords['xCoord'];
                $yCoord = $coords['yCoord'];
                $message = 'Die H&ouml;hle mit dem Namen: "' . $params->POST->caveName . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
            }
        } else {
            if (!empty($params->POST->targetCaveID)) {
                $coords = getCaveByID($params->POST->targetCaveID);
                if ($coords === null) {
                    $message = 'Die H&ouml;hle mit der ID: "' . $params->POST->targetCaveID . '" konnte nicht gefunden werden!';
                } else {
                    $xCoord = $coords['xCoord'];
                    $yCoord = $coords['yCoord'];
                    $message = 'Die H&ouml;hle mit der ID: "' . $params->POST->targetCaveID . '" befindet sich in (' . $xCoord . ' | ' . $yCoord . ').';
                }
            } else {
                if (!empty($params->POST->xCoord) && !empty($params->POST->yCoord)) {
                    $xCoord = $params->POST->xCoord;
                    $yCoord = $params->POST->yCoord;
                }
            }
        }
    }
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $message);
    }
    // Koordinaten begrenzen
    if ($xCoord < $mapSize['minX']) {
        $xCoord = $mapSize['minX'];
    }
    if ($yCoord < $mapSize['minY']) {
        $yCoord = $mapSize['minY'];
    }
    if ($xCoord > $mapSize['maxX']) {
        $xCoord = $mapSize['maxX'];
    }
    if ($yCoord > $mapSize['maxY']) {
        $yCoord = $mapSize['maxY'];
    }
    // width und height anpassen
    $mapwidth = isset($params->width) ? intval($params->width) : MAPWIDTH;
    $mapheight = isset($params->height) ? intval($params->height) : MAPHEIGHT;
    $MAP_WIDTH = min($mapwidth, $mapSize['maxX'] - $mapSize['minX'] + 1);
    $MAP_HEIGHT = min($mapheight, $mapSize['maxY'] - $mapSize['minY'] + 1);
    // Nun befinden sich in $xCoord und $yCoord die gesuchten Koordinaten.
    // ermittele nun die linke obere Ecke des Bildausschnittes
    $minX = min(max($xCoord - intval($MAP_WIDTH / 2), $mapSize['minX']), $mapSize['maxX'] - $MAP_WIDTH + 1);
    $minY = min(max($yCoord - intval($MAP_HEIGHT / 2), $mapSize['minY']), $mapSize['maxY'] - $MAP_HEIGHT + 1);
    // ermittele nun die rechte untere Ecke des Bildausschnittes
    $maxX = $minX + $MAP_WIDTH - 1;
    $maxY = $minY + $MAP_HEIGHT - 1;
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $map = array();
    foreach ($caveDetails as $cave) {
        $cell = array('terrain' => strtolower($terrainList[$cave['terrain']]['name']), 'alt' => "{$cave['cavename']} - ({$cave['xCoord']}|{$cave['yCoord']})", 'link' => "modus=" . MAP_DETAIL . "&targetCaveID={$cave['caveID']}");
        // unbewohnte Höhle
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen, wenn man missionieren kann
            if (sizeof($caves) < $params->SESSION->user['takeover_max_caves'] && $cave['takeoverable'] == 1) {
                $text = "Frei!";
                $file = "icon_cave_empty";
                // als Einöde zeigen, wenn man nicht mehr missionieren kann
            } else {
                $text = "Ein&ouml;de";
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $params->SESSION->user['playerID']) {
                $file = "icon_cave_own";
            } else {
                $file = "icon_cave_other";
            }
            // mit Artefakt
            if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // link zum Tribe einfügen
            $cell['link_tribe'] = "modus=" . TRIBE_DETAIL . "&tribe=" . urlencode(unhtmlentities($cave['tribe']));
            // Stamm abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['text_tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['text_tribe'] = $cave['tribe'];
            }
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
        if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) {
            $cell['artefacts'] = $cave['artefacts'];
            $cell['artefacts_text'] = "Artefakte: {$cave['artefacts']}";
        }
        $map[$cave['xCoord']][$cave['yCoord']] = $cave;
    }
    // Karte mit Beschriftungen ausgeben
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        tmpl_iterate($template, '/ROWS');
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            tmpl_iterate($template, '/ROWS/CELLS');
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                tmpl_set($template, "/ROWS/CELLS", getEmptyCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    tmpl_set($template, "/ROWS/CELLS", getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        tmpl_set($template, "/ROWS/CELLS", getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        tmpl_set($template, "/ROWS/CELLS", getMapCell($map, $i, $j));
                    }
                }
            }
        }
    }
    $width = $mapSize['maxX'] - $mapSize['minX'] + 1;
    $height = $mapSize['maxY'] - $mapSize['minY'] + 1;
    // compute mapcenter coords
    $mcX = $minX + intval($MAP_WIDTH / 2);
    $mcY = $minY + intval($MAP_HEIGHT / 2);
    tmpl_set($template, "/MINIMAP", array('file' => "images/minimap.png.php?x=" . $xCoord . "&y=" . $yCoord, 'modus' => MAP, 'width' => intval($width * MINIMAP_SCALING / 100), 'height' => intval($height * MINIMAP_SCALING / 100), 'scaling' => MINIMAP_SCALING));
    tmpl_set($template, '/O', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/SO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/S', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/SW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY + $MAP_HEIGHT));
    tmpl_set($template, '/W', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY));
    tmpl_set($template, '/NW', array('modus' => MAP, 'x' => $mcX - $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/N', array('modus' => MAP, 'x' => $mcX, 'y' => $mcY - $MAP_HEIGHT));
    tmpl_set($template, '/NO', array('modus' => MAP, 'x' => $mcX + $MAP_WIDTH, 'y' => $mcY - $MAP_HEIGHT));
    return tmpl_parse($template);
}
示例#4
0
/** calculates the displayed data for a specific map region. */
function calcCaveMapRegionData($caveID, $caves, $xCoord, $yCoord)
{
    $caveData = $caves[$caveID];
    $mapSize = getMapSize();
    // Größe der Karte wird benötigt
    $message = '';
    // calculate the dimensions of the visible map region
    $section = calcVisibleMapRegion($mapSize, $xCoord, $yCoord);
    $minX = $section['minX'];
    // minimum x-coordinate of caves in visible part of the map
    $minY = $section['minY'];
    // minimum y-coordinate of caves in visible part of the map
    $maxX = $section['maxX'];
    // maximum x-coordinate of caves in visible part of the map
    $maxY = $section['maxY'];
    // maximum y-coordinate of caves in visible part of the map
    $centerX = $section['centerX'];
    $centerY = $section['centerY'];
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $relations = TribeRelation::getRelations($_SESSION['player']->tribeID);
    $map = array();
    foreach ($caveDetails as $cave) {
        $cell = array('caveID' => $cave['caveID'], 'terrain' => 'terrain' . $cave['terrain'], 'terrain_tribe' => $GLOBALS['terrainList'][$cave['terrain']]['tribeRegion'], 'imgMap' => $GLOBALS['terrainList'][$cave['terrain']]['imgMap'], 'barren' => $GLOBALS['terrainList'][$cave['terrain']]['barren'], 'title' => 'Dies ist der Landstrich "' . $cave['cavename'] . '" (' . $cave['xCoord'] . '|' . $cave['yCoord'] . ') - ' . $GLOBALS['terrainList'][$cave['terrain']]['name']);
        // unbewohnte Höhle
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen
            if ($cave['takeoverable'] == 1) {
                $text = _('Frei!');
                $file = "icon_cave_empty";
                // als Einöde zeigen
            } else {
                $text = _('Einöde');
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $_SESSION['player']->playerID) {
                $file = "icon_cave_own";
            } else {
                $file = "icon_cave_other";
                // fremde Höhle
            }
            // mit Artefakt
            if ($cave['hasArtefact'] && ($cave['tribe'] != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // Stamm abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['tribe'] = $cave['tribe'];
            }
            $cell['tribeID'] = $cave['tribeID'];
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
            if ($_SESSION['player']->playerID == $cave['playerID']) {
                $cell['css_self'] = 't_self';
            }
            if (isset($relations['own'][$cave['tribeID']])) {
                $cell['css_own'] = 't_own_relation_' . $relations['own'][$cave['tribeID']]['relationType'];
            }
            if (isset($relations['other'][$cave['tribeID']])) {
                $cell['css_other'] = 't_other_relation_' . $relations['other'][$cave['tribeID']]['relationType'];
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        $map[$cave['xCoord']][$cave['yCoord']] = $cell;
    }
    // create a region data array with an empty row as starting point.
    $regionData = array('rows' => array());
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        $cells = array();
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                array_push($cells, getCornerCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    array_push($cells, getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        array_push($cells, getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        array_push($cells, getMapCell($map, $i, $j));
                    }
                }
            }
        }
        array_push($regionData['rows'], $cells);
    }
    $mapData = array('centerXCoord' => $centerX, 'centerYCoord' => $centerY, 'queryXCoord' => $xCoord, 'queryYCoord' => $yCoord, 'mapregion' => $regionData);
    return $mapData;
}
示例#5
0
文件: map.html.php 项目: norter/Game
/** calculates the displayed data for a specific map region. */
function calcCaveMapRegionData($caveID, $caves, $xCoord, $yCoord)
{
    $caveData = $caves[$caveID];
    $mapSize = getMapSize();
    // Größe der Karte wird benötigt
    $message = '';
    // calculate the dimensions of the visible map region
    $section = calcVisibleMapRegion($mapSize, $xCoord, $yCoord);
    $minX = $section['minX'];
    // minimum x-coordinate of caves in visible part of the map
    $minY = $section['minY'];
    // minimum y-coordinate of caves in visible part of the map
    $maxX = $section['maxX'];
    // maximum x-coordinate of caves in visible part of the map
    $maxY = $section['maxY'];
    // maximum y-coordinate of caves in visible part of the map
    $centerX = $section['centerX'];
    $centerY = $section['centerY'];
    // get the map details
    $caveDetails = getCaveDetailsByCoords($minX, $minY, $maxX, $maxY);
    $map = array();
    foreach ($caveDetails as $cave) {
        $cell = array('terrain' => 'terrain' . $cave['terrain'], 'imgMap' => $GLOBALS['terrainList'][$cave['terrain']]['imgMap'], 'barren' => $GLOBALS['terrainList'][$cave['terrain']]['barren'], 'alt' => "{$cave['cavename']} - ({$cave['xCoord']}|{$cave['yCoord']}) - {$cave['region']}", 'link' => "modus=" . MAP_DETAIL . "&amp;targetCaveID={$cave['caveID']}");
        // unbewohnte Höhle
        if ($cave['playerID'] == 0) {
            // als Frei! zeigen
            if ($cave['takeoverable'] == 1) {
                $text = _('Frei!');
                $file = "icon_cave_empty";
                // als Einöde zeigen
            } else {
                $text = _('Ein&ouml;de');
                $file = "icon_waste";
            }
            // bewohnte Höhle
        } else {
            // eigene Höhle
            if ($cave['playerID'] == $_SESSION['player']->playerID) {
                $file = "icon_cave_own";
                // fremde Höhle
            } else {
                $file = "icon_cave_other";
            }
            // mit Artefakt
            if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
                $file .= "_artefact";
            }
            // link zum Tribe einfügen
            $cell['link_tribe'] = "modus=" . TRIBE_DETAIL . "&amp;tribe=" . urlencode(unhtmlentities($cave['tribe']));
            // Stamm abkürzen
            $decodedTribe = unhtmlentities($cave['tribe']);
            if (strlen($decodedTribe) > 10) {
                $cell['text_tribe'] = htmlentities(substr($decodedTribe, 0, 8)) . "..";
            } else {
                $cell['text_tribe'] = $cave['tribe'];
            }
            // Besitzer
            $decodedOwner = unhtmlentities($cave['name']);
            if (strlen($decodedOwner) > 10) {
                $text = htmlentities(substr($decodedOwner, 0, 8)) . "..";
            } else {
                $text = $cave['name'];
            }
            // übernehmbare Höhlen können gekennzeichnet werden
            if ($cave['secureCave'] != 1) {
                $cell['unsecure'] = array('dummy' => '');
            }
        }
        $cell['file'] = $file;
        $cell['text'] = $text;
        // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
        if ($cave['artefacts'] != 0 && ($cave['tribe'] != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
            $cell['artefacts'] = $cave['artefacts'];
            $cell['artefacts_text'] = sprintf(_('Artefakte: %d'), $cave['artefacts']);
        }
        $map[$cave['xCoord']][$cave['yCoord']] = $cell;
    }
    // create a region data array with an empty row as starting point.
    $regionData = array('rows' => array());
    // über alle Zeilen
    for ($j = $minY - 1; $j <= $maxY + 1; ++$j) {
        $cells = array();
        // über alle Spalten
        for ($i = $minX - 1; $i <= $maxX + 1; ++$i) {
            // leere Zellen
            if (($j == $minY - 1 || $j == $maxY + 1) && ($i == $minX - 1 || $i == $maxX + 1)) {
                array_push($cells, getCornerCell());
                // x-Beschriftung
            } else {
                if ($j == $minY - 1 || $j == $maxY + 1) {
                    array_push($cells, getLegendCell('x', $i));
                    // y-Beschriftung
                } else {
                    if ($i == $minX - 1 || $i == $maxX + 1) {
                        array_push($cells, getLegendCell('y', $j));
                        // Kartenzelle
                    } else {
                        array_push($cells, getMapCell($map, $i, $j));
                    }
                }
            }
        }
        array_push($regionData['rows'], $cells);
    }
    $mapData = array('centerXCoord' => $centerX, 'centerYCoord' => $centerY, 'queryXCoord' => $xCoord, 'queryYCoord' => $yCoord, 'mapregion' => $regionData);
    return $mapData;
}