34 lines
555 B
PHP
34 lines
555 B
PHP
<?php
|
|
|
|
namespace User;
|
|
|
|
class WearedItem
|
|
{
|
|
private array $slot = [];
|
|
|
|
|
|
public function add(Item $item): void
|
|
{
|
|
$this->slot[$item->inslot] = $item;
|
|
}
|
|
|
|
public function exist(int $slot): bool
|
|
{
|
|
return array_key_exists($slot, $this->slot);
|
|
}
|
|
|
|
public function get(int $slot): Item
|
|
{
|
|
return $this->slot[$slot];
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return count($this->slot);
|
|
}
|
|
|
|
public function remove(int $slot): void
|
|
{
|
|
array_splice($this->slot, $slot, 1);
|
|
}
|
|
} |