Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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);
    $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;
}