2024-07-13 23:15:25 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Classes
|
|
|
|
{
|
|
|
|
public static function all(): array|false
|
|
|
|
{
|
|
|
|
$res = App::$db->q("SELECT * FROM classes");
|
|
|
|
return $res->fetchAll() ?: false;
|
|
|
|
}
|
2024-07-15 14:24:13 -05:00
|
|
|
|
|
|
|
public static function get(int $id): array|false
|
|
|
|
{
|
|
|
|
$res = App::$db->do("SELECT * FROM classes WHERE id = ?", [$id]);
|
|
|
|
return $res->fetch() ?: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spell definitions are in the DB under the spell columns;
|
|
|
|
// level:spell_id,spell_id|level:spell_id
|
|
|
|
// This means that as level increases, more spells are available.
|
|
|
|
public static function spellsToArray(string $spells): array
|
|
|
|
{
|
|
|
|
$list = [];
|
|
|
|
$groups = explode('|', $spells);
|
|
|
|
foreach ($groups as $group) {
|
|
|
|
$parts = explode(':', $group);
|
|
|
|
// first part will be level, second part will be spell_ids
|
|
|
|
$list[$parts[0]] = explode(',', $parts[1]);
|
|
|
|
}
|
|
|
|
return $list;
|
|
|
|
}
|
2024-07-13 23:15:25 -05:00
|
|
|
}
|