@ 2015-08-29T00:34:12Z <?php
class ChampionGG {
private $manaless = array("Aatrox", "DrMundo", "Mordekaiser", "Vladimir", "Zac", "Akali", "Kennen", "LeeSin", "Shen",
"Zed", "Garen", "Gnar", "Katarina", "RekSai", "Renekton", "Rengar", "Riven", "Rumble",
"Shyvana", "Tryndamere", "Yasuo");
public function getAllSets() {
echo "Creating item sets for all champions...\n";
$time = time();
$saveFolder = $time . "_ItemSets";
$page = $this->getPage("http://champion.gg/");
preg_match_all('/<a href="([^"]*)" style="display:block">/si', $page, $list);
foreach ($list[1] as $champPage) {
$data = explode("/", $champPage);
$champ = $data[2];
$role = $data[3];
$this->getOneSet($champ, $role, $saveFolder, $time);
}
echo "Complete!\n";
return true;
}
public function getOneSet($champ, $role, $saveFolder = null, $time = null) {
if ($time == null) {
$time = time();
}
$url = "http://champion.gg/champion/" . $champ . "/" . $role;
$page = $this->getPage($url);
$data = $this->getBetween($page, "matchupData.championData = ", "matchupData.patchHistory");
$data = trim($data);
$data = trim($data, ";");
$champJSON = json_decode($data, true);
$currentPatch = $this->getBetween(str_replace(array("\n", " "), "", $page), "<small>Patch<strong>", "</strong>");
$firstMG = $champJSON["firstItems"]["mostGames"];
$firstHWP = $champJSON["firstItems"]["highestWinPercent"];
$fullMG = $champJSON["items"]["mostGames"];
$fullHWP = $champJSON["items"]["highestWinPercent"];
$skillsMG = $champJSON["skills"]["mostGames"];
$skillsHWP = $champJSON["skills"]["highestWinPercent"];
if (!isset($firstMG["games"], $firstHWP["games"], $fullMG["games"], $fullHWP["games"])) {
echo "Woops, full data is unavailable for " . $champ . " in " . $role . " role\n";
file_put_contents($time . "_Unavailable.txt", "* " . $champ . " - " . $role . " role\n", FILE_APPEND);
return false;
}
$consumeItems = array(2003, 2004, 2044, 2043, 2041, 2138, 2137, 2139, 2140);
$trinketItems = array(3340, 3341, 3342);
if (in_array($champ, $this->manaless)) {
unset($consumeItems[1]);
}
$skillsItems1 = array(3361, 3362, 2003 /* health pot needed here so it works in other maps */);
$skillsItems2 = array(3364, 3363, 2003);
$skillsItemsComb = array(3361, 3362, 3364, 3363, 2003);
$firstMGItems = array_merge($this->getItems($firstMG), $this->getItems($trinketItems, true));
$firstHWPItems = array_merge($this->getItems($firstHWP), $this->getItems($trinketItems, true));
$fullMGItems = $this->getItems($fullMG);
$fullHWPItems = $this->getItems($fullHWP);
$firstMGBlock = array(
"items" => $firstMGItems,
"type" => "Most Frequent Starters (" . $firstMG["winPercent"] . "% win - " . $firstMG["games"] . " games)"
);
$firstHWPBlock = array(
"items" => $firstHWPItems,
"type" => "Highest Win Rate Starters (" . $firstHWP["winPercent"] . "% win - " . $firstHWP["games"] . " games)"
);
$fullMGBlock = array(
"items" => $fullMGItems,
"type" => "Most Frequent Build (" . $fullMG["winPercent"] . "% win - " . $fullMG["games"] . " games)"
);
$fullHWPBlock = array(
"items" => $fullHWPItems,
"type" => "Highest Win Rate Build (" . $fullHWP["winPercent"] . "% win - " . $fullHWP["games"] . " games)"
);
$consumeBlock = array(
"items" => $this->getItems($consumeItems, true),
"type" => "Consumables"
);
$skillsMGOrder = $this->getSkills($skillsMG);
$skillsHWPOrder = $this->getSkills($skillsHWP);
$skillsMGBlock = array(
"items" => $this->getItems($skillsItems1, true),
"type" => $skillsMGOrder . " (" . $skillsMG["winPercent"] . "% win - " . $skillsMG["games"] . " games)"
);
$skillsHWPBlock = array(
"items" => $this->getItems($skillsItems2, true),
"type" => $skillsHWPOrder . " (" . $skillsHWP["winPercent"] . "% win - " . $skillsHWP["games"] . " games)"
);
$roleFormatted = substr($champJSON["role"], 0, 1) . substr(strtolower($champJSON["role"]), 1);
$itemSetArr = array(
"map" => "any",
"isGlobalForChampions" => false,
"blocks" => array(
$firstMGBlock,
$firstHWPBlock,
$fullMGBlock,
$fullHWPBlock,
$consumeBlock,
$skillsMGBlock,
$skillsHWPBlock
),
"associatedChampions" => array(),
"title" => $roleFormatted . " " . $currentPatch,
"priority" => false,
"mode" => "any",
"isGlobalForMaps" => true,
"associatedMaps" => array(),
"type" => "custom",
"sortrank" => 1,
"champion" => $champJSON["key"]
);
if ($skillsMGOrder == $skillsHWPOrder) {
array_pop($itemSetArr["blocks"]);
$itemSetArr["blocks"][5]["items"] = $this->getItems($skillsItemsComb, true);
}
if ($firstMGItems == $firstHWPItems) {
unset($itemSetArr["blocks"][1]);
}
if ($fullMGItems == $fullHWPItems) {
unset($itemSetArr["blocks"][3]);
}
$itemSetArr["blocks"] = array_values($itemSetArr["blocks"]);
if ($saveFolder == null) {
$saveFolder = $champJSON["key"] . "/Recommended";
}
else {
$saveFolder = $saveFolder . "/" . $champJSON["key"] . "/Recommended";
}
if (!file_exists($saveFolder)) {
mkdir($saveFolder, 0777, true);
}
$fileName = str_replace(".", "_", $currentPatch) . "_" . $roleFormatted . ".json";
$fileName = $saveFolder . "/" . $fileName;
$itemSetJSON = json_encode($itemSetArr, JSON_PRETTY_PRINT);
file_put_contents($fileName, $itemSetJSON);
echo "Saved set for " . $champ . " in " . $role . " role to: " . $fileName . "\n";
return true;
}
private function getSkills($array) {
$skillStr = "";
foreach ($array["order"] as $index => $skill) {
$level = $index + 1;
$skill = strtr($skill, array(
"1" => "Q",
"2" => "W",
"3" => "E",
"4" => "R"
));
if ($level == 6 || $level == 12) {
$skill .= " > ";
}
$skillStr .= $skill;
}
return $skillStr;
}
private function getItems($array, $fromPreset = false) {
$items = array();
if ($fromPreset) {
foreach ($array as $item) {
$items[] = array(
"count" => 1,
"id" => (string) $item
);
}
}
else {
$itemIDs = array();
foreach ($array["items"] as $item) {
$id = $item["id"];
if ($id == 2010) {
$id = 2003;
}
if (isset($itemIDs[$id])) {
$itemIDs[$id]++;
}
else {
$itemIDs[$id] = 1;
}
}
foreach ($itemIDs as $itemID => $count) {
$items[] = array(
"count" => $count,
"id" => (string) $itemID
);
}
}
return $items;
}
private function getBetween($content, $start, $end){
$r = explode($start, $content);
if (isset($r[1])) {
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
private function getPage($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18");
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
return $data;
}
}
$champ = new ChampionGG();
//$champ->getOneSet("Bard", "Support");
$champ->getAllSets();
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.3.1 0.011 0.003 16.31 7.3.0 0.000 0.011 16.52 7.2.13 0.006 0.006 16.59 7.2.12 0.000 0.011 16.85 7.2.11 0.011 0.004 16.82 7.2.10 0.003 0.006 16.42 7.2.9 0.009 0.003 16.77 7.2.8 0.006 0.007 16.68 7.2.7 0.007 0.003 16.88 7.2.6 0.006 0.009 16.78 7.2.5 0.006 0.006 16.84 7.2.4 0.022 0.000 16.77 7.2.3 0.006 0.006 16.68 7.2.2 0.003 0.010 16.48 7.2.1 0.006 0.003 16.93 7.2.0 0.005 0.009 18.18 7.1.25 0.007 0.013 15.51 7.1.20 0.000 0.016 15.80 7.1.10 0.000 0.014 18.13 7.1.7 0.000 0.008 17.07 7.1.6 0.003 0.021 19.42 7.1.5 0.010 0.007 16.84 7.1.0 0.003 0.073 22.31 7.0.20 0.000 0.009 16.48 7.0.10 0.013 0.067 20.11 7.0.9 0.010 0.043 20.01 7.0.8 0.013 0.063 20.11 7.0.7 0.007 0.087 20.11 7.0.6 0.010 0.053 20.02 7.0.5 0.007 0.087 20.54 7.0.4 0.007 0.083 20.10 7.0.3 0.010 0.043 20.15 7.0.2 0.017 0.070 20.09 7.0.1 0.010 0.090 20.14 7.0.0 0.010 0.053 20.07 5.6.28 0.007 0.047 21.07 5.6.25 0.013 0.060 20.68 5.6.24 0.013 0.043 20.68 5.6.23 0.007 0.083 20.76 5.6.22 0.003 0.083 20.74 5.6.21 0.010 0.080 20.69 5.6.20 0.007 0.067 21.23 5.6.19 0.007 0.063 21.13 5.6.18 0.003 0.053 21.11 5.6.17 0.013 0.077 21.15 5.6.16 0.007 0.043 21.20 5.6.15 0.007 0.090 21.10 5.6.14 0.013 0.050 21.17 5.6.13 0.017 0.070 21.19 5.6.12 0.007 0.077 21.21 5.6.11 0.013 0.070 21.17 5.6.10 0.003 0.080 21.19 5.6.9 0.007 0.083 21.10 5.6.8 0.010 0.033 20.52 5.6.7 0.007 0.080 20.63 5.6.6 0.007 0.073 20.41 5.6.5 0.010 0.077 20.51 5.6.4 0.007 0.077 20.38 5.6.3 0.007 0.073 20.54 5.6.2 0.010 0.083 20.45 5.6.1 0.010 0.073 20.44 5.6.0 0.003 0.047 20.49 5.5.38 0.000 0.087 20.49 5.5.37 0.020 0.033 20.60 5.5.36 0.010 0.037 20.40 5.5.35 0.000 0.087 20.52 5.5.34 0.013 0.080 20.86 5.5.33 0.010 0.080 20.99 5.5.32 0.003 0.050 20.92 5.5.31 0.003 0.050 20.86 5.5.30 0.007 0.050 20.98 5.5.29 0.013 0.073 20.82 5.5.28 0.010 0.057 20.88 5.5.27 0.003 0.053 20.88 5.5.26 0.017 0.077 20.82 5.5.25 0.020 0.073 20.79 5.5.24 0.010 0.077 20.37 5.5.23 0.010 0.057 20.33 5.5.22 0.007 0.077 20.25 5.5.21 0.010 0.047 20.36 5.5.20 0.003 0.083 20.12 5.5.19 0.007 0.050 20.25 5.5.18 0.010 0.043 20.27 5.5.16 0.003 0.080 20.19 5.5.15 0.003 0.080 20.32 5.5.14 0.003 0.083 20.34 5.5.13 0.013 0.073 20.30 5.5.12 0.003 0.040 20.30 5.5.11 0.007 0.063 20.21 5.5.10 0.007 0.077 20.18 5.5.9 0.010 0.033 20.23 5.5.8 0.003 0.083 20.13 5.5.7 0.003 0.090 20.12 5.5.6 0.000 0.053 20.18 5.5.5 0.013 0.063 20.13 5.5.4 0.007 0.040 20.17 5.5.3 0.017 0.077 20.21 5.5.2 0.003 0.047 20.16 5.5.1 0.007 0.077 20.14 5.5.0 0.003 0.050 20.17 5.4.45 0.010 0.083 19.46 5.4.44 0.000 0.053 19.54 5.4.43 0.010 0.043 19.35 5.4.42 0.020 0.070 19.21 5.4.41 0.003 0.047 19.31 5.4.40 0.010 0.077 19.24 5.4.39 0.003 0.083 19.12 5.4.38 0.003 0.080 19.09 5.4.37 0.007 0.050 19.09 5.4.36 0.000 0.080 19.19 5.4.35 0.007 0.063 19.18 5.4.34 0.017 0.067 18.85 5.4.32 0.017 0.053 19.13 5.4.31 0.013 0.070 19.05 5.4.30 0.010 0.067 19.02 5.4.29 0.017 0.063 19.07 5.4.28 0.010 0.050 18.96 5.4.27 0.007 0.063 18.89 5.4.26 0.010 0.087 19.21 5.4.25 0.010 0.040 19.11 5.4.24 0.007 0.070 19.12 5.4.23 0.003 0.077 19.06 5.4.22 0.007 0.083 19.15 5.4.21 0.010 0.063 19.12 5.4.20 0.000 0.073 18.82 5.4.19 0.017 0.070 19.02 5.4.18 0.007 0.053 19.12 5.4.17 0.017 0.070 19.18 5.4.16 0.010 0.073 19.00 5.4.15 0.003 0.050 19.00 5.4.14 0.010 0.053 16.34 5.4.13 0.003 0.070 16.43 5.4.12 0.010 0.040 16.42 5.4.11 0.003 0.080 16.56 5.4.10 0.003 0.077 16.40 5.4.9 0.007 0.047 16.56 5.4.8 0.013 0.060 16.54 5.4.7 0.013 0.070 16.39 5.4.6 0.003 0.077 16.31 5.4.5 0.003 0.073 16.46 5.4.4 0.007 0.070 16.46 5.4.3 0.010 0.073 16.52 5.4.2 0.003 0.077 16.43 5.4.1 0.023 0.063 16.51 5.4.0 0.003 0.077 15.86
preferences:dark mode live preview
39.04 ms | 401 KiB | 5 Q