View Single Post
Old 04-30-2009, 01:06 AM   #107 (permalink)
Draven21
The Visitor
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Draven21 is on a distinguished road
Default Further information from armory

I would like to thank all of the contributors to this thread. It took me a little while to get my head around all of this and for my coding skills to come back to me with lack of sleep and lots of coffee. I have used code from various posters and all credit goes to those that I have pulled code from.

I was looking for a way to display a guild list that included all of the pertinent information that any guildy would want to know about their online raid friends. The first bit was getting the list together and then pulling together information from further Blizz xml pages.

For actual raiders, they are obviously only going to be top level and usually of a certain rank within the guild. My listing will only show players of level 80 and rank 5 and above. I separated the mappings for rank/class/race etc in the event that you wanted a public and private list that displayed different information. You may not want public to see the professions, specs and so on for all of your guild members.

The layout is somewhat messy and busy but the functionality is there and it just needs some tlc on the layout through css or whatever your pleasure.

Although this lies outside the scope of this thread and perhaps the forum, this current setup I have is only a short term solution until I can put together a lighter weight version running xml/xsl but this is a little ways off yet but will be much cleaner when I work out how to do it. I want to compile pertinent information from multiple Blizz xml into another xml file basically and go from there.

This is what I have come up with - please feel free to comment or give me any tips.



*IMPORTANT*
As this code will create multiple queries for the final output, a large improperly filtered roster list can take some time to display as it will pull an extra xml file for each character in the roster that is not being filtered out. Take note for the character level and guild ranking filters that are in place so you don't end up with a supersized list. My guild has 92 members but the final list that displays is only 39 actual rostered raiders that are not alts etc. This list takes a few seconds to populate depending on your connection speed.



roster_functions.php:
PHP Code:
<?php

/*
return_class    Returns the acutal class name for a character
return_rank        Returns a rank mapping as this information is not held on the Armory
return_race        Returns Race and Sex information

*/



static $browser_user_agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";

function 
return_class($classid) {
    switch (
$classid) {
        case 
1:
            
$class "Warrior";
            break;
        case 
2:
            
$class "Paladin";
            break;
        case 
3:
            
$class "Hunter";
            break;
        case 
4:
            
$class "Rogue";
            break;
        case 
5:
            
$class "Priest";
            break;
        case 
6:
            
$class "Death Knight";
            break;
        case 
7:
            
$class "Shaman";
            break;
        case 
8:
            
$class "Mage";
            break;
        case 
9:
            
$class "Warlock";
            break;
        case 
11:
            
$class "Druid";
            break;
    }
    return 
$class;
}  

function 
return_rank($rankid) {        // Adjust the names here for the guild rank names.  0 is always the Guild owner
    
switch ($rankid) {
        case 
0:
            
$class "Guild Manager";
            break;
        case 
1:
            
$class "Guild Manager";
            break;
        case 
2:
            
$class "Bank Access";
            break;
        case 
3:
            
$class "Advisor";
            break;
        case 
4:
            
$class "Raider";
            break;
        case 
5:
            
$class "Member";
            break;
        case 
6:
            
$class "Recruit";
            break;
        case 
7:
            
$class "Alt";
            break;
    }
    return 
$class;
}  

function 
return_race($raceid$sex) {
    switch (
$raceid) {
        case 
1:
            if (
$sex == "0") {$race "Human Male";}
            if (
$sex == "1") {$race "Human Female";}
            break;
        case 
2:
            if (
$sex == "0") {$race "Orc Male";}
            if (
$sex == "1") {$race "Orc Female";}
            break;
        case 
3:
            if (
$sex == "0") {$race "Dwarf Male";}
            if (
$sex == "1") {$race "Dwarf Female";}
            break;
        case 
4:
            if (
$sex == "0") {$race "Night Elf Male";}
            if (
$sex == "1") {$race "Night Elf Female";}
            break;
        case 
5:
            if (
$sex == "0") {$race "Undead Male";}
            if (
$sex == "1") {$race "Undead Female";}
            break;
        case 
6:
            if (
$sex == "0") {$race "Tauren Male";}
            if (
$sex == "1") {$race "Tauren Female";}
            break;
        case 
7:
            if (
$sex == "0") {$race "Gnome Male";}
            if (
$sex == "1") {$race "Gnome Female";}
            break;
        case 
8:
            if (
$sex == "0") {$race "Troll Male";}
            if (
$sex == "1") {$race "Troll Female";}
            break;
        case 
10:
            if (
$sex == "0") {$race "Blood Elf Male";}
            if (
$sex == "1") {$race "Blood Elf Female";}
            break;
        case 
11:
            if (
$sex == "0") {$race "Draenei Male";}
            if (
$sex == "1") {$race "Draenei Female";}
            break;
    }
    return 
$race;
}  
?>

and roster.php:
PHP Code:
<?php
include 'roster_functions.php';

$guildurl 'http://eu.wowarmory.com/guild-info.xml?r=REALM&gn=GUILD';
$charurl 'http://eu.wowarmory.com/character-sheet.xml?';

$gch curl_init();
    
curl_setopt ($gchCURLOPT_URL$guildurl);
    
curl_setopt ($gchCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($gchCURLOPT_USERAGENT,  $browser_user_agent);

$rosterxml curl_exec($gch);  

$guildxml = new SimpleXMLElement($rosterxml);


foreach (
$guildxml->guildInfo->guild->members->children() as $char) {
    if ( 
$char['level'] < 80 ) continue;        //  Limits display to lvl 80 Chars
    
if ( $char['rank'] > ) continue;            //  Limits display to active members and above (depending on your guild ranks) 
    
$toonrace    return_race($char['raceId'], $char['genderId']);      //    Maps Race and Sex
    
$toonclass    return_class($char['classId']);          // Maps class name
    
$toonrank return_rank($char['rank']);        //    Maps guild rank name
    
    
$cch curl_init();
    
curl_setopt ($cchCURLOPT_URL$charurl $char['url']);
    
curl_setopt ($cchCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($cchCURLOPT_USERAGENT,  $browser_user_agent);

    
$charxml curl_exec($cch);
    
$detailxml = new SimpleXMLElement($charxml);
    
    
    echo 
'<b>Name:</b> <a href="' .$charurl $char['url'] .'" target="_blank">' $char['name'] . '</a> ';    //Includes an armory external link
    
echo '<b>Class:</b> ' $toonclass ' ';
    echo 
'<b>Race:</b>' $toonrace ' ';
    echo 
'<b>Rank:</b> ' $toonrank .' ';
//    echo '<b>Level:</b> ' . $char['level'] . ' ';        // Displays char level
    
echo '<b>Professions: </b> ';
        
    foreach (
$detailxml->characterInfo->characterTab->professions->children() as $profession) {
        
// Displays all of the professions and skill levels and maximums
        
echo $profession['name'] . ' (' $profession['value'] . '/' $profession['max'] .') ';
    }

    echo 
'<b>Specs: </b> ';
    foreach (
$detailxml->characterInfo->characterTab->talentSpecs->children() as $spec) {
        
// Displays all of the specs in use and their builds and names.  It is easily possible to show which one is active as well.
        
echo $spec['prim'] . '(' $spec['treeOne'] . '/' $spec['treeTwo'] . '/' $spec['treeThree'] . ')  ';
    }
    echo 
'<br>';
}  
?>
Draven21 is offline  
Reply With Quote
The Following User Says Thank You to Draven21 For This Useful Post:
miica (04-30-2009)