<?php

namespace App\Model\Entities\Components\Guide;

use App\Model\Entities\Game;
use App\Model\Entities\GameData\GameData;
use App\Model\Entities\Security\User;
use App\Model\Entities\Components\Messenger;
use App\Model\Entities\Components\TextEntry;
use App\Model\Entities\Templates\GuideTemplate;
use App\Model\Interfaces\IResource;
use App\Model\Interfaces\ITemplate;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="guide")
 */
class Guide extends TextEntry implements IResource
{
    /**
     * @var GuideTemplate
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Templates\GuideTemplate")
     */
    protected $template;

    /**
     * @var Game
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Game")
     */
    protected $game;

    /**
     * @var Messenger
     * @ORM\ManyToOne(targetEntity="App\Model\Entities\Components\Discussion\Discussion")
     * @ORM\JoinColumn(nullable=true)
     */
    protected $discussion;

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

        $this->game = $game;
    }

    /**
     * @return GameData
     */
    public function getGame()
    {
        return $this->game;
    }

    /**
     * @return Messenger
     */
    public function getDiscussion()
    {
        return $this->discussion;
    }

    /**
     * @param Messenger $discussion
     */
    public function setDiscussion(Messenger $discussion)
    {
        $this->discussion = $discussion;
    }

    /**
     * @return GuideTemplate
     */
    public function getTemplate()
    {
        return $this->template;
    }

    /**
     * @param GuideTemplate $template
     */
    public function setTemplate(GuideTemplate $template)
    {
        $this->template = $template;
    }

    public function getResourceTemplate() : ITemplate
    {
        return $this->getTemplate();
    }
}