Ejemplo n.º 1
0
function takeover_getContent($playerID, $caveID, $xCoord = NULL, $yCoord = NULL)
{
    global $config, $params, $resourceTypeList, $TAKEOVERMAXPOPULARITYPOINTS, $TAKEOVERMINRESOURCEVALUE;
    $template = @tmpl_open('templates/' . $config->template_paths[$params->SESSION->user['template']] . '/takeover.ihtml');
    if (getNumberOfCaves($playerID) >= $params->SESSION->user['takeover_max_caves']) {
        tmpl_set($template, 'feedback', "Sie haben bereits die maximale Anzahl von " . $params->SESSION->user['takeover_max_caves'] . " Siedlung(en) erreicht.");
    } else {
        $beliebtheit = $TAKEOVERMAXPOPULARITYPOINTS;
        $mindestgebot = $TAKEOVERMINRESOURCEVALUE;
        $resourcevalues = array();
        for ($i = 0; $i < sizeof($resourceTypeList); ++$i) {
            array_push($resourcevalues, array('dbFieldName' => $resourceTypeList[$i]->dbFieldName, 'name' => $resourceTypeList[$i]->name, 'value' => $resourceTypeList[$i]->takeoverValue));
        }
        tmpl_set($template, 'TAKEOVER', array('beliebtheit' => $beliebtheit, 'maxcaves' => $params->SESSION->user['takeover_max_caves'], 'mindestgebot' => $mindestgebot, 'targetXCoord' => $params->POST->targetXCoord, 'targetYCoord' => $params->POST->targetYCoord, 'RESOURCEVALUE' => $resourcevalues, 'HIDDEN' => array('name' => 'modus', 'value' => TAKEOVER_CHANGE)));
        for ($i = 0; $i < $beliebtheit; ++$i) {
            tmpl_iterate($template, 'TAKEOVER/LEGENDE');
            tmpl_set($template, 'TAKEOVER/LEGENDE/status', $i);
            tmpl_set($template, 'TAKEOVER/LEGENDE', getStatusPic($i));
        }
        if (!($xCoord == "" || $yCoord == "")) {
            // neue Koordinaten
            // 1. pruefen, ob freie Hoehle
            // 2. neuen Eintrag in Cave_takeover (alten ueberschreiben)
            if (changeCaveIfReasonable($playerID, $xCoord, $yCoord)) {
                tmpl_set($template, 'feedback', "Sie bieten nun f&uuml;r die Siedlung in (" . $xCoord . " | " . $yCoord . ").");
            } else {
                tmpl_set($template, 'feedback', "Sie k&ouml;nnen nicht f&uuml;r diese" . " Siedlung (" . $xCoord . " | " . $yCoord . ")." . " bieten. W&auml;hlen sie eine freie Siedlung.");
            }
        }
        $takeover = new Takeover($playerID);
        if (!is_null($takeover)) {
            tmpl_iterate($template, 'TAKEOVER/HIDDEN');
            tmpl_set($template, 'TAKEOVER/HIDDEN', array(array('name' => 'currentXCoord', 'value' => $takeover->xCoord), array('name' => 'currentYCoord', 'value' => $takeover->yCoord)));
            tmpl_context($template, '/TAKEOVER/CHOSEN');
            tmpl_set($template, 'xCoord', $takeover->xCoord);
            tmpl_set($template, 'yCoord', $takeover->yCoord);
            tmpl_set($template, 'caveName', $takeover->caveName);
            tmpl_set($template, $takeover->getStatus());
            tmpl_set($template, 'bewegung', "?modus=" . MOVEMENT . "&caveID=" . $caveID . "&targetXCoord=" . $takeover->xCoord . "&targetYCoord=" . $takeover->yCoord . "&targetCaveName=" . unhtmlentities($takeover->caveName));
            if (sizeof($takeover->resources) != 0) {
                tmpl_context($template, '/TAKEOVER/CHOSEN/RESOURCES/RESOURCE');
                tmpl_set($template, $takeover->resources);
                tmpl_set($template, '../SUM/sum', $takeover->resources_sum);
            } else {
                tmpl_context($template, '/TAKEOVER/CHOSEN/RESOURCES/NONE');
                tmpl_set($template, 'none', 'keine');
            }
            if (sizeof($takeover->bidders) != 0) {
                tmpl_context($template, '/TAKEOVER/CHOSEN/BIDDERS/BIDDER');
                tmpl_set($template, $takeover->bidders);
            } else {
                tmpl_context($template, '/TAKEOVER/CHOSEN/BIDDERS/NOONE');
                tmpl_set($template, 'noone', 'niemand');
            }
        }
    }
    return tmpl_parse($template);
}
Ejemplo n.º 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);
}
Ejemplo n.º 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);
}