dressingroom.php
| 1 |
<?
|
|---|---|
| 2 |
/*
|
| 3 |
$armor = DressingRoom::getArmor($xml); |
| 4 |
echo 'link <a href="'.DressingRoom::buildUrl(false).'">'.$armor."</a>\n"; |
| 5 |
echo 'image <img src="'.DressingRoom::buildUrl(true)."\" width='200px' align='right' border=1 />\n"; |
| 6 |
*/ |
| 7 |
|
| 8 |
class DressingRoom { |
| 9 |
function buildUrl($as_img=false, $base='http://ballisticmystix.net/?p=dressingRoom;'){ |
| 10 |
$url = $base; |
| 11 |
if(strpos($url, '?')===false){ |
| 12 |
$url.='?'; |
| 13 |
}else{
|
| 14 |
$url.='&'; |
| 15 |
} |
| 16 |
$url.=$armor; |
| 17 |
if($as_img){ |
| 18 |
$url.='&img=1'; |
| 19 |
} |
| 20 |
return $url; |
| 21 |
} |
| 22 |
|
| 23 |
function getArmor(SimpleXMLElement $xml){ |
| 24 |
$url=array(); |
| 25 |
foreach($xml->equipments->item as $node){ |
| 26 |
// if it's one of armor parts
|
| 27 |
$part = (string) $node['part']; |
| 28 |
if(in_array($part, array('hands', 'chest', 'arms', 'legs','feet','head'))){ |
| 29 |
$color = (int) $node['c']; |
| 30 |
$url[]=$part.'='.(string) $node.'/'.$color; |
| 31 |
} |
| 32 |
} |
| 33 |
// race
|
| 34 |
switch(strtolower($xml->race)){ |
| 35 |
case 'zorai': |
| 36 |
case 'fyros': |
| 37 |
case 'matis': |
| 38 |
case 'tryker': // fall thru |
| 39 |
$race=strtolower($xml->race); |
| 40 |
break;
|
| 41 |
default:
|
| 42 |
$race='tryker'; |
| 43 |
} |
| 44 |
$url[]='race='.$race; |
| 45 |
// gender
|
| 46 |
if(strtolower($xml->gender)=='f') $gender='f'; else $gender='m'; |
| 47 |
$url[]='gender='.$gender; |
| 48 |
// hair
|
| 49 |
$hair_type = (int)$xml->body->hair_type; |
| 50 |
$hair_color = (int)$xml->body->hair_color; |
| 51 |
$url[]='hair='.$hair_type.'/'.$hair_color; |
| 52 |
// tattoo
|
| 53 |
$tattoo=(int)$xml->body->tattoo; |
| 54 |
$url[]='tattoo='.$tattoo; |
| 55 |
|
| 56 |
// join the URL and return it
|
| 57 |
return join('&',$url); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
}// DressingRoom
|
| 62 |
//eof
|