public function onOpen(Player $who)
{
parent::onOpen($who);
if ($this->levels == null) {
$this->bookshelfAmount = $this->countBookshelf();
if ($this->bookshelfAmount < 0) {
$this->bookshelfAmount = 0;
}
if ($this->bookshelfAmount > 15) {
$this->bookshelfAmount = 15;
}
$base = mt_rand(1, 8) + $this->bookshelfAmount / 2 + mt_rand(0, $this->bookshelfAmount);
$this->levels = [0 => max($base / 3, 1), 1 => $base * 2 / 3 + 1, 2 => max($base, $this->bookshelfAmount * 2)];
}
}