<?php

namespace App\Model\Entities\GameData\Mmorpg;

use App\Model\Entities\BaseNamedRecord;
use App\Model\Entities\Security\User;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="server")
 */
class Server extends BaseNamedRecord
{
    const CREATED = 'created';
    const ACTIVE = 'active';
    const MERGED = 'merged';

    /**
     * @var Region
     * @ORM\ManyToOne(targetEntity="Region")
     */
    protected $region;

    public function __construct(User $createdBy)
    {
        parent::__construct($createdBy);

        $this->setState(self::CREATED);
    }


    /**
     * @return Region
     */
    public function getRegion() : Region
    {
        return $this->region;
    }

    /**
     * @param Region $region
     */
    public function setRegion(Region $region)
    {
        $this->region = $region;
    }

    protected function getValidStates() : array
    {
        $states =  parent::getValidStates();
        $states[] = self::CREATED;
        $states[] = self::ACTIVE;
        $states[] = self::MERGED;

        return $states;
    }


}