예제 #1
0
function getCaveReport($meineHoehlen, $caveID, $targetCaveID)
{
    global $params, $config, $terrainList;
    $cave = getCaveByID($targetCaveID);
    $caveDetails = array();
    $playerDetails = array();
    if ($cave['playerID'] != 0) {
        $caveDetails = getCaves($cave['playerID']);
        $playerDetails = getPlayerByID($cave['playerID']);
    }
    $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'mapdetail.ihtml');
    if ($cave['protected']) {
        tmpl_set($template, 'PROPERTY', _('Anfängerschutz aktiv'));
    }
    if (!$cave['secureCave'] && $cave['playerID']) {
        tmpl_iterate($template, 'PROPERTY');
        tmpl_set($template, 'PROPERTY', _('übernehmbar'));
    }
    $region = getRegionByID($cave['regionID']);
    tmpl_set($template, array('cavename' => $cave['name'], 'xcoord' => $cave['xCoord'], 'ycoord' => $cave['yCoord'], 'terrain' => $terrainList[$cave['terrain']]['name'], 'region' => $region['name'], 'movementlink' => sprintf("?modus=unit_movement&targetXCoord=%d&targetYCoord=%d&targetCaveName=%s", $cave['xCoord'], $cave['yCoord'], unhtmlentities($cave['name'])), 'backlink' => sprintf("?modus=map&xCoord=%d&yCoord=%d", $cave['xCoord'], $cave['yCoord'])));
    if ($cave['playerID'] != 0) {
        tmpl_set($template, '/OCCUPIED', array('playerLink' => "?modus=player_detail&detailID=" . $playerDetails['playerID'], 'caveOwner' => $playerDetails['name']));
        if ($playerDetails['tribe']) {
            tmpl_set($template, '/OCCUPIED/TRIBE', array('tribeLink' => "?modus=tribe_detail&tribe=" . urlencode(unhtmlentities($playerDetails['tribe'])), 'ownersTribe' => $playerDetails['tribe']));
        }
        if ($cave['artefacts'] != 0 && ($playerDetails['tribe'] != GOD_ALLY || $params->SESSION->player->tribe == GOD_ALLY)) {
            tmpl_set($template, '/OCCUPIED/ARTEFACT/artefactLink', "?modus=artefact_list&caveID={$caveID}");
        }
        $caves = array();
        foreach ($caveDetails as $key => $value) {
            $temp = array('caveName' => $value['name'], 'xCoord' => $value['xCoord'], 'ycoord' => $value['yCoord'], 'terrain' => $terrainList[$value['terrain']]['name'], 'caveSize' => floor($value[CAVE_SIZE_DB_FIELD] / 50) + 1, 'movementLink' => "?modus=unit_movement&targetXCoord=" . $value['xCoord'] . "&targetYCoord=" . $value['yCoord'] . "&targetCaveName=" . unhtmlentities($value['name']));
            if ($value['artefacts'] != 0 && ($playerDetails['tribe'] != GOD_ALLY || $params->SESSION->player->tribe == GOD_ALLY)) {
                $temp['ARTEFACT'] = array('artefactLink' => "?modus=artefact_list&caveID={$caveID}");
            }
            if ($value['protected'] && $value['playerID']) {
                $temp['PROPERTY'] = array('text' => _('Anfängerschutz aktiv'));
            } else {
                if (!$value['secureCave']) {
                    $temp['PROPERTY'] = array('text' => _('übernehmbar'));
                }
            }
            $caves[] = $temp;
        }
        tmpl_set($template, '/OCCUPIED/CAVES', $caves);
    } else {
        if (sizeof($meineHoehlen) < $params->SESSION->player->takeover_max_caves && $cave['takeoverable'] == 1) {
            tmpl_set($template, 'TAKEOVERABLE', array('modus' => TAKEOVER, 'caveID' => $caveID, 'targetXCoord' => $cave['xCoord'], 'targetYCoord' => $cave['yCoord']));
        }
    }
    return tmpl_parse($template);
}
예제 #2
0
function getCaveDetailsContent(&$details, $showGiveUp = TRUE)
{
    global $db, $template;
    // open template
    $template->setFile('caveDetail.tmpl');
    $statusMsg = '';
    $action = Request::getVar('action', '');
    switch ($action) {
        /****************************************************************************************************
        *
        * Höhle aufgeben!
        *
        ****************************************************************************************************/
        case 'caveGiveUp':
            if (Request::getVar('giveUpCaveID', 0) == $details['caveID'] && Request::isPost('postConfirm')) {
                if (cave_giveUpCave($details['caveID'], $_SESSION['player']->playerID, $_SESSION['player']->tribeID)) {
                    $template->throwError(_('Sie haben sich aus dieser Höhle zurückgezogen.'));
                    return;
                } else {
                    $statusMsg = array('type' => 'error', 'message' => _('Diese Höhle kann nicht aufgegeben werden.'));
                }
            } else {
                $statusMsg = array('type' => 'error', 'message' => _('Fehler beim aufgeben der Höhle.'));
            }
            break;
            /****************************************************************************************************
            *
            * Anfängerschutz deaktivieren
            *
            ****************************************************************************************************/
        /****************************************************************************************************
        *
        * Anfängerschutz deaktivieren
        *
        ****************************************************************************************************/
        case 'endProtection':
            if (Request::getVar('giveUpCaveID', 0) == $details['caveID'] && Request::isPost('postConfirm')) {
                if (beginner_endProtection($details['caveID'], $_SESSION['player']->playerID)) {
                    $statusMsg = array('type' => 'success', 'message' => _('Sie haben den Anfängerschutz abgeschaltet.'));
                    $details['protected'] = 0;
                } else {
                    $statusMsg = array('type' => 'error', 'message' => _('Sie konnten den Anfängerschutz nicht abschalten.'));
                }
            } else {
                $statusMsg = array('type' => 'error', 'message' => _('Fehler beim deaktivieren des Anfängerschutzes.'));
            }
            break;
    }
    if (!empty($statusMsg)) {
        $template->addVar('status_msg', $statusMsg);
    }
    // get region data
    $region = getRegionByID($details['regionID']);
    $details['region_name'] = $region['name'];
    // set properties
    $properties = array();
    if ($details['protected']) {
        $details['properties'][] = array('text' => _('Anfängerschutz aktiv'));
    }
    if (!$details['secureCave']) {
        $details['properties'][] = array('text' => _('Übernehmbar'));
    }
    if ($details['starting_position'] > 0) {
        $details['properties'][] = array('text' => _('Haupthöhle'));
    }
    // fill give-up form
    if ($showGiveUp) {
        $template->addVar('give_up', true);
    }
    // fill end beginner protection form
    if ($details['protected']) {
        $template->addVar('unprotected', true);
    }
    $template->addVar('cave_data', $details);
    // RESOURCES AUSFUELLEN
    $resources = array();
    foreach ($GLOBALS['resourceTypeList'] as $resource) {
        if (!$resource->nodocumentation || $details[$resource->dbFieldName] > 0) {
            $resources[] = array('dbFieldName' => $resource->dbFieldName, 'name' => $resource->name, 'value' => $details[$resource->dbFieldName]);
        }
    }
    if (sizeof($resources)) {
        $template->addVar('resource', $resources);
    }
    // UNITS AUSFUELLEN
    $units = array();
    foreach ($GLOBALS['unitTypeList'] as $unit) {
        $value = $details[$unit->dbFieldName];
        if ($value != 0) {
            $units[] = array('dbFieldName' => $unit->dbFieldName, 'name' => $unit->name, 'value' => $value);
        }
    }
    if (sizeof($units)) {
        $template->addVar('units', $units);
    }
    // BUILDINGS AUSFUELLEN
    $buildings = array();
    foreach ($GLOBALS['buildingTypeList'] as $building) {
        $value = $details[$building->dbFieldName];
        if ($value != 0) {
            $buildings[] = array('dbFieldName' => $building->dbFieldName, 'name' => $building->name, 'value' => $value);
        }
    }
    if (sizeof($buildings)) {
        $template->addVar('buildings', $buildings);
    }
    // VERTEIDIGUNG AUSFUELLEN
    $defenses = array();
    foreach ($GLOBALS['defenseSystemTypeList'] as $defense) {
        $value = $details[$defense->dbFieldName];
        if ($value != 0) {
            $defenses[] = array('dbFieldName' => $defense->dbFieldName, 'name' => $defense->name, 'value' => $value);
        }
    }
    if (sizeof($defenses)) {
        $template->addVar('defenses', $defenses);
    }
}
예제 #3
0
function getCaveReport($caveID, $ownCaves, $targetCaveID, $method)
{
    global $template;
    if (!$targetCaveID) {
        $template->throwError('Es wurde keine Höhle ausgewählt.');
        return;
    }
    if ($method == 'ajax') {
        $shortVersion = true;
        $template->setFile('mapDetailAjax.tmpl');
    } else {
        $shortVersion = false;
        $template->setFile('mapDetail.tmpl');
    }
    $cave = getCaveByID($targetCaveID);
    $caveDetails = array();
    $playerDetails = null;
    $showArtePossible = false;
    if ($cave['playerID'] != 0) {
        $caveDetails = getCaves($cave['playerID']);
        $playerDetails = Player::getPlayer($cave['playerID']);
        $showArtePossible = $playerDetails->tribe != GOD_ALLY ? true : false;
    }
    $cave['terrain_name'] = $GLOBALS['terrainList'][$cave['terrain']]['name'];
    $cave['terrain_img'] = $GLOBALS['terrainList'][$cave['terrain']]['img'];
    if ($GLOBALS['terrainList'][$cave['terrain']]['tribeRegion']) {
        $cave['terrain_description'] = $GLOBALS['terrainList'][$cave['terrain']]['description'];
        $cave['terrain_tribe_cave'] = $GLOBALS['terrainList'][$cave['terrain']]['tribeRegion'];
        $attackerTribe = Tribe::getByID($cave['lastAttackingTribeID']);
        $cave['tribe_cave_tag'] = $attackerTribe['tag'];
    }
    $region = getRegionByID($cave['regionID']);
    // Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
    if ($cave['hasArtefact'] && ($showArtePossible || $_SESSION['player']->tribe == GOD_ALLY)) {
        $cave['hasArtefact'] = true;
    } else {
        $cave['hasArtefact'] = false;
    }
    if ($cave['hasPet'] && ($showArtePossible || $_SESSION['player']->tribe == GOD_ALLY)) {
        $cave['hasPet'] = true;
    } else {
        $cave['hasArtefact'] = false;
    }
    $template->addVar('cave_details', $cave);
    if ($cave['playerID'] != 0) {
        $template->addVar('player_details', $playerDetails);
        /****************************************************************************************************
        *
        * Alle Höhlen des Spielers ausgeben
        *
        ****************************************************************************************************/
        $caves = array();
        foreach ($caveDetails as $key => $value) {
            $temp = array('caveName' => $value['name'], 'xCoord' => $value['xCoord'], 'yCoord' => $value['yCoord'], 'terrain' => $GLOBALS['terrainList'][$value['terrain']]['name'], 'caveSize' => floor($value[CAVE_SIZE_DB_FIELD] / 50) + 1, 'secureCave' => $value['secureCave']);
            if ($value['hasArtefact'] && ($playerDetails->tribe != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
                $temp['artefact'] = true;
            }
            if ($value['hasPet'] && ($playerDetails->tribe != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
                $temp['pet'] = true;
            }
            $caves[] = $temp;
        }
        $template->addVar('player_caves', $caves);
    } else {
        if (sizeof($ownCaves) < $_SESSION['player']->takeover_max_caves) {
            if ($cave['starting_position'] == 0 && $cave['takeoverable'] == 0 && $cave['takeover_level'] > 0) {
                $template->addVar('maybe_takeoverable', true);
            } else {
                if ($cave['takeoverable'] == 1) {
                    $template->addVar('takeoverable', true);
                }
            }
        }
    }
}
예제 #4
0
파일: map.html.php 프로젝트: norter/Game
function getCaveReport($caveID, $ownCaves, $targetCaveID, $method)
{
    global $template;
    if (!$targetCaveID) {
        $template->throwError('Es wurde keine Höhle ausgewählt.');
        return;
    }
    if ($method == 'ajax') {
        $shortVersion = true;
        $template->setFile('mapDetailAjax.tmpl');
    } else {
        $shortVersion = false;
        $template->setFile('mapDetail.tmpl');
    }
    $cave = getCaveByID($targetCaveID);
    $caveDetails = array();
    $playerDetails = array();
    $showArtePossible = false;
    if ($cave['playerID'] != 0) {
        $caveDetails = getCaves($cave['playerID']);
        $playerDetails = getPlayerByID($cave['playerID']);
        $showArtePossible = $playerDetails['tribe'] != GOD_ALLY ? true : false;
    }
    $cave['terrain_name'] = $GLOBALS['terrainList'][$cave['terrain']]['name'];
    $cave['terrain_img'] = $GLOBALS['terrainList'][$cave['terrain']]['img'];
    $region = getRegionByID($cave['regionID']);
    if ($cave['artefacts'] != 0 && ($showArtePossible || $_SESSION['player']->tribe == GOD_ALLY)) {
        $cave['artefact'] = true;
    }
    $template->addVar('cave_details', $cave);
    if ($cave['playerID'] != 0) {
        $template->addVar('player_details', $playerDetails);
        /****************************************************************************************************
        *
        * Alle Höhlen des Spielers ausgeben
        *
        ****************************************************************************************************/
        $caves = array();
        foreach ($caveDetails as $key => $value) {
            $temp = array('caveName' => $value['name'], 'xCoord' => $value['xCoord'], 'yCoord' => $value['yCoord'], 'terrain' => $GLOBALS['terrainList'][$value['terrain']]['name'], 'caveSize' => floor($value[CAVE_SIZE_DB_FIELD] / 50) + 1, 'secureCave' => $value['secureCave']);
            if ($value['artefacts'] != 0 && ($playerDetails['tribe'] != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
                $temp['artefact'] = true;
            }
            $caves[] = $temp;
        }
        $template->addVar('player_caves', $caves);
    } else {
        if (sizeof($ownCaves) < $_SESSION['player']->takeover_max_caves && $cave['takeoverable'] == 1) {
            $template->addVar('takeoverable', true);
        }
    }
}
예제 #5
0
if ($functionname == 'delDriver') {
    $driverID = $_POST["driverID"];
    delDriver($driverID, $mysqli);
}
/*Region*/
if ($functionname == 'setRegion') {
    $regionID = $_POST["regionID"];
    $regionName = $_POST["regionName"];
    setRegion($regionID, $regionName, $mysqli);
}
if ($functionname == 'getRegion') {
    getRegion($mysqli);
}
if ($functionname == 'getRegionByID') {
    $regionID = $_POST["regionID"];
    getRegionByID($regionID, $mysqli);
}
if ($functionname == 'delRegion') {
    $regionID = $_POST["regionID"];
    delRegion($regionID, $mysqli);
}
/*State*/
if ($functionname == 'setState') {
    $stateID = $_POST["stateID"];
    $stateName = $_POST["stateName"];
    $stateCode = $_POST["stateCode"];
    setState($stateID, $stateName, $stateCode, $mysqli);
}
if ($functionname == 'getState') {
    getState($mysqli);
}
예제 #6
0
function getCaveDetailsContent($cave_data, $showGiveUp = TRUE, $alternate = FALSE)
{
    global $resourceTypeList, $buildingTypeList, $unitTypeList, $scienceTypeList, $defenseSystemTypeList, $params, $config, $db;
    // give this cave up
    if ($params->POST->caveGiveUpConfirm) {
        if (cave_giveUpCave($params->POST->giveUpCaveID, $params->SESSION->player->playerID, $params->SESSION->player->tribe)) {
            return _('Sie haben sich aus dieser Höhle zurückgezogen.');
        } else {
            $message = _('Diese Höhle kann nicht aufgegeben werden.');
        }
    } else {
        if ($params->POST->endProtectionConfirm) {
            if (beginner_endProtection($cave_data['caveID'], $params->SESSION->player->playerID, $db)) {
                $message = _('Sie haben den Anfängerschutz abgeschaltet.');
                $cave_data['protected'] = 0;
            } else {
                $message = _('Sie konnten den Anfängerschutz nicht abschalten.');
            }
        }
    }
    $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'cave.ihtml');
    if ($message) {
        tmpl_set($template, "/MESSAGE/message", $message);
    }
    // get region data
    $region = getRegionByID($cave_data['regionID']);
    // fill give-up form
    if ($showGiveUp) {
        tmpl_set($template, "GIVE_UP", $cave_data);
    }
    // fill end beginner protection form
    if ($cave_data['protected']) {
        tmpl_set($template, "UNPROTECT/iterate", '');
    }
    // fill cave info template
    tmpl_context($template, $alternate ? "/CAVE_ALTERNATE" : "/CAVE");
    // set properties
    $properties = array();
    if ($cave_data['protected']) {
        $properties[] = array('text' => _('Anfängerschutz aktiv'));
    }
    if (!$cave_data['secureCave']) {
        $properties[] = array('text' => _('übernehmbar'));
    }
    if ($cave_data['starting_position'] > 0) {
        $properties[] = array('text' => _('Haupthöhle'));
    }
    if (sizeof($properties)) {
        tmpl_set($template, 'PROPERTY', $properties);
    }
    tmpl_set($template, 'caveID', $cave_data['caveID']);
    tmpl_set($template, 'name', $cave_data['name']);
    tmpl_set($template, 'xCoord', $cave_data['xCoord']);
    tmpl_set($template, 'yCoord', $cave_data['yCoord']);
    tmpl_set($template, 'region', $region['name']);
    // RESOURCES AUSFUELLEN
    $resources = array();
    foreach ($resourceTypeList as $resource) {
        if (!$resource->nodocumentation || $cave_data[$resource->dbFieldName] > 0) {
            $resources[] = array('file' => $resource->dbFieldName, 'name' => $resource->name, 'value' => $cave_data[$resource->dbFieldName]);
        }
    }
    if (sizeof($resources)) {
        tmpl_set($template, 'RESOURCES/RESOURCE', $resources);
    }
    // UNITS AUSFUELLEN
    $units = array();
    foreach ($unitTypeList as $unit) {
        $value = $cave_data[$unit->dbFieldName];
        if ($value != 0) {
            $units[] = array('file' => $unit->dbFieldName, 'name' => $unit->name, 'value' => $value);
        }
    }
    if (sizeof($units)) {
        tmpl_set($template, 'UNITS/UNIT', $units);
    }
    // BUILDINGS AUSFUELLEN
    $addons = array();
    foreach ($buildingTypeList as $building) {
        $value = $cave_data[$building->dbFieldName];
        if ($value != 0) {
            $buildings[] = array('file' => $building->dbFieldName, 'name' => $building->name, 'value' => $value);
        }
    }
    if (sizeof($buildings)) {
        tmpl_set($template, 'BUILDINGS/BUILDING', $buildings);
    }
    // VERTEIDIGUNG AUSFUELLEN
    $defenses = array();
    foreach ($defenseSystemTypeList as $defense) {
        $value = $cave_data[$defense->dbFieldName];
        if ($value != 0) {
            $defenses[] = array('file' => $defense->dbFieldName, 'name' => $defense->name, 'value' => $value);
        }
    }
    if (sizeof($defenses)) {
        tmpl_set($template, 'DEFENSES/DEFENSE', $defenses);
    }
    return tmpl_parse($template);
}