Initial implementation of WoW display.
This commit is contained in:
parent
4a578a7e01
commit
797cbc31b9
2 changed files with 60 additions and 21 deletions
|
@ -22,7 +22,7 @@ $dataSources = array(
|
||||||
'lastfm' => 60,
|
'lastfm' => 60,
|
||||||
'sc2ranks' => 43200,
|
'sc2ranks' => 43200,
|
||||||
'steam' => 3600,
|
'steam' => 3600,
|
||||||
'wow' => 43200,
|
'wow' => 0 //43200,
|
||||||
);
|
);
|
||||||
|
|
||||||
if(file_exists($CACHE_FILE)) {
|
if(file_exists($CACHE_FILE)) {
|
||||||
|
@ -171,6 +171,18 @@ function steam() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wow() {
|
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();
|
$benchmark_start = time();
|
||||||
$characters = array(
|
$characters = array(
|
||||||
'Gaffer' => false,
|
'Gaffer' => false,
|
||||||
|
@ -188,7 +200,7 @@ function wow() {
|
||||||
// build our mutli curl request
|
// build our mutli curl request
|
||||||
$mh = curl_multi_init();
|
$mh = curl_multi_init();
|
||||||
foreach($characters as $character=>$data) {
|
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);
|
$character);
|
||||||
|
|
||||||
$characters[$character] = curl_prep($url);
|
$characters[$character] = curl_prep($url);
|
||||||
|
@ -217,17 +229,32 @@ function wow() {
|
||||||
$leastN = 1000;
|
$leastN = 1000;
|
||||||
$leastH = 1000;
|
$leastH = 1000;
|
||||||
foreach($bosses as $boss) {
|
foreach($bosses as $boss) {
|
||||||
|
if($boss->normalKills == -1) $boss->normalKills = 0;
|
||||||
if(($boss->normalKills + $boss->heroicKills) < $leastN) $leastN = $boss->normalKills + $boss->heroicKills;
|
if(($boss->normalKills + $boss->heroicKills) < $leastN) $leastN = $boss->normalKills + $boss->heroicKills;
|
||||||
if($boss->heroicKills < $leastH) $leastH = $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(
|
$characterData[$character] = array(
|
||||||
'name' => $character,
|
'name' => $character,
|
||||||
'level' => $json->level,
|
'level' => $json->level,
|
||||||
'class' => $json->class,
|
'class' => $CLASSES[$json->class],
|
||||||
'progression' => array('n' => $leastN, 'h' => $leastH),
|
'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;
|
return $characterData;
|
||||||
}
|
}
|
||||||
|
@ -270,4 +297,8 @@ function github_sort($a, $b) {
|
||||||
return strtotime($a->pushed_at) < strtotime($b->pushed_at);
|
return strtotime($a->pushed_at) < strtotime($b->pushed_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function progression_sort($a, $b) {
|
||||||
|
return $a['progression'] < $b['progression'];
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -13,7 +13,7 @@ $links = $db->query("SELECT id,url,text,status,released_date FROM wia_links WHER
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Who is Andrew?</title>
|
<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" />
|
<link rel="shortcut icon" href="favicon.ico" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -71,14 +71,14 @@ $links = $db->query("SELECT id,url,text,status,released_date FROM wia_links WHER
|
||||||
<h2>random</h2>
|
<h2>random</h2>
|
||||||
<div id="random">
|
<div id="random">
|
||||||
<?php
|
<?php
|
||||||
while($link = $links->fetch_object()) {
|
while($link = $links->fetch_object()) {
|
||||||
$link_text = $link->text;
|
$link_text = $link->text;
|
||||||
|
|
||||||
$link_text = preg_replace('/\[/','<a href="' . htmlentities($link->url) . '">',$link_text);
|
$link_text = preg_replace('/\[/','<a href="' . htmlentities($link->url) . '">',$link_text);
|
||||||
$link_text = preg_replace('/\]/','</a>',$link_text);
|
$link_text = preg_replace('/\]/','</a>',$link_text);
|
||||||
|
|
||||||
echo ' <p class="box">' . $link_text . '</p>' . "\n";
|
echo ' <p class="box">' . $link_text . '</p>' . "\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -126,14 +126,22 @@ $links = $db->query("SELECT id,url,text,status,released_date FROM wia_links WHER
|
||||||
<tr>
|
<tr>
|
||||||
<td class="gamesformatting"><a href="http://battle.net/wow"><img src="img/badges/wow.jpg" alt="World of Warcraft" /></a></td>
|
<td class="gamesformatting"><a href="http://battle.net/wow"><img src="img/badges/wow.jpg" alt="World of Warcraft" /></a></td>
|
||||||
<td class="top">
|
<td class="top">
|
||||||
<a href="http://us.battle.net/wow/en/character/crushridge/veincane/advanced">Veincane</a>,
|
<table class="classformatting">
|
||||||
<a href="http://us.battle.net/wow/en/character/crushridge/gaffer/advanced">Gaffer</a>,
|
<tr>
|
||||||
<a href="http://us.battle.net/wow/en/character/crushridge/ttg/advanced">Ttg</a>,
|
<?php
|
||||||
<a href="http://us.battle.net/wow/en/character/crushridge/getburnt/advanced">Getburnt</a>,
|
foreach($data->wow as $character) {
|
||||||
<a href="http://us.battle.net/wow/en/character/crushridge/levita/advanced">Levita</a>,
|
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);
|
||||||
<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/>
|
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue