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 = [];
|
$ret = [];
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$handle = fopen($path, "r");
|
$handle = fopen($path, 'r');
|
||||||
if ($handle) {
|
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new \RuntimeException('Failed to open items file: ' . $path);
|
||||||
|
}
|
||||||
|
|
||||||
$parse = '';
|
$parse = '';
|
||||||
|
|
||||||
while (($line = fgets($handle)) !== false) {
|
while (($line = fgets($handle)) !== false) {
|
||||||
@@ -25,17 +29,18 @@ class ItemsParser
|
|||||||
// skip lines like this
|
// skip lines like this
|
||||||
// field = {type = "fire", initdamage = 20, ticks = 10000, count = 7, damage = 10}
|
// field = {type = "fire", initdamage = 20, ticks = 10000, count = 7, damage = 10}
|
||||||
// as it cannot be parsed by parse_ini_string
|
// as it cannot be parsed by parse_ini_string
|
||||||
if (str_contains($line, 'field =')) {
|
if (str_starts_with(ltrim($line), 'field =')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parse .= $line;
|
$parse .= $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($parse !== '') {
|
||||||
$ret[] = parse_ini_string($parse);
|
$ret[] = parse_ini_string($parse);
|
||||||
|
}
|
||||||
|
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use MyAAC\Cache\PHP as CachePHP;
|
|||||||
|
|
||||||
class Items
|
class Items
|
||||||
{
|
{
|
||||||
private string $error;
|
private string $error = '';
|
||||||
|
|
||||||
public function getError(): string {
|
public function getError(): string {
|
||||||
return $this->error;
|
return $this->error;
|
||||||
|
|||||||
@@ -40,12 +40,4 @@ class Vocations
|
|||||||
public function getFrom(): array {
|
public function getFrom(): array {
|
||||||
return $this->vocationsFrom;
|
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