function getCaveReport($meineHoehlen, $caveID, $targetCaveID, $playerID) { global $params, $config, $terrainList; $cave = getCaveByID($targetCaveID); $caveDetails = array(); $playerDetails = array(); // ADDED by chris--- for Quests // ---------------------------------------------------------- global $db; // checking if this cave is a quest cave and if its visible to the player (than he knows the quest) // if he does not know the quest the cave is invisible if (isCaveQuestCave($targetCaveID, $db) && isCaveInvisibleToPlayer($targetCaveID, $playerID, $db)) { $cave['playerID'] = 0; } // ---------------------------------------------------------- if ($cave['playerID'] != 0) { $caveDetails = getCaves($cave['playerID']); $playerDetails = getPlayerFromID($cave['playerID']); // ADDED by chris--- for farmschutz if (FARMSCHUTZ_ACTIVE == 1) { $farmschutz = getFarmschutz($cave['playerID']); } else { $farmschutz = ""; } } $template = @tmpl_open('./templates/' . $config->template_paths[$params->SESSION->user['template']] . '/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!'); } // ADDED by chris--- for Quests -------------------------------------------------------------------------------- if ($cave['quest_cave'] && !isCaveInvisibleToPlayer($cave['caveID'], $playerID, $db) && $cave['invisible_name'] != "") { $cave['name'] = $cave['invisible_name']; } // ------------------------------------------------------------------------------------------------------- $addCaveLink = "?modus=" . CAVE_BOOK_ADD . "&id=" . $targetCaveID; // ADDED by chris--- for cavebook tmpl_set($template, '/', array('cavename' => $cave['name'], 'xcoord' => $cave['xCoord'], 'ycoord' => $cave['yCoord'], 'terrain' => $terrainList[$cave['terrain']]['name'], 'movementlink' => "?modus=" . MOVEMENT . "&targetXCoord=" . $cave['xCoord'] . "&targetYCoord=" . $cave['yCoord'] . "&targetCaveName=" . unhtmlentities($cave['name']), 'backlink' => "?modus=" . MAP . "&xCoord=" . $cave['xCoord'] . "&yCoord=" . $cave['yCoord'])); if ($cave['playerID'] != 0) { tmpl_set($template, '/OCCUPIED', array('playerLink' => "?modus=" . PLAYER_DETAIL . "&detailID=" . $playerDetails['playerID'], 'caveOwner' => $playerDetails['name'], 'farmschutz' => $farmschutz, 'adressbook_add_modus' => MESSAGE_BOOK_ADD, 'addCaveLink' => $addCaveLink)); 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->user['tribe'] == GOD_ALLY)) { tmpl_set($template, '/OCCUPIED/ARTEFACT/artefactLink', "?modus=" . ARTEFACT_LIST . "&caveID={$caveID}"); } $caves = array(); foreach ($caveDetails as $key => $value) { if (!(isCaveQuestCave($value['caveID'], $db) && isCaveInvisibleToPlayer($value['caveID'], $playerID, $db))) { $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=" . MOVEMENT . "&targetXCoord=" . $value['xCoord'] . "&targetYCoord=" . $value['yCoord'] . "&targetCaveName=" . unhtmlentities($value['name'])); if ($value['artefacts'] != 0 && ($playerDetails['tribe'] != GOD_ALLY || $params->SESSION->user['tribe'] == GOD_ALLY)) { $temp['ARTEFACT'] = array('artefactLink' => "?modus=" . ARTEFACT_LIST . "&caveID={$caveID}"); } if ($value['protected'] && $value['playerID']) { $temp['PROPERTY'] = array('text' => 'Schutz'); } else { if (!$value['secureCave']) { $temp['PROPERTY'] = array('text' => 'übernehmbar'); } } $caves[] = $temp; } } tmpl_set($template, '/OCCUPIED/CAVES', $caves); } else { if (sizeof($meineHoehlen) < $params->SESSION->user['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); }
function unitAction($caveID, &$meineHoehlen) { global $config, $db, $MAX_RESOURCE, $MOVEMENTCOSTCONSTANT, $MOVEMENTSPEEDCONSTANT, $params, $ua_movements, $resourceTypeList, $unitTypeList, $effectTypeList, $FUELRESOURCEID; $details = $meineHoehlen[$caveID]; /***************************************************************************/ /** **/ /** CHECK ARTEFACTS **/ /** **/ /***************************************************************************/ // artefact moving: get ID if any // // $params->POST->myartefacts will be // NULL, if it is not set at all // -1 when choosing no artefact to move // 0 if there was a real choice // default: Move No Artefact (this var holds the artefactID to move) $moveArtefact = 0; // this array shall contain the artefacts if any $myartefacts = array(); // does the cave contain an artefact at least? if ($details['artefacts'] > 0) { // get artefacts $myartefacts = artefact_getArtefactsReadyForMovement($caveID); // was an artefact chosen? if ((int) $params->POST->myartefacts > 0) { $tempID = (int) $params->POST->myartefacts; // now check, whether this artefactID belongs to this cave foreach ($myartefacts as $key => $value) { // if found, set it if ($tempID == $value['artefactID']) { $moveArtefact = $tempID; break; } } } } // now $moveArtefact should contain 0 for 'move no artefact' // or the artefactID of the artefact to be moved /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ // get Map Size $size = getMapSize(); $dim_x = ($size['maxX'] - $size['minX'] + 1) / 2; $dim_y = ($size['maxY'] - $size['minY'] + 1) / 2; $foodPerCave = eval('return ' . formula_parseToPHP($MOVEMENTCOSTCONSTANT . ';', '$details')); $minutesPerCave = eval('return ' . formula_parseToPHP($MOVEMENTSPEEDCONSTANT . ';', '$details')); if (isset($params->POST->moveit)) { $targetXCoord = $params->POST->targetXCoord; $targetYCoord = $params->POST->targetYCoord; $targetCaveName = $params->POST->targetCaveName; $movementID = $params->POST->movementID; // check for scripters check_timestamp($params->POST->tstamp); // HöhlenName >>> Koordinate $validCaveName = FALSE; if (empty($targetXCoord) || empty($targetYCoord) and !empty($targetCaveName)) { $result = getCaveByName($targetCaveName); if (sizeof($result) != 0) { $targetXCoord = $result['xCoord']; $targetYCoord = $result['yCoord']; $validCaveName = TRUE; } } // Array von Nullwerten befreien $unit = array_filter($params->POST->unit, "filterZeros"); $unit = array_map("checkFormValues", $unit); $resource = array_map("checkFormValues", $params->POST->rohstoff); // Test, ob Einheitentragekapazität ausgelastet foreach ($resource as $resKey => $aRes) { $capacity = 0; foreach ($unit as $unitKey => $aUnit) { $capacity += $aUnit * $unitTypeList[$unitKey]->encumbranceList[$resKey]; } if ($capacity < $aRes) { $overloaded = 1; break; } } // ADDED by chris--- for farmschutz if (FARMSCHUTZ_ACTIVE == 1) { if ($params->POST->movementID == 3 || $params->POST->movementID == 6) { $farmschutz = farmschutz($targetXCoord, $targetYCoord, $params->SESSION->user['playerID'], $db); } } // ------------------------------------ if ($params->POST->movementID == 0) { $msg = "*#\$@*#\$%: Bitte Bewegungsart auswählen!"; } else { if (!sizeof($unit)) { $msg = "*#\$@*#\$%: Es sind keine Einheiten ausgewählt!"; } else { if (empty($targetXCoord) || empty($targetYCoord) and empty($targetCaveName)) { $msg = "*#\$@*#\$%: Es fehlt eine Zielkoordinate oder ein Zielsiedlungsname!"; } else { if (empty($targetXCoord) || empty($targetYCoord) and !empty($targetCaveName) and $validCaveName === FALSE) { $msg = "*#\$@*#\$%: Es gibt keine Siedlung mit dem Namen '" . $targetCaveName . "'!"; } else { if ($overloaded) { $msg = "*#\$@*#\$%: Deine Krieger können die Menge an Ressourcen nicht tragen!!"; } else { if (beginner_isCaveProtectedByCoord($targetXCoord, $targetYCoord, $db)) { $msg = "*#\$@*#\$%: Die Zielsiedlung steht unter Anfängerschutz. "; } else { if (beginner_isCaveProtectedByID($caveID, $db)) { $msg = "*#\$@*#\$%: Ihre Siedlung steht unter Anfängerschutz. " . "Sie können den Schutz sofort unter dem Punkt Bericht: Alle " . "meine Siedlungen beenden"; } else { if ($params->POST->movementID == 6 && cave_isCaveSecureByCoord($targetXCoord, $targetYCoord, $db)) { $msg = "*#\$@*#\$%: Sie können diese Siedlung nicht übernehmen. " . "Sie ist gegen Übernahmen geschützt."; } else { if (FARMSCHUTZ_ACTIVE == 1 && ($params->POST->movementID == 3 || $params->POST->movementID == 6) && $farmschutz == 1) { $msg = "*#\$@*#\$%: Der Spieler steht unter Farmschutz. Sie können ihn nicht angreifen."; } else { if (FARMSCHUTZ_ACTIVE == 1 && ($params->POST->movementID == 3 || $params->POST->movementID == 6) && $farmschutz == 2) { $msg = "*#\$@*#\$%: Sie stehen unter Farmschutz. Dieser Spieler ist zu groß zum angreifen."; } else { // Entfernung x Dauer pro Höhle x größter Geschwindigkeitsfaktor x Bewegungsfaktor $duration = ceil(getDistanceByCoords($details['xCoord'], $details['yCoord'], $targetXCoord, $targetYCoord) * $minutesPerCave * getMaxSpeedFactor($unit) * $ua_movements[$movementID]->speedfactor * (1 + $details[$effectTypeList[25]->dbFieldName])); // Dauer x Rationen x Größe einer Ration x Bewegungsfaktor $reqFood = ceil($duration * calcRequiredFood($unit) * $foodPerCave * $ua_movements[$movementID]->foodfactor); if ($details[$resourceTypeList[$FUELRESOURCEID]->dbFieldName] < $reqFood) { $msg = "*#\$@*#\$%: Nicht genug Nahrung zum Ernähren der Krieger auf ihrem langen Marsch vorhanden!!"; } else { $msgID = setMovementEvent($caveID, $details, $targetXCoord, $targetYCoord, $unit, $resource, $movementID, $reqFood, $duration, $moveArtefact, $minutesPerCave * $ua_movements[$movementID]->speedfactor); switch ($msgID) { case 0: $msg = "Die Krieger wurden losgeschickt und haben {$reqFood} Nahrung mitgenommen!"; break; case 1: $msg = "*#\$@*#\$%: In diesen Koordinaten liegt keine Siedlung!"; break; case 2: $msg = "*#\$@*#\$%: Für diese Bewegung sind nicht genügend Einheiten/Rohstoffe verfügbar!"; break; case 3: $msg = "Schwerer *#\$@*#\$%: Bitte Admin kontaktieren!"; } } } } } } } } } } } } } else { if (!empty($params->POST->eventID)) { $msgID = reverseMovementEvent($caveID, $params->POST->eventID); switch ($msgID) { case 0: $msg = "Die Einheiten kehren zurück!"; break; case 1: $msg = "*#\$@*#\$%: Fehler bei der Rückkehr!"; break; } } } // refresh this cave $temp = getCaveSecure($caveID, $params->SESSION->user['playerID']); $meineHoehlen[$caveID] = $details = $temp->nextRow(MYSQL_ASSOC); // make sure that bagged artefacts are not shown again if ($moveArtefact != 0) { $myartefacts = artefact_getArtefactsReadyForMovement($caveID); } // ////////////////////////////////////////////////////////////// // Create the page // ////////////////////////////////////////////////////////////// $template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/unitaction.ihtml"); // messages if (isset($msg)) { tmpl_set($template, '/MESSAGE/msg', $msg); } // javascript support tmpl_set($template, 'currentX', $details['xCoord']); tmpl_set($template, 'currentY', $details['yCoord']); tmpl_set($template, 'dim_x', $dim_x); tmpl_set($template, 'dim_y', $dim_y); tmpl_set($template, 'speed', $minutesPerCave); tmpl_set($template, 'movementcostconstant', $foodPerCave); tmpl_set($template, "resourceTypes", $MAX_RESOURCE); tmpl_set($template, "movement_speed_factor", $details[$effectTypeList[25]->dbFieldName]); // ADDED by chris--- for movement_speed_factor // ADDED by chris--- for cavebook: tmpl_set($template, 'show_book_modus', CAVE_BOOK); // Getting entries $cavelist = cavebook_getEntries($params->SESSION->user['playerID']); // Show the cave table for ($i = 0; $i < sizeof($cavelist[id]); $i++) { $cavename = $cavelist[name][$i]; // the current cavename $cavebookID = $cavelist[id][$i]; $cave_x = $cavelist[x][$i]; $cave_y = $cavelist[y][$i]; tmpl_iterate($template, '/BOOKENTRY'); tmpl_set($template, 'BOOKENTRY/book_entry', $cavename); tmpl_set($template, 'BOOKENTRY/book_id', $cavebookID); tmpl_set($template, 'BOOKENTRY/book_x', $cave_x); tmpl_set($template, 'BOOKENTRY/book_y', $cave_y); tmpl_iterate($template, '/BOOKENTRYJS'); tmpl_set($template, 'BOOKENTRYJS/book_entry', unhtmlentities($cavename)); tmpl_set($template, 'BOOKENTRYJS/book_id', $cavebookID); tmpl_set($template, 'BOOKENTRYJS/book_x', $cave_x); tmpl_set($template, 'BOOKENTRYJS/book_y', $cave_y); } // movements $selectable_movements = array(); foreach ($ua_movements as $value) { if ($value->playerMayChoose) { $selectable_movements[] = get_object_vars($value); } } tmpl_set($template, 'SELECTACTION', $selectable_movements); // resources $resources = array(); for ($res = 0; $res < sizeof($resourceTypeList); $res++) { $resources[] = array('resourceID' => $resourceTypeList[$res]->resourceID, 'name' => $resourceTypeList[$res]->name, 'currentAmount' => "0" + $details[$resourceTypeList[$res]->dbFieldName], 'dbFieldName' => $resourceTypeList[$res]->dbFieldName); } tmpl_set($template, 'RESOURCE', $resources); tmpl_set($template, 'TOTAL', $resources); tmpl_set($template, 'RESOURCE_LUGGAGE', $resources); // units table $unitprops = array(); $units = array(); $unitsAll = array(); // ADDED by chris--- for ($i = 0; $i < sizeof($unitTypeList); $i++) { // if no units of this type, next type if (!$details[$unitTypeList[$i]->dbFieldName]) { continue; } $temp = array(); $encumbrance = array(); for ($j = 0; $j < count($resourceTypeList); $j++) { $encumbrance[$j] = array('resourceID' => $j, 'load' => "0" + $unitTypeList[$i]->encumbranceList[$j]); $temp[] = "0" + $unitTypeList[$i]->encumbranceList[$j]; } $unitprops[] = array('unitID' => $unitTypeList[$i]->unitID, 'foodCost' => $unitTypeList[$i]->foodCost, 'speedFactor' => $unitTypeList[$i]->wayCost, 'resourceLoad' => implode(",", $temp)); $units[] = array('name' => $unitTypeList[$i]->name, 'modus' => UNIT_PROPERTIES, 'unitID' => $unitTypeList[$i]->unitID, 'foodCost' => $unitTypeList[$i]->foodCost, 'speedFactor' => $unitTypeList[$i]->wayCost, 'maxWarriorAnzahl' => $details[$unitTypeList[$i]->dbFieldName], 'warriorID' => $i, 'ENCUMBRANCE' => $encumbrance); $unitAnzahl = sizeof($units); } tmpl_set($template, 'UNITPROPS', $unitprops); tmpl_set($template, 'SELECTWARRIOR', $units); tmpl_set($template, '/unitAnzahl', $unitAnzahl); // weitergereichte Koordinateny if (empty($params->POST->movementID)) { tmpl_set($template, 'targetXCoord', $params->POST->targetXCoord); tmpl_set($template, 'targetYCoord', $params->POST->targetYCoord); tmpl_set($template, 'targetCaveName', $params->POST->targetCaveName); } // weitere Paramter $hidden = array(array('name' => 'modus', 'value' => MOVEMENT), array('name' => 'moveit', 'value' => 'true'), array('name' => 'trigger', 'value' => 'self'), array('name' => 'tstamp', 'value' => "" . time())); tmpl_set($template, 'PARAMS', $hidden); $movements = digest_getMovements(array($caveID => $details), array(), true); //$movements = digest_getMovements($meineHoehlen, array(), true); foreach ($movements as $move) { if ($move['isOwnMovement']) { if (isCaveInvisibleToPlayer($move['target_caveID'], $params->SESSION->user['playerID'], $db)) { $move['target_player_tribe'] = ""; $move['target_player_name'] = ""; } tmpl_iterate($template, 'MOVEMENT/MOVE'); tmpl_set($template, 'MOVEMENT/MOVE', $move); } else { tmpl_iterate($template, 'OPPMOVEMENT/MOVE'); tmpl_set($template, 'OPPMOVEMENT/MOVE', $move); } } // artefakte if (sizeof($myartefacts) != 0) { tmpl_set($template, '/ARTEFACTS/ARTEFACT', $myartefacts); } return tmpl_parse($template); }