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