Archived
1
0
Fork 0

Initial Commit

This commit is contained in:
Henrik Hautakoski 2021-10-18 11:53:33 +02:00
commit ddf09fe00c
113 changed files with 187148 additions and 0 deletions

66
app/Game/GameSettings.php Normal file
View file

@ -0,0 +1,66 @@
<?php
namespace App\Game;
use App\Support\Set;
use Illuminate\Support\Collection;
class GameSettings
{
public Set $classes;
public Set $roles;
public Set $characters;
public Set $raids;
public function __construct($settings = [])
{
$this->classes = new Set();
$this->characters = new Set();
$this->raids = new Set();
$this->roles = new Set();
$this->fromArray($settings);
}
public function fromArray(array $array)
{
if (isset($array['classes'])) {
$this->classes->fill($array['classes']);
}
if (isset($array['raids'])) {
$this->raids->fill($array['raids']);
}
if (isset($array['characters'])) {
$this->characters->fill($array['characters']);
}
if (isset($array['roles'])) {
$this->roles->fill($array['roles']);
}
}
public function toArray() : array
{
return [
'classes' => $this->classes->toArray(),
'roles' => $this->roles->toArray(),
'raids' => $this->raids->toArray(),
'characters' => $this->characters->toArray()
];
}
public function all() : Collection
{
return collect([
'classes' => $this->classes->all()->toArray(),
'roles' => $this->roles->all()->toArray(),
'raids' => $this->raids->all()->toArray(),
'characters' => $this->characters->all()->toArray()
])->filter();
}
}