%PDF- %PDF-
Direktori : /www/varak.net/www.varak.net/sig/ |
Current File : /www/varak.net/www.varak.net/sig/arena_matchup.php |
<? /******************************************************************************* Copyright (c) 2007, Chris Heald. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * You are free to use this software in any commercial or non-commercial capacity you wish, provided that the following conditions are met: 1) The original author and any contributors are given visible credit for the tool on each page of the tool and on pages generated by the tool. If your tool does not generate visible pages, then simply place a comment with appropriate credit in your code. 2) You make a good-faith effort to contribute modifications, contributions, and changes to this tool back to the community by releasing them under a license similar to this one. This is non-binding, but is greatly appreciated. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************************/ session_start(); include("_armory.php"); $xmlDataCache = array(); ini_set("user_agent", "Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.2"); function getTeamData($base_url, $realm, $teamsize, $team) { $members = getTeamMembers($base_url, $realm, $teamsize, $team); $emblem = getTeamEmblem($base_url, $realm, $teamsize, $team); $info = getTeamInfo($base_url, $realm, $teamsize, $team); return array($info, $members, $emblem); } function getFirstAttrib($x, $p, $a) { $hps = $x->xpath($p); if(!$hps) return 0; $hpa = attribs($hps[0]); return $hpa[$a]; } function getCharacterCrit($data) { $paths = array( "/page/characterInfo/characterTab/spell/critChance/arcane", "/page/characterInfo/characterTab/spell/critChance/nature", "/page/characterInfo/characterTab/spell/critChance/shadow", "/page/characterInfo/characterTab/spell/critChance/holy", "/page/characterInfo/characterTab/spell/critChance/first", "/page/characterInfo/characterTab/spell/critChance/frost", "/page/characterInfo/characterTab/ranged/critChance", "/page/characterInfo/characterTab/melee/critChance" ); $maxCrit = -1; foreach($paths as $path) { $crit = getFirstAttrib($data, $path, "percent"); if($crit > $maxCrit) $maxCrit = $crit; } return $maxCrit; } function getCharacterDamage($data) { $classID = getFirstAttrib($data, "/page/characterInfo/character", "classId"); $paths = array( "/page/characterInfo/characterTab/spell/bonusDamage/arcane", "/page/characterInfo/characterTab/spell/bonusDamage/holy", "/page/characterInfo/characterTab/spell/bonusDamage/shadow", "/page/characterInfo/characterTab/spell/bonusDamage/first", "/page/characterInfo/characterTab/spell/bonusDamage/frost", "/page/characterInfo/characterTab/spell/bonusDamage/nature", ); $maxDamage = -1; foreach($paths as $path) { $damage = getFirstAttrib($data, $path, "value"); if($damage > $maxDamage) $maxDamage = $damage; } $paths = array( "/page/characterInfo/characterTab/melee/power", "/page/characterInfo/characterTab/ranged/power", ); $maxAP = -1; foreach($paths as $path) { $ap = getFirstAttrib($data, $path, "effective"); if($ap > $maxAP) $maxAP = $ap ; } return array($maxAP, $maxDamage); } function writeTeamStats($f, $team) { fwrite($f, "<table align='center' class='stats'>"); fwrite($f, "<tr><td class='l'>Rating:</td><td>" . $team[0]["rating"] . "</td></tr>"); fwrite($f, "<tr><td class='l'>Ranking:</td><td>" . $team[0]["ranking"] . "</td></tr>"); fwrite($f, "<tr><td class='l'>Win Ratio:</td><td>" . @number_format($team[0]["seasonGamesWon"] / $team[0]["seasonGamesPlayed"] * 100, 2) . "%</td></tr>"); fwrite($f, "</table>"); } function writeTeamTable($base_url, $f, $team) { fwrite($f, "<table border='1'><tr class='sorthead'>"); $headers = array("Name", "Class", "Spec", "HP", "Resilience", "Crit", "AP", "+Damage"); foreach($headers as $header) { fwrite($f, "<th>$header</th>"); } fwrite($f, "</tr>"); foreach($team[1] as $member) { $attribs = attribs($member); $data = getCharacterData($base_url, $attribs["realm"], $attribs["name"]); $d["Name"] = "<a href=\"$base_url/character-sheet.xml?r=$attribs[realm]&n=$attribs[name]\">$attribs[name]</a>"; $d["Class"] = $attribs["class"]; $d["Spec"] = getFirstAttrib($data, "/page/characterInfo/characterTab/talentSpec", "treeOne") . "/" . getFirstAttrib($data, "/page/characterInfo/characterTab/talentSpec", "treeTwo") . "/" . getFirstAttrib($data, "/page/characterInfo/characterTab/talentSpec", "treeThree"); $attribs["treeOne"] . "/" . $attribs["treeTwo"] . "/" . $attribs["treeThree"]; $d["HP"] = getFirstAttrib($data, "/page/characterInfo/characterTab/characterBars/health", "effective"); $d["Resilience"] = getFirstAttrib($data, "/page/characterInfo/characterTab/defenses/resilience", "value"); $d["Crit"] = getCharacterCrit($data); $dmg = getCharacterDamage($data); $d["AP"] = $dmg[0]; $d["+Damage"] = $dmg[1]; fwrite($f, "<tr>"); foreach($headers as $i => $header) { $c = $header == "Class" ? $d[$header] : ""; fwrite($f, "<td class='t$i $c'>$d[$header]</td>"); } fwrite($f, "</tr>"); } fwrite($f, "</table>\n"); } function writeComparisonTable($base_url, $battlegroup, $teamsize, $team1, $team2) { $size = strtolower(preg_replace("/[^a-zA-Z0-9]/", "-", $teamsize)); $bits = array( strtolower(preg_replace("/[^a-zA-Z0-9]/", "-", $battlegroup)), $size . "v" . $size, strtolower(preg_replace("/[^a-zA-Z0-9]/", "-", $team1[0]["name"])), "vs", strtolower(preg_replace("/[^a-zA-Z0-9]/", "-", $team2[0]["name"])), ); $filename = join("-", $bits) . ".html"; $file = fopen("arena_out/$filename", "w"); $team1_name = $team1[0]["name"]; $team2_name = $team2[0]["name"]; $battlegroup = $team1[0]["battleGroup"]; $size = $teamsize . "v" . $teamsize; fwrite($file, " <html> <head> <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'> <title>Arena Comparison: $team1_name vs $team2_name ($battlegroup $size)</title> <script src='../static/sorttable.js'></script> <script src='../static/prototype.js'></script> <script src='../static/tooltip.js'></script> <link rel='stylesheet' type='text/css' href='../static/arena.css' /> </head> <body> "); fwrite($file, "<h1>Arena Comparison: $team1_name vs $team2_name ($battlegroup $size)</h1><h3>Last Updated: " . strftime("%Y/%m/%d %T %z") . "</h3>\n"); $id1_a = attribs($team1[2]); $id1 = $id1_a["iconStyle"]; $id2_a = attribs($team2[2]); $id2 = $id2_a["iconStyle"]; fwrite($file, " <table id='main'> <tr> <th class='h'><div class='em'><img src='http://wowarmory.com/images/icons/team/pvp-banner-emblem-" . $id1 . ".png' /></div> $team1_name</th> <th class='h h2'>vs</th></th> <th class='h'><div class='em em2'><img src='http://eu.wowarmory.com/images/icons/team/pvp-banner-emblem-" . $id2 . ".png' /></div> $team2_name</th> </tr> "); fwrite($file, "<tr><td valign='top'>"); writeTeamStats($file, $team1); fwrite($file, "</td><td class='h2'> </td><td>"); writeTeamStats($file, $team2); fwrite($file, "</td></tr>\n"); fwrite($file, "<tr><td valign='top'>"); writeTeamTable($base_url, $file, $team1); fwrite($file, "</td><td class='h2'> </td><td valign='top'>"); writeTeamTable($base_url, $file, $team2); fwrite($file, "</td></tr>\n"); fwrite($file, " </table> "); fwrite($file, "<!-- please leave this credit notice intact. I worked very hard on these tools. :) //-->"); fwrite($file, "<p />Generated by Antiarc's Armory Tools at <a href='http://wow.tachyonsix.com/armory/'>http://wow.tachyonsix.com/armory</a>.\n"); fwrite($file, "</body></html>"); fclose($file); echo "<h3>Summary complete. Please see results at <a href=\"arena_out/$filename\">$filename</a>. Please link to the HTML file rather than this script when sharing the results.</h3>"; } function processPostData() { if(@$_REQUEST["realm"] && @$_REQUEST["team1"] && @$_REQUEST["team2"]) { $_SESSION["gen_id"] = false; $base_url = "http://wowarmory.com"; if(@$_REQUEST["loc"] == "EU") $base_url = "http://eu.wowarmory.com"; try { $team1 = getTeamData($base_url, $_REQUEST["realm"], $_REQUEST["teamsize"], $_REQUEST["team1"]); $team2 = getTeamData($base_url, $_REQUEST["realm2"], $_REQUEST["teamsize"], $_REQUEST["team2"]); writeComparisonTable($base_url, $_REQUEST["realm"] . "-" . $_REQUEST["realm2"], $_REQUEST["teamsize"], $team1, $team2); } catch (Exception $e) { echo "<font style='font-weight: bold; color: #f00;'>ERROR: " . $e->getMessage() . "</font><p />"; } } } ?> <link rel="stylesheet" type="text/css" href="style.css" /> <div class="container"> <? processPostData(); $_SESSION["gen_id"] = rand(1, 100000); ?> <? include("ads/_vert_ads.php"); ?> <h3>Arena Team Comparison</h3> Enter the information below to request an arena team matchup from the Armory. Data is cached for 12 hours, so you won't get different results if you run it more often than that. <p/> For an example of the output, see <a href="arena_out/bloodlust-5v5-nurfed-vs-redonkulus.html">this page</a>. <p /> If you want to <a href="arena_out/">browse already-generated summaries</a>, you can do so as well. You might try looking here for your file if your browser seems to stall and never come back. <p /> <b>Please note that some team members may not show up: this is an issue with the Armory not reporting all team members correctly. There isn't much I can do about that.</b> <p /> <form method="get"> <table> <tr> <td align="right">Team size:</td> <td> <select name="teamsize"> <option value="2">2v2</option> <option value="3">3v3</option> <option value="5">5v5</option> </select> </td> </tr> <tr><td align="right">Team #1 Name (exact):</td><td><input type="text" name="team1"></td></tr> <tr> <td align="right">Team 1's Realm:</td><td> <input type="text" name="realm" /> </td> </tr> <tr><td align="right">Team #2 Name (exact):</td><td><input type="text" name="team2"></td></tr> <tr> <td align="right">Team 2's Realm:</td><td> <input type="text" name="realm2" /> </td> </tr> </table> <input type="radio" checked name="loc" value="US"> US <input type="radio" name="loc" value="EU"> EU<p /> <input type="hidden" name="gen_id" value="<?=$_SESSION["gen_id"] ?>"> <p /> <input type="submit" /> <p /> Please be patient. This pulls a lot of data from the WoW Armory and takes a bit to complete. </form> <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-1555148-2"; urchinTracker(); </script> <? include("_footer.php"); ?> </div> <? logReferer("ArenaMatchup"); ?>