Ejemplo n.º 1
0
function getArtefactMovement($artefactID, $showETA = false)
{
    global $db;
    $sql = 'SELECT source_caveID, target_caveID, movementID, ' . 'event_end ' . 'FROM Event_movement WHERE artefactID = ' . $artefactID;
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return array();
    }
    $result = $dbresult->nextrow(MYSQL_ASSOC);
    $result['event_end'] = date("d.m.Y H:i:s", time_timestampToTime($result['event_end']));
    $sql = "SELECT c.name AS source_cavename, c.xCoord AS source_xCoord, " . "c.yCoord AS source_yCoord, " . "IF(ISNULL(p.name), 'leere Höhle',p.name) AS source_name, " . "p.tribe AS source_tribe, p.playerID AS source_playerID " . "FROM Cave c LEFT JOIN Player p ON c.playerID = p.playerID " . "WHERE c.caveID = " . $result['source_caveID'];
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return array();
    }
    $result += $dbresult->nextrow(MYSQL_ASSOC);
    $sql = "SELECT c.name AS destination_cavename, c.xCoord AS destination_xCoord, " . "c.yCoord AS destination_yCoord, " . "IF(ISNULL(p.name), 'leere Höhle',p.name) AS destination_name, " . "p.tribe AS destination_tribe, p.playerID AS destination_playerID " . "FROM Cave c LEFT JOIN Player p ON c.playerID = p.playerID " . "WHERE c.caveID = " . $result['target_caveID'];
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return array();
    }
    $result += $dbresult->nextrow(MYSQL_ASSOC);
    return $result;
}
Ejemplo n.º 2
0
function unit_getUnitDetail($caveID, &$details)
{
    global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db, $MAX_RESOURCE;
    // messages
    $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 4 => "Bitte korrekte Anzahl der Einheiten Angeben (1 ... " . MAX_SIMULTAN_BUILDED_UNITS . ")");
    // proccess a cancel-order request
    if (isset($params->POST->eventID)) {
        $messageID = unit_processOrderCancel($params->POST->eventID, $caveID, $db);
    }
    // proccess a new order request
    if (isset($params->POST->unitID)) {
        $messageID = unit_processOrder($params->POST->unitID, intval($params->POST->quantity), $caveID, $db, $details);
        $r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
        if ($r->isEmpty()) {
            page_dberror();
        }
        $details = $r->nextRow();
    }
    $queue = unit_getUnitQueueForCave($params->SESSION->user['playerID'], $caveID);
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/unitbuild.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // Show the unit table
    for ($i = 0; $i < sizeof($unitTypeList); $i++) {
        $notenough = FALSE;
        $unit = $unitTypeList[$i];
        // the current unit
        $result = rules_checkDependencies($unit, $details);
        if ($result === TRUE) {
            tmpl_iterate($template, '/UNIT');
            tmpl_set($template, "UNIT/alternate", $count++ % 2 ? "alternate" : "");
            tmpl_set($template, 'UNIT', array('name' => $unit->name, 'dbFieldName' => $unit->dbFieldName, 'unitID' => $i, 'modus' => UNIT_PROPERTIES, 'caveID' => $caveID, 'size' => "0" + $details[$unit->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($unit->productionTimeFunction . ";", '$details')) * BUILDING_TIME_BASE_FACTOR)));
            // iterate ressourcecosts
            foreach ($unit->resourceProductionCost as $resourceID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "UNIT/RESSOURCECOST");
                    if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "UNIT/RESSOURCECOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "UNIT/RESSOURCECOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "UNIT/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
                    tmpl_set($template, "UNIT/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
                }
            }
            // iterate unitcosts
            foreach ($unit->unitProductionCost as $unitID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "UNIT/UNITCOST");
                    if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "UNIT/UNITCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "UNIT/UNITCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "UNIT/UNITCOST/name", $unitTypeList[$unitID]->name);
                }
            }
            // iterate buildingcosts
            foreach ($unit->buildingProductionCost as $buildingID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
                    if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
                }
            }
            // iterate externalcosts
            foreach ($unit->externalProductionCost as $externalID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
                    if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
                }
            }
            // show the improvement link ?!
            if ($queue) {
                tmpl_set($template, "UNIT/UNIT_LINK_NO/message", "Ausbildung im Gange");
            } else {
                if ($notenough) {
                    tmpl_set($template, "UNIT/UNIT_LINK_NO/message", "");
                } else {
                    $formParams = array(array('name' => 'modus', 'value' => UNIT_BUILDER), array('name' => 'caveID', 'value' => $caveID), array('name' => 'unitID', 'value' => $unit->unitID));
                    tmpl_set($template, "UNIT/UNIT_LINK/PARAMS", $formParams);
                }
            }
        } else {
            if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$unit->nodocumentation) {
                tmpl_iterate($template, '/UNQUALIFIEDUNITS/UNIT');
                tmpl_set($template, '/UNQUALIFIEDUNITS/UNIT', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => UNIT_PROPERTIES, 'unitID' => $i, 'caveID' => $caveID, 'dbFieldName' => $unit->dbFieldName, 'name' => $unit->name, 'dependencies' => $result));
            }
        }
    }
    // Show the building queue
    if ($queue) {
        // display the unit building queue
        $row = $queue->nextRow();
        tmpl_set($template, 'UNIT_QUEUE', array('name' => $unitTypeList[$row[unitID]]->name, 'quantity' => $row['quantity'], 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row[event_end])), 'action' => UNIT_BUILDER, 'eventID' => $row['event_unitID'], 'caveID' => $caveID));
    }
    return tmpl_parse($template);
}
Ejemplo n.º 3
0
 public static function getPlayerList($tribeID, $getGod = false, $getCaves = false, $orderBy = 'r.rank')
 {
     global $db;
     if (empty($tribeID)) {
         return array();
     }
     $auth = new auth();
     $select = '';
     if ($getGod) {
         foreach (Config::$gods as $god) {
             $select .= ', p.' . $god . ' as ' . $god;
         }
         foreach (Config::$halfGods as $halfgod) {
             $select .= ', p.' . $halfgod . ' as ' . $halfgod;
         }
     }
     $return = array();
     $sql = $db->prepare("SELECT p.playerID, p.name, p.awards, p.auth, r.rank, r.average AS points, r.caves, r.religion, r.fame, r.fame as kp, s.lastAction  {$select}\n                         FROM " . PLAYER_TABLE . " p\n                           LEFT JOIN " . RANKING_TABLE . " r ON r.playerID = p.playerID\n                           LEFT JOIN " . SESSION_TABLE . " s ON s.playerID = p.playerID\n                         WHERE p.tribeID = :tribeID\n                         ORDER BY {$orderBy} ASC");
     $sql->bindValue('tribeID', $tribeID, PDO::PARAM_INT);
     if (!$sql->execute()) {
         return array();
     }
     while ($member = $sql->fetch(PDO::FETCH_ASSOC)) {
         $return[$member['playerID']] = $member;
         if (!empty($member['awards'])) {
             $member['awards'] = explode('|', $member['awards']);
             $awards = array();
             foreach ($member['awards'] as $award) {
                 $awards[] = array('tag' => $award, 'award_modus' => AWARD_DETAIL);
             }
             $return[$member['playerID']]['award'] = $awards;
         }
         $return[$member['playerID']]['lastAction'] = date("d.m.Y H:i:s", time_timestampToTime($member['lastAction']));
         $userAuth = unserialize($member['auth']);
         $return[$member['playerID']]['tribeAuth'] = $auth->getAllTypePermission('tribe', $userAuth['tribe']);
         if ($getCaves) {
             $return[$member['playerID']]['caves'] = array();
         }
     }
     $sql->closeCursor();
     if ($getGod) {
         foreach ($GLOBALS['scienceTypeList'] as $value) {
             $ScienceFieldsName[$value->dbFieldName] = $value->name;
         }
         foreach ($return as $id => $data) {
             $return[$id]['god'] = 'keinen';
             $return[$id]['halfgod'] = 'keinen';
             foreach (Config::$gods as $god) {
                 if ($return[$id][$god] > 0) {
                     $return[$id]['god'] = $ScienceFieldsName[$god];
                 }
             }
             foreach (Config::$halfGods as $halfgod) {
                 if ($return[$id][$halfgod] > 0) {
                     $return[$id]['halfgod'] = $ScienceFieldsName[$halfgod];
                 }
             }
         }
     }
     if ($getCaves && !empty($return)) {
         $sql = $db->prepare("SELECT caveID, xCoord, yCoord, name, playerID\n                           FROM " . CAVE_TABLE . "\n                           WHERE playerID IN ('" . implode("', '", array_keys($return)) . "')");
         if (!$sql->execute()) {
             return array();
         }
         while ($caves = $sql->fetch(PDO::FETCH_ASSOC)) {
             $return[$caves['playerID']]['caves'][$caves['caveID']] = $caves;
         }
         $sql->closeCursor();
     }
     return $return;
 }
