mirror of
https://github.com/slawkens/myaac.git
synced 2026-03-16 16:03:31 +01:00
[WIP] Refactoring
This commit is contained in:
@@ -9,8 +9,12 @@ class ItemsParser
|
||||
$ret = [];
|
||||
|
||||
$i = 0;
|
||||
$handle = fopen($path, "r");
|
||||
if ($handle) {
|
||||
$handle = fopen($path, 'r');
|
||||
|
||||
if ($handle === false) {
|
||||
throw new \RuntimeException('Failed to open items file: ' . $path);
|
||||
}
|
||||
|
||||
$parse = '';
|
||||
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
@@ -25,17 +29,18 @@ class ItemsParser
|
||||
// skip lines like this
|
||||
// field = {type = "fire", initdamage = 20, ticks = 10000, count = 7, damage = 10}
|
||||
// as it cannot be parsed by parse_ini_string
|
||||
if (str_contains($line, 'field =')) {
|
||||
if (str_starts_with(ltrim($line), 'field =')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parse .= $line;
|
||||
}
|
||||
|
||||
if ($parse !== '') {
|
||||
$ret[] = parse_ini_string($parse);
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use MyAAC\Cache\PHP as CachePHP;
|
||||
|
||||
class Items
|
||||
{
|
||||
private string $error;
|
||||
private string $error = '';
|
||||
|
||||
public function getError(): string {
|
||||
return $this->error;
|
||||
|
||||
@@ -40,12 +40,4 @@ class Vocations
|
||||
public function getFrom(): array {
|
||||
return $this->vocationsFrom;
|
||||
}
|
||||
|
||||
public static function getBase($includingRook = true): array {
|
||||
return \MyAAC\Server\Vocations::getBase($includingRook);
|
||||
}
|
||||
|
||||
public static function getOriginal(int $id): ?int {
|
||||
return \MyAAC\Server\Vocations::getOriginal($id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user