예제 #1
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);
    }
}
예제 #2
0
function getCaveDetailsContent($details, $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->user['playerID'])) {
            return "<p><b>Sie haben sich aus dieser Siedlung zur&uuml;ckgezogen.</b>";
        } else {
            $message = "<p>Diese Siedlung kann nicht aufgegeben werden.</p>";
        }
        // end beginners protection
    } else {
        if ($params->POST->endProtectionConfirm) {
            if (beginner_endProtection($details['caveID'], $params->SESSION->user['playerID'], $db)) {
                $message = "<p><b>Sie haben den Anf&auml;ngerschutz abgeschaltet.</b>";
            } else {
                $message = "<p>Sie konnten den Anf&auml;ngerschutz nicht abschalten.</p>";
            }
        }
    }
    $widthCount = 10;
    $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/cave.ihtml');
    if ($message) {
        tmpl_set($template, "/MESSAGE/message", $message);
    }
    // fill give-up form
    if ($showGiveUp) {
        tmpl_context($template, "/GIVE_UP");
        tmpl_set($template, 'ARGUMENT', array(array('arg_name' => "giveUpCaveID", 'arg_value' => $details['caveID']), array('arg_name' => "modus", 'arg_value' => CAVE_GIVE_UP_CONFIRM)));
        tmpl_set($template, "text", "Siedlung " . $details['name'] . " aufgeben");
    }
    // fill end beginner protection form
    if ($details['protected']) {
        tmpl_iterate($template, "/GIVE_UP");
        tmpl_context($template, "/GIVE_UP");
        tmpl_iterate($template, "ARGUMENT");
        tmpl_set($template, "ARGUMENT/arg_name", "caveID");
        tmpl_set($template, "ARGUMENT/arg_value", $details['caveID']);
        tmpl_iterate($template, "ARGUMENT");
        tmpl_set($template, "ARGUMENT/arg_name", "modus");
        tmpl_set($template, "ARGUMENT/arg_value", END_PROTECTION_CONFIRM);
        tmpl_set($template, "text", "Anf&auml;ngerschutz vorzeitig beenden.");
    }
    // fill cave info template
    tmpl_context($template, $alternate ? "/CAVE_ALTERNATE" : "/CAVE");
    if ($details['protected']) {
        tmpl_set($template, "PROPERTY/text", 'Anf&auml;ngerschutz aktiv');
    }
    if (!$details['secureCave']) {
        tmpl_iterate($template, "PROPERTY");
        tmpl_set($template, "PROPERTY/text", '&uuml;bernehmbar');
    }
    if ($details['starting_position'] > 0) {
        tmpl_iterate($template, "PROPERTY");
        tmpl_set($template, "PROPERTY/text", 'Hauptsiedlung');
    }
    tmpl_set($template, 'caveID', $details['caveID']);
    tmpl_set($template, 'name', $details['name']);
    tmpl_set($template, 'xCoord', $details['xCoord']);
    tmpl_set($template, 'yCoord', $details['yCoord']);
    // RESOURCES AUSFUELLEN
    $resources = array();
    for ($i = 0; $i < sizeof($resourceTypeList); ++$i) {
        $resources[] = array('file' => $resourceTypeList[$i]->dbFieldName, 'name' => $resourceTypeList[$i]->name, 'value' => $details[$resourceTypeList[$i]->dbFieldName]);
    }
    if (sizeof($resources)) {
        tmpl_set($template, 'RESOURCES/RESOURCE', $resources);
    }
    // UNITS AUSFUELLEN
    $units = array();
    for ($i = 0; $i < sizeof($unitTypeList); ++$i) {
        $value = $details[$unitTypeList[$i]->dbFieldName];
        if ($value != 0) {
            $units[] = array('file' => $unitTypeList[$i]->dbFieldName, 'name' => $unitTypeList[$i]->name, 'value' => $value);
        }
    }
    if (sizeof($units)) {
        tmpl_set($template, 'UNITS/UNIT', $units);
    }
    // BUILDINGS AUSFUELLEN
    $addons = array();
    for ($i = 0; $i < sizeof($buildingTypeList); ++$i) {
        $value = $details[$buildingTypeList[$i]->dbFieldName];
        if ($value != 0) {
            $addons[] = array('file' => $buildingTypeList[$i]->dbFieldName, 'name' => $buildingTypeList[$i]->name, 'value' => $value);
        }
    }
    if (sizeof($addons)) {
        tmpl_set($template, 'BUILDINGS/BUILDING', $addons);
    }
    // VERTEIDIGUNG AUSFUELLEN
    $defense = array();
    for ($i = 0; $i < sizeof($defenseSystemTypeList); ++$i) {
        $value = $details[$defenseSystemTypeList[$i]->dbFieldName];
        if ($value != 0) {
            $defense[] = array('file' => $defenseSystemTypeList[$i]->dbFieldName, 'name' => $defenseSystemTypeList[$i]->name, 'value' => $value);
        }
    }
    if (sizeof($defense)) {
        tmpl_set($template, 'DEFENSES/DEFENSE', $defense);
    }
    return tmpl_parse($template);
}
예제 #3
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);
}