Ejemplo n.º 4
0
function digest_getAppointments($meineHoehlen)
{
    global $buildingTypeList, $scienceTypeList, $defenseSystemTypeList, $unitTypeList, $db;
    $caveIDs = array();
    foreach ($meineHoehlen as $caveID => $value) {
        $caveIDs[] = $caveID;
    }
    $caveIDs = "caveID IN (" . implode(", ", $caveIDs) . ")";
    $result = array();
    $query = "SELECT * FROM Event_unit WHERE " . $caveIDs;
    if (!($dbresult = $db->query($query))) {
        return array();
    }
    while ($row = $dbresult->nextrow(MYSQL_ASSOC)) {
        $temp_time = time_timestampToTime($row['event_end']);
        $result[] = array('event_name' => $row['quantity'] . "x " . $unitTypeList[$row['unitID']]->name, 'cave_name' => $meineHoehlen[$row['caveID']]['name'], 'caveID' => $row['caveID'], 'category' => 'unit', 'modus' => UNIT_BUILDER, 'eventID' => $row['event_unitID'], 'event_end' => date("d.m.Y H:i:s", $temp_time), 'seconds_before_end' => $temp_time - time());
    }
    $query = "SELECT * FROM Event_expansion WHERE " . $caveIDs;
    if (!($dbresult = $db->query($query))) {
        return array();
    }
    while ($row = $dbresult->nextrow(MYSQL_ASSOC)) {
        $temp_time = time_timestampToTime($row['event_end']);
        $result[] = array('event_name' => $buildingTypeList[$row['expansionID']]->name, 'cave_name' => $meineHoehlen[$row['caveID']]['name'], 'caveID' => $row['caveID'], 'category' => 'building', 'modus' => IMPROVEMENT_DETAIL, 'eventID' => $row['event_expansionID'], 'event_end' => date("d.m.Y H:i:s", $temp_time), 'seconds_before_end' => $temp_time - time());
    }
    $query = "SELECT * FROM Event_defenseSystem WHERE " . $caveIDs;
    if (!($dbresult = $db->query($query))) {
        return array();
    }
    while ($row = $dbresult->nextrow(MYSQL_ASSOC)) {
        $temp_time = time_timestampToTime($row['event_end']);
        $result[] = array('event_name' => $defenseSystemTypeList[$row['defenseSystemID']]->name, 'cave_name' => $meineHoehlen[$row['caveID']]['name'], 'caveID' => $row['caveID'], 'category' => 'defense', 'modus' => DEFENSESYSTEM, 'eventID' => $row['event_defenseSystemID'], 'event_end' => date("d.m.Y H:i:s", $temp_time), 'seconds_before_end' => $temp_time - time());
    }
    $query = "SELECT * FROM Event_science WHERE " . $caveIDs;
    if (!($dbresult = $db->query($query))) {
        return array();
    }
    while ($row = $dbresult->nextrow(MYSQL_ASSOC)) {
        $temp_time = time_timestampToTime($row['event_end']);
        $result[] = array('event_name' => $scienceTypeList[$row['scienceID']]->name, 'cave_name' => $meineHoehlen[$row['caveID']]['name'], 'caveID' => $row['caveID'], 'category' => 'science', 'modus' => SCIENCE, 'eventID' => $row['event_scienceID'], 'event_end' => date("d.m.Y H:i:s", $temp_time), 'seconds_before_end' => $temp_time - time());
    }
    usort($result, "datecmp");
    return $result;
}
Ejemplo n.º 5
0
function improvement_getImprovementDetail($caveID, &$details)
{
    global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db;
    // messages
    $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 5 => "Das Geb&auml;ude wurde erfolgreich abgerissen", 6 => "Das Geb&auml;ude konnte nicht abgerissen werden", 7 => "Sie haben von der Sorte gar keine Geb&auml;ude", 8 => "Sie k&ouml;nnen derzeit kein Geb&auml;ude abreissen, weil erst vor Kurzem etwas in dieser Siedlung abgerissen wurde. Generell muss zwischen zwei Abrissen eine Zeitspanne von " . TORE_DOWN_TIMEOUT . " Minuten liegen.");
    // proccess a cancel-order request
    if (isset($params->POST->eventID)) {
        $messageID = improvement_processOrderCancel($params->POST->eventID, $caveID, $db);
    }
    // proccess a tore down or new order request
    if (isset($params->POST->breakDownConfirm)) {
        $messageID = improvement_breakDown($params->POST->buildingID, $caveID, $details, $db);
        $reload = 1;
    } else {
        if (isset($params->POST->buildingID)) {
            $messageID = improvement_processOrder($params->POST->buildingID, $caveID, $details, $db);
            $reload = 1;
        }
    }
    if ($reload) {
        // this isn't that elegant...
        $r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
        if ($r->isEmpty()) {
            page_dberror();
        }
        $details = $r->nextRow();
    }
    $queue = improvement_getImprovementQueueForCave($params->SESSION->user['playerID'], $caveID);
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/improvement.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // Show the improvement table
    for ($i = 0; $i < sizeof($buildingTypeList); $i++) {
        $notenough = FALSE;
        $building = $buildingTypeList[$i];
        // the current building
        $maxLevel = round(eval('return ' . formula_parseToPHP("{$building->maxLevel};", '$details')));
        $result = rules_checkDependencies($building, $details);
        if ($result === TRUE) {
            tmpl_iterate($template, 'IMPROVEMENT');
            tmpl_set($template, "IMPROVEMENT/alternate", $count++ % 2 ? "alternate" : "");
            tmpl_set($template, 'IMPROVEMENT', array('name' => $building->name, 'dbFieldName' => $building->dbFieldName, 'buildingID' => $i, 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'caveID' => $caveID, 'maxlevel' => $maxLevel, 'size' => "0" + $details[$building->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($building->productionTimeFunction . ";", '$details')) * BUILDING_TIME_BASE_FACTOR)));
            // iterate ressourcecosts
            foreach ($building->resourceProductionCost as $resourceID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "IMPROVEMENT/RESSOURCECOST");
                    if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
                    tmpl_set($template, "IMPROVEMENT/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
                }
            }
            // iterate unitcosts
            foreach ($building->unitProductionCost as $unitID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "IMPROVEMENT/UNITCOST");
                    if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "IMPROVEMENT/UNITCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "IMPROVEMENT/UNITCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "IMPROVEMENT/UNITCOST/name", $unitTypeList[$unitID]->name);
                }
            }
            // iterate buildingcosts
            /*
                  foreach ($building->buildingProductionCost as $buildingID => $function){
            
                    $cost = ceil(eval('return '. formula_parseToPHP($function . ';', '$details')));
            
                    if ($cost){
                      tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
            
                      if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost){
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
            
                      } else {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
            $notenough = TRUE;
                      }
                      tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
                    }
                  }
            */
            // iterate buildingcosts
            foreach ($building->buildingProductionCost as $buildingID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "IMPROVEMENT/BUILDINGCOST");
                    if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "IMPROVEMENT/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
                }
            }
            // iterate externalcosts
            foreach ($building->externalProductionCost as $externalID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
                    if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
                }
            }
            // show the break down link
            tmpl_set($template, 'IMPROVEMENT/BREAK_DOWN_LINK', array('action' => IMPROVEMENT_BREAK_DOWN, 'buildingID' => $building->buildingID, 'caveID' => $caveID));
            // show the building link ?!
            if ($queue) {
                tmpl_set($template, 'IMPROVEMENT/BUILD_LINK_NO/message', "Ausbau im Gange");
            } else {
                if ($notenough && $maxLevel > $details[$building->dbFieldName]) {
                    tmpl_set($template, 'IMPROVEMENT/BUILD_LINK_NO/message', "");
                } else {
                    if ($maxLevel > $details[$building->dbFieldName]) {
                        tmpl_set($template, 'IMPROVEMENT/BUILD_LINK', array('action' => IMPROVEMENT_DETAIL, 'buildingID' => $building->buildingID, 'caveID' => $caveID));
                    } else {
                        tmpl_set($template, '/IMPROVEMENT/BUILD_LINK_NO/message', "Max. Stufe");
                    }
                }
            }
        } else {
            if ($details[$building->dbFieldName]) {
                tmpl_iterate($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT');
                tmpl_set($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT', array('alternate' => $count_unwanted++ % 2 ? "" : "alternate", 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'buildingID' => $i, 'caveID' => $caveID, 'size' => $details[$building->dbFieldName], 'dbFieldName' => $building->dbFieldName, 'name' => $building->name, 'action' => IMPROVEMENT_BREAK_DOWN));
                if ($result !== FALSE) {
                    tmpl_set($template, '/UNWANTEDIMPROVEMENTS/IMPROVEMENT/dependencies', $result);
                }
            } else {
                if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$building->nodocumentation) {
                    tmpl_iterate($template, '/UNQUALIFIEDIMPROVEMENTS/IMPROVEMENT');
                    tmpl_set($template, '/UNQUALIFIEDIMPROVEMENTS/IMPROVEMENT', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => IMPROVEMENT_BUILDING_DETAIL, 'buildingID' => $i, 'caveID' => $caveID, 'dbFieldName' => $building->dbFieldName, 'name' => $building->name, 'dependencies' => $result));
                }
            }
        }
    }
    // Show the building queue
    if ($queue) {
        // display the building queue
        $row = $queue->nextRow();
        tmpl_set($template, 'IMPROVEMENT_QUEUE', array('name' => $buildingTypeList[$row['expansionID']]->name, 'size' => $details[$buildingTypeList[$row['expansionID']]->dbFieldName] + 1, 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row['event_end'])), 'action' => IMPROVEMENT_DETAIL, 'eventID' => $row['event_expansionID'], 'caveID' => $caveID));
    }
    return tmpl_parse($template);
}
Ejemplo n.º 6
0
function tribe_getAllMembers($tag, $db)
{
    $query = "SELECT p.playerID, p.name, s.lastAction " . "FROM Player p " . "LEFT  JOIN  `Session` s ON s.playerID = p.playerID " . "WHERE tribe LIKE '{$tag}' " . "ORDER BY name ASC";
    $result = $db->query($query);
    if (!$result) {
        return -1;
    }
    $members = array();
    while ($row = $result->nextRow(MYSQL_ASSOC)) {
        $row['lastAction'] = date("d.m.Y H:i:s", time_timestampToTime($row['lastAction']));
        $members[$row['playerID']] = $row;
    }
    return $members;
}
Ejemplo n.º 7
0
function getStartPointForTournament($turnierID)
{
    global $db;
    $query = "SELECT starttime FROM Tournament t WHERE t.turnierID = {$turnierID}";
    $r = $db->query($query);
    if (!$r) {
        return "";
    }
    $r = $r->nextRow(MYSQL_ASSOC);
    if ($r['starttime'] == "") {
        return "";
    } else {
        return ", Start: " . date("d.m.Y \\u\\m H:i", time_timestampToTime($r['starttime']));
    }
}
Ejemplo n.º 8
0
function tribe_getAllMembers($tag)
{
    global $db;
    $auth = new auth();
    $members = array();
    $sql = $db->prepare("SELECT p.playerID, p.name, p.auth, s.lastAction \n                       FROM " . PLAYER_TABLE . " p\n                         LEFT JOIN " . SESSION_TABLE . " s ON s.playerID = p.playerID\n                       WHERE tribe LIKE :tag\n                       ORDER BY name ASC");
    $sql->bindValue('tag', $tag, PDO::PARAM_STR);
    if (!$sql->execute()) {
        return array();
    }
    while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
        $row['lastAction'] = date("d.m.Y H:i:s", time_timestampToTime($row['lastAction']));
        $members[$row['playerID']] = $row;
        $userAuth = unserialize($row['auth']);
        $members[$row['playerID']]['tribeAuth'] = $auth->getAllTypePermission('tribe', $userAuth['tribe']);
    }
    $sql->closeCursor();
    return $members;
}
Ejemplo n.º 9
0
function defenseSystem_getDefenseSystemDetail($caveID, &$details)
{
    global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db;
    // messages
    $messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 5 => "Das Geb&auml;ude wurde erfolgreich abgerissen", 6 => "Das Geb&auml;ude konnte nicht abgerissen werden", 7 => "Sie haben von der Sorte gar keine Geb&auml;ude");
    // proccess a cancel-order request
    if (isset($params->POST->eventID)) {
        $messageID = defenseSystem_processOrderCancel($params->POST->eventID, $caveID, $db);
    }
    // proccess a tore down or new order request
    if (isset($params->POST->breakDownConfirm)) {
        $messageID = defenseSystem_breakDown($params->POST->defenseSystemID, $caveID, $details, $db);
        $reload = 1;
    } else {
        if (isset($params->POST->defenseSystemID)) {
            check_timestamp($params->POST->tstamp);
            $messageID = defenseSystem_processOrder($params->POST->defenseSystemID, $caveID, $details, $db);
            $reload = 1;
        }
    }
    if ($reload) {
        // this isn't that elegant...
        $r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
        if ($r->isEmpty()) {
            page_dberror();
        }
        $details = $r->nextRow();
    }
    $queue = defenseSystem_getDefenseSystemQueueForCave($params->SESSION->user['playerID'], $caveID);
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/fortification.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // Show the defenseSystem table
    for ($i = 0; $i < sizeof($defenseSystemTypeList); $i++) {
        $notenough = FALSE;
        $defenseSystem = $defenseSystemTypeList[$i];
        // the current building
        $maxLevel = round(eval('return ' . formula_parseToPHP("{$defenseSystem->maxLevel};", '$details')));
        $result = rules_checkDependencies($defenseSystem, $details);
        // if all requirements are met but the maxLevel is 0,
        // treat it like a non-buildable
        if ($maxLevel <= 0 && $result === TRUE) {
            $result = $details[$defenseSystem->dbFieldName] ? 'Max. Stufe: 0' : FALSE;
        }
        if ($result === TRUE) {
            tmpl_iterate($template, 'DEFENSESYSTEM');
            tmpl_set($template, "DEFENSESYSTEM/alternate", $count++ % 2 ? "alternate" : "");
            tmpl_set($template, 'DEFENSESYSTEM', array('name' => $defenseSystem->name, 'dbFieldName' => $defenseSystem->dbFieldName, 'defenseSystemID' => $i, 'modus' => DEFENSESYSTEM_DETAIL, 'caveID' => $caveID, 'maxlevel' => $maxLevel, 'size' => "0" + $details[$defenseSystem->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($defenseSystem->productionTimeFunction . ";", '$details')) * DEFENSESYSTEM_TIME_BASE_FACTOR)));
            // iterate ressourcecosts
            foreach ($defenseSystem->resourceProductionCost as $resourceID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/RESSOURCECOST");
                    if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
                    tmpl_set($template, "DEFENSESYSTEM/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
                }
            }
            // iterate unitcosts
            foreach ($defenseSystem->unitProductionCost as $unitID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/UNITCOST");
                    if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/UNITCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/UNITCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/UNITCOST/name", $unitTypeList[$unitID]->name);
                }
            }
            // iterate buildingcosts
            foreach ($defenseSystem->buildingProductionCost as $buildingID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
                    if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
                }
            }
            // iterate externalcosts
            foreach ($defenseSystem->externalProductionCost as $externalID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
                    if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
                }
            }
            // show the break down link
            if ($details[$defenseSystem->dbFieldName]) {
                tmpl_set($template, 'DEFENSESYSTEM/BREAK_DOWN_LINK', array('action' => DEFENSESYSTEM_BREAK_DOWN, 'defenseSystemID' => $defenseSystem->defenseSystemID, 'caveID' => $caveID));
            }
            // show the improvement link ?!
            if ($queue) {
                tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', "Ausbau im Gange");
            } else {
                if ($notenough && $maxLevel > $details[$defenseSystem->dbFieldName]) {
                    tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK_NO/message', "");
                } else {
                    if ($maxLevel > $details[$defenseSystem->dbFieldName]) {
                        tmpl_set($template, 'DEFENSESYSTEM/BUILD_LINK', array('action' => DEFENSESYSTEM, 'defenseSystemID' => $defenseSystem->defenseSystemID, 'caveID' => $caveID, 'tstamp' => "" . time()));
                    } else {
                        tmpl_set($template, '/DEFENSESYSTEM/BUILD_LINK_NO/message', "Max. Stufe");
                    }
                }
            }
        } else {
            if ($details[$defenseSystem->dbFieldName]) {
                tmpl_iterate($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM');
                tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unwanted++ % 2 ? "" : "alternate", 'modus' => DEFENSESYSTEM_DETAIL, 'defenseSystemID' => $i, 'size' => $details[$defenseSystem->dbFieldName], 'dbFieldName' => $defenseSystem->dbFieldName, 'name' => $defenseSystem->name, 'action' => DEFENSESYSTEM_BREAK_DOWN));
                if ($result !== FALSE) {
                    tmpl_set($template, '/UNWANTEDDEFENSESYSTEMS/DEFENSESYSTEM/dependencies', $result);
                }
            } else {
                if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$defenseSystem->nodocumentation) {
                    tmpl_iterate($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM');
                    tmpl_set($template, '/UNQUALIFIEDDEFENSESYSTEMS/DEFENSESYSTEM', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => DEFENSESYSTEM_DETAIL, 'defenseSystemID' => $i, 'name' => $defenseSystem->name, 'dbFieldName' => $defenseSystem->dbFieldName, 'dependencies' => $result));
                }
            }
        }
    }
    // Show the building queue
    if ($queue) {
        $row = $queue->nextRow();
        tmpl_set($template, 'DEFENSESYSTEM_QUEUE', array('name' => $defenseSystemTypeList[$row['defenseSystemID']]->name, 'size' => $details[$defenseSystemTypeList[$row['defenseSystemID']]->dbFieldName] + 1, 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row['event_end'])), 'action' => DEFENSESYSTEM, 'eventID' => $row['event_defenseSystemID'], 'caveID' => $caveID));
    }
    return tmpl_parse($template);
}
Ejemplo n.º 10
0
function science_getScienceDetail($caveID, &$details)
{
    global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $scienceTypeList, $config, $params, $db;
    // messages
    $messageText = array(0 => "Der Forschungsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Forschungsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 4 => "Dieses Wissen wird schon in einer anderen Siedlung erforscht", 5 => "Es wird gerade in einer anderen Siedlung Wissen erforscht, " . "dass dieses Wissen ausschlie&szlig;t.");
    // proccess a cancel-order request
    if (isset($params->POST->eventID)) {
        $messageID = science_processOrderCancel($params->POST->eventID, $caveID, $db);
    }
    if (isset($params->POST->scienceID)) {
        $messageID = science_processOrder($params->POST->scienceID, $caveID, $params->SESSION->user['playerID'], $details, $db);
        $r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
        if ($r->isEmpty()) {
            page_dberror();
        }
        $details = $r->nextRow();
    }
    $queue = science_getScienceQueueForCave($params->SESSION->user['playerID'], $caveID);
    $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/science.ihtml");
    // Show a special message
    if (isset($messageID)) {
        tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
    }
    // Show the science table
    for ($i = 0; $i < sizeof($scienceTypeList); $i++) {
        $notenough = FALSE;
        $science = $scienceTypeList[$i];
        // the current science
        $maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$details')));
        $result = rules_checkDependencies($science, $details);
        if ($result === TRUE) {
            tmpl_iterate($template, 'SCIENCE');
            tmpl_set($template, "SCIENCE/alternate", $count++ % 2 ? "alternate" : "");
            tmpl_set($template, 'SCIENCE', array('dbFieldName' => $science->dbFieldName, 'name' => $science->name, 'scienceID' => $i, 'modus' => SCIENCE_DETAIL, 'caveID' => $caveID, 'maxlevel' => $maxLevel, 'size' => "0" + $details[$science->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($science->productionTimeFunction . ";", '$details')) * SCIENCE_TIME_BASE_FACTOR)));
            // iterate ressourcecosts
            foreach ($science->resourceProductionCost as $resourceID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "SCIENCE/RESSOURCECOST");
                    if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "SCIENCE/RESSOURCECOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "SCIENCE/RESSOURCECOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "SCIENCE/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
                    tmpl_set($template, "SCIENCE/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
                }
            }
            // iterate unitcosts
            foreach ($science->unitProductionCost as $unitID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "SCIENCE/UNITCOST");
                    if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "SCIENCE/UNITCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "SCIENCE/UNITCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "SCIENCE/UNITCOST/name", $unitTypeList[$unitID]->name);
                }
            }
            // iterate buildingcosts
            foreach ($science->buildingProductionCost as $buildingID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
                    if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
                }
            }
            // iterate externalcosts
            foreach ($science->externalProductionCost as $externalID => $function) {
                $cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
                if ($cost) {
                    tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
                    if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
                    } else {
                        tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
                        $notenough = TRUE;
                    }
                    tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
                }
            }
            // show the science link ?!
            if ($queue) {
                tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', "Ausbau im Gange");
            } else {
                if ($notenough && $maxLevel > $details[$science->dbFieldName]) {
                    tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', "");
                } else {
                    if ($maxLevel > $details[$science->dbFieldName]) {
                        tmpl_set($template, 'SCIENCE/RESEARCH_LINK', array('action' => SCIENCE, 'scienceID' => $science->scienceID, 'caveID' => $caveID));
                    } else {
                        tmpl_set($template, '/SCIENCE/RESEARCH_LINK_NO/message', "Max. Stufe");
                    }
                }
            }
        } else {
            if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$science->nodocumentation) {
                tmpl_iterate($template, '/UNQUALIFIEDSCIENCES/SCIENCE');
                tmpl_set($template, '/UNQUALIFIEDSCIENCES/SCIENCE', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => SCIENCE_DETAIL, 'scienceID' => $science->scienceID, 'caveID' => $caveID, 'dbFieldName' => $science->dbFieldName, 'name' => $science->name, 'dependencies' => $result));
            }
        }
    }
    // Show the science queue
    if ($queue) {
        // display the science queue
        $row = $queue->nextRow();
        tmpl_set($template, 'SCIENCE_QUEUE', array('name' => $scienceTypeList[$row['scienceID']]->name, 'size' => $details[$scienceTypeList[$row['scienceID']]->dbFieldName] + 1, 'finish' => date("d.m.Y H:i:s", time_timestampToTime($row['event_end'])), 'action' => SCIENCE, 'eventID' => $row['event_scienceID'], 'caveID' => $caveID));
    }
    return tmpl_parse($template);
}