Initial implementation of WoW display.

This commit is contained in:
Andrew Tomaka 2011-10-14 02:54:29 -04:00
parent 4a578a7e01
commit 797cbc31b9
2 changed files with 60 additions and 21 deletions

View file

@ -22,7 +22,7 @@ $dataSources = array(
'lastfm' => 60,
'sc2ranks' => 43200,
'steam' => 3600,
'wow' => 43200,
'wow' => 0 //43200,
);
if(file_exists($CACHE_FILE)) {
@ -171,6 +171,18 @@ function steam() {
}
function wow() {
$CLASSES = array(
6 => 'deathknight',
5 => 'priest',
11 => 'druid',
4 => 'rogue',
8 => 'mage',
7 => 'shaman',
1 => 'warrior',
9 => 'warlock',
3 => 'hunter',
);
$benchmark_start = time();
$characters = array(
'Gaffer' => false,
@ -188,7 +200,7 @@ function wow() {
// build our mutli curl request
$mh = curl_multi_init();
foreach($characters as $character=>$data) {
$url = sprintf('http://us.battle.net/api/wow/character/crushridge/%s?fields=progression',
$url = sprintf('http://us.battle.net/api/wow/character/crushridge/%s?fields=progression,talents',
$character);
$characters[$character] = curl_prep($url);
@ -217,18 +229,33 @@ function wow() {
$leastN = 1000;
$leastH = 1000;
foreach($bosses as $boss) {
if($boss->normalKills == -1) $boss->normalKills = 0;
if(($boss->normalKills + $boss->heroicKills) < $leastN) $leastN = $boss->normalKills + $boss->heroicKills;
if($boss->heroicKills < $leastH) $leastH = $boss->heroicKills;
}
//find our active talent tree
$spec = null;
foreach($json->talents as $talent) {
if(isset($talent->selected)) {
$spec = $talent;
break;
}
}
$characterData[$character] = array(
'name' => $character,
'level' => $json->level,
'class' => $json->class,
'progression' => array('n' => $leastN, 'h' => $leastH),
'class' => $CLASSES[$json->class],
'progression' => $leastH > 0 ? $leastH * 100 : $leastN,
'armory' => sprintf('http://us.battle.net/wow/en/character/crushridge/%s/advanced',$character),
'spec_icon' => $talent->icon,
'spec_name' => $talent->name,
);
}
usort(&$characterData,'progression_sort');
return $characterData;
}
@ -270,4 +297,8 @@ function github_sort($a, $b) {
return strtotime($a->pushed_at) < strtotime($b->pushed_at);
}
function progression_sort($a, $b) {
return $a['progression'] < $b['progression'];
}
?>

View file

@ -13,7 +13,7 @@ $links = $db->query("SELECT id,url,text,status,released_date FROM wia_links WHER
<head>
<meta charset="utf-8" />
<title>Who is Andrew?</title>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/main.css?v=1" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
@ -126,14 +126,22 @@ $links = $db->query("SELECT id,url,text,status,released_date FROM wia_links WHER
<tr>
<td class="gamesformatting"><a href="http://battle.net/wow"><img src="img/badges/wow.jpg" alt="World of Warcraft" /></a></td>
<td class="top">
<a href="http://us.battle.net/wow/en/character/crushridge/veincane/advanced">Veincane</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/gaffer/advanced">Gaffer</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/ttg/advanced">Ttg</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/getburnt/advanced">Getburnt</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/levita/advanced">Levita</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/toppazz/advanced">Toppazz</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/toopro/advanced">Toopro</a>,
<a href="http://us.battle.net/wow/en/character/crushridge/notgaffer/advanced">Notgaffer</a>.<br/><br/>
<table class="classformatting">
<tr>
<?php
foreach($data->wow as $character) {
echo sprintf(' <td class="classformatting"><a href="%s"><img src="http://wow.zamimg.com/images/wow/icons/small/class_%s.jpg" alt="%s" /></a></td>' . "\n",$character->armory,$character->class,$character->name);
}
?>
</tr>
<tr>
<?php
foreach($data->wow as $character) {
echo sprintf(' <td class="classformatting"><img src="http://wow.zamimg.com/images/wow/icons/small/%s.jpg" alt="%s" /></td>' . "\n",$character->spec_icon,$character->class,$character->spec_name);
}
?>
</tr>
</table>
</td>
</tr>
</table>