Skip to content

Instantly share code, notes, and snippets.

@binaryatrocity
Created May 14, 2014 03:24
Show Gist options
  • Save binaryatrocity/d8c4660394dc6acce7c6 to your computer and use it in GitHub Desktop.
Save binaryatrocity/d8c4660394dc6acce7c6 to your computer and use it in GitHub Desktop.
Dota Item Tooltips (too old)
<?php
$id = $_POST['id'];
$type = $_POST['ttt'];
if(isset($type) && isset($id))
{
switch($type)
{
case 'item':
getItem($id);
break;
case 'hero':
getHero($id);
break;
case 'skill':
getSkill($id);
break;
}
}
function getItem($id)
{
/* Database fun */
$con = new mysqli('localhost', 'hwlnet_dota2', 'RqnLuL4N[WS4', 'hwlnet_dota2');
if($con->connect_errno) {
printf("SQL Connection Error %s\n", mysqli_connect_error());
exit;
}
$result = $con->query("SELECT * FROM item_data WHERE id=". $id);
$item = $result->fetch_object();
$result->close();
$count = 0;
$res_path = "http://www.dotanoobs.com/res";
/* [EXTRACT ITEM INFO FROM DB] */
// id + name + orbs
$id = $item->id;
$name = $item->name;
$orbs = explode('#', $item->orbs);
// determine color for name
$nclass = "itemlabel";
if ( $id >= 200 && $id <= 233) { $nclass = $nclass . " common"; }
if ( $id >= 234 && $id <= 299) { $nclass = $nclass . " caster"; }
if ( $id >= 300 && $id <= 364) { $nclass = $nclass . " weapon"; }
if ( $id >= 365 && $id <= 399) { $nclass = $nclass . " artifact"; }
if ( $id >= 400 && $id <= 435) { $nclass = $nclass . " secret"; }
// stats
$stat = explode('#', $item->stats);
$stats = array();
foreach($stat as $s) {
$stats[$count] = explode(',', $s);
$count++;
}
// passive
$passive = explode('#', $item->passive);
// active
$active = explode('#', $item->active);
// shops + gold
$shops = array( $item->main_shop, $item->side_shop, $item->secret_shop );
$gold = $item->gold;
// recipe + components
$rtemp = explode('#', $item->recipe);
$recipe = array();
$count = 0;
if(isset($rtemp[1]) && $rtemp[1] != "") {
$recipe[3] = $rtemp[1];
}
$rtemp = explode(',', $rtemp[0]);
foreach($rtemp as $r) {
$recipe[$count] = $r;
$count++;
}
$build_path = explode('#', $item->build_path);
$lore = $item->lore;
/* [END ITEM EXTRACTION] */
/* [# START ITEM FORMATTING HERE #] */
echo "<div class=\"item\">";
// Display item picture
echo "<div id=\"itempic\">
<img src=\"$res_path/items/$id.png\" width=\"72\" height=\"40\" />
</div>";
// Display item name + gold value
echo " <span class=\"$nclass\" \"> $name </span><br /><br />
<img src=\"$res_path/art/gold.png\" align=\"left\" />
<span class=\"goldvalue\"> $gold</span><br /><br />";
// Displays the active ability
if (!empty($active[0])) {
echo "Active: <b>$active[0]</b> - $active[1]<br /><br />";
}
// Display passive ability
if(!empty($passive[0])) {
echo "Passive: <b>$passive[0]</b> - $passive[1]<br />";
}
// Display orbs/slow/deathdrop
if($orbs[0] == 1) {
echo "<br />$name is a Unique Attack Modifier, and does not stack with other Unique Attack Modifiers.";
if($id == 375) { echo "On ranged heroes, Eye of Skadi can be combined with Lifesteal Attack Modifiers.<br />"; } else { echo "<br />"; }
}
if($id == 310) { echo "Drops on death"; }
echo "<br />";
// Display stats list
echo "<table class=\"stattable\" cellpadding=0 cellspacing=0>";
foreach($stats as $s) {
if( !empty($s[0]) ) {
//echo "<span style=\"font-size: 14px;\"><span class=\"statnum\">" . $s[0] . "</span> " . $s[1] . "</span><br />";
echo "<tr><td class=\"statnum\">" . $s[0] . "</td><td>" . $s[1] . "</td></tr>";
}
}
echo "</table>";
// Display ability-stats
echo "<table class=\"stattable\" cellpadding=0 cellspacing=0>";
if(!empty($active[5])) {
$ablty = explode(',', $active[5]);
echo "<tr><td style=\"padding-left: 8px;\">" . strtoupper($ablty[0]) . ":</td><td class=\"statnum\"> " . $ablty[1] . "</td>";
}
if(!empty($active[6])) {
$ablty = explode(',', $active[6]);
echo "<tr><td style=\"padding-left: 8px;\">" . strtoupper($ablty[0]) . ":</td><td class=\"statnum\"> " . $ablty[1] . "</td>";
}
if(!empty($active[4])) {
echo "<tr><td style=\"padding-left: 8px;\"> DURATION: </td><td class=\"statnum\"> " . $active[4] . "</td>";
}
echo "</table><br />";
// Display manacost/cooldowns
echo "<table class=\"stattable\"><tr>";
if (!empty($active[2])) {
echo "<td class=\"cooldown\"> <img src=\"$res_path/art/time.png\" /> " . $active[2] . " </td>";
}
if (!empty($active[3])) {
echo "<td style=\"padding-left: 60px;\" class=\"cooldown\"> <img src=\"$res_path/art/mana.png\" /> " . $active[3] . " </td>";
}
echo "</tr></table>";
// Display lore
if( !empty($lore) ) {
echo "<br /><span class=\"lore\">$lore</span>";
}
echo "</div>";
$con->close();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment