<?php

namespace App\Model\Entities;

use App\Model\Entities\GameData\GameData;
use App\Model\Entities\Security\User;
use App\Model\Interfaces\IGameData;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Game extends PortalSite
{
    /**
     * @var IGameData
     * @ORM\OneToOne(targetEntity="App\Model\Entities\GameData\GameData")
     */
    protected $gameData;

    /**
     * @var ArrayCollection
     * @ORM\ManyToMany(targetEntity="App\Model\Entities\Security\User", inversedBy="games")
     * @ORM\JoinTable(name="team_members")
     */
    protected $teamMembers;

    /**
     * GameSite constructor.
     * @param User $createdBy
     * @param IGameData $gameData
     */
    public function __construct(User $createdBy, IGameData $gameData)
    {
        parent::__construct($createdBy);

        $this->gameData = $gameData;
        $this->teamMembers = new ArrayCollection();
    }

    /**
     * @return IGameData
     */
    public function getGameData()
    {
        return $this->gameData;
    }

    public function isGameSite() : bool
    {
        return true;
    }


    public function isWoW()
    {
        return (strtolower($this->getName()) == 'world of warcraft');
    }
}