$h1_full ?? [], 2 => $h2_full ?? [], 3 => $h3_full ?? [], 5 => $h5_full ?? [], 6 => $h6_full ?? [], 11 => $h11_full ?? [], 12 => $h12_full ?? [], 13 => $h13_full ?? [], 15 => $h15_full ?? [], 16 => $h16_full ?? [], 21 => $h21_full ?? [], 22 => $h22_full ?? [], 24 => $h24_full ?? [], 25 => $h25_full ?? [], 26 => $h26_full ?? [], ]; // The "can be resurrected" line was duplicated identically in the original: one version // for the base unit of the tribe (without research check) and one for // the rest of the units (with research check) - but the generated HTML was byte-for-byte // the same. Extracted here once, called from both branches below. $renderReviveRow = function ($hero_datarow, $name, $wood, $clay, $iron, $crop, $training_time, $id) use ($session, $building, $village) { $total_required = (int) ($wood + $clay + $iron + $crop); $html = ""; $html .= ""; $html .= ""; $html .= ""; return $html; }; // check if there is a hero in revive already $reviving = $training = false; foreach ($heroes as $hero_datarow) { if ($hero_datarow['inrevive']) { $reviving = true; } if ($hero_datarow['intraining']) { $training = true; } $name = $technology->getUnitName($hero_datarow['unit']); // Collapsed the two branches (level <= 60 / level > 60) that differed // only by the key used in the lookup (current level vs. ceiling 60) - // same result, without duplicating the 5 calculation lines. $levelKey = ($hero_datarow['level'] <= 60) ? $hero_datarow['level'] : 60; $heroLevelData = $heroFullData[$hero_datarow['unit']][$levelKey]; $wood = $heroLevelData['wood']; $clay = $heroLevelData['clay']; $iron = $heroLevelData['iron']; $crop = $heroLevelData['crop']; $timeToTrain = $database->getArtifactsValueInfluence($session->uid, $village->wid, 5, $heroLevelData['time'] / SPEED); $training_time = $generator->getTimeFormat($timeToTrain); $training_time2 = time() + $timeToTrain; if ($hero_datarow['inrevive'] == 1) { $timeleft = $generator->getTimeFormat($hero_datarow['trainingtime'] - time()); ?>
"; $html .= "
"; $html .= "\"""; $html .= $name . " (Level " . $hero_datarow['level'] . ")"; $html .= "
"; $html .= "
"; $html .= "\""" . $wood . "|"; $html .= "\""" . $clay . "|"; $html .= "\""" . $iron . "|"; $html .= "\""" . $crop . "|"; $html .= "\"Crop6|"; $html .= "\"""; $html .= $training_time; //-- If available resources combined are not enough, remove NPC button if ($session->userinfo['gold'] >= 3 && $building->getTypeLevel(17) >= 1 && $village->atotal >= $total_required) { $html .= "|\"NPC"; } $html .= "
"; $html .= "
"; if ($village->awood < $wood || $village->aclay < $clay || $village->airon < $iron || $village->acrop < $crop) { $html .= "" . NOT . "" . ENOUGH_RESOURCES . ""; } else { $html .= "" . REVIVE . ""; } $html .= "
"; ?>
".HERO_READY." timer.">".$timeleft."
\"".$name."\" $name ($name1)
" ?>
checkIfResearched($village->wid, 't' . $hero_datarow['unit']) != 0) { echo $renderReviveRow($hero_datarow, $name, $wood, $clay, $iron, $crop, $training_time, $id); } } } if (isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1) { mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `inrevive` = '1', `trainingtime` = '" . (int) $training_time2 . "', `wref` = '" . (int) $village->wid . "' WHERE `heroid` = " . (int) $_GET['hid'] . " AND `uid` = '" . (int) $session->uid . "'"); $database->modifyResource($village->wid, $wood, $clay, $iron, $crop, 0); header("Location: build.php?id=" . $id . ""); exit; } } ?>