mirror of
https://github.com/slawkens/myaac.git
synced 2026-04-23 19:03:31 +02:00
[WIP] Outfits TOML + XML
Deprecate old Outfits & Mounts functions
This commit is contained in:
49
system/src/Server/XML/Outfits.php
Normal file
49
system/src/Server/XML/Outfits.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Server\XML;
|
||||
|
||||
class Outfits
|
||||
{
|
||||
private array $outfits = [];
|
||||
|
||||
const FILE = 'XML/outfits.xml';
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$file = config('data_path') . self::FILE;
|
||||
|
||||
if(!@file_exists($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$xml = new \DOMDocument;
|
||||
$xml->load($file);
|
||||
|
||||
foreach ($xml->getElementsByTagName('outfit') as $outfit) {
|
||||
$this->outfits[] = $this->parseOutfitNode($outfit);
|
||||
}
|
||||
}
|
||||
|
||||
private function parseOutfitNode($node): array
|
||||
{
|
||||
$looktype = (int)$node->getAttribute('looktype');
|
||||
$type = (int)$node->getAttribute('type');
|
||||
$name = $node->getAttribute('name');
|
||||
$premium = getBoolean($node->getAttribute('premium'));
|
||||
$locked = !getBoolean($node->getAttribute('unlocked'));
|
||||
$enabled = getBoolean($node->getAttribute('enabled'));
|
||||
|
||||
return [
|
||||
'id' => $looktype,
|
||||
'sex' => ($type === 1 ? SEX_MALE : SEX_FEMALE),
|
||||
'name' => $name,
|
||||
'premium' => $premium,
|
||||
'locked' => $locked,
|
||||
'enabled' => $enabled,
|
||||
];
|
||||
}
|
||||
|
||||
public function getOutfits(): array {
|
||||
return $this->outfits;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user