28 lines
644 B
PHP
28 lines
644 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use App\Game\Buildings\BuildingState;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class Building extends Model
|
||
|
|
{
|
||
|
|
protected $guarded = [];
|
||
|
|
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return ['level' => 'integer', 'priority' => 'integer', 'x' => 'integer', 'y' => 'integer'];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function village(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Village::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function state(): BuildingState
|
||
|
|
{
|
||
|
|
return new BuildingState($this->id, $this->type, $this->level, $this->priority, $this->x, $this->y);
|
||
|
|
}
|
||
|
|
}
|