src/Entity/JogosParametros.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\JogosParametrosRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Util\Niveis;
  7. #[ORM\Entity(repositoryClass: JogosParametrosRepository::class)]
  8. class JogosParametros extends Niveis
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id = null;
  14.     #[ORM\Column(nullable: true)]
  15.     private ?int $pontos = null;
  16.     #[ORM\Column(nullable: true)]
  17.     private ?int $moedas = null;
  18.     #[ORM\Column]
  19.     private ?\DateTimeImmutable $created_at = null;
  20.     #[ORM\Column(nullable: true)]
  21.     private ?\DateTimeImmutable $updated_at = null;
  22.     #[ORM\ManyToOne(inversedBy: 'JogosParametros')]
  23.     private ?Jogos $Jogos = null;
  24.     #[ORM\ManyToOne(inversedBy: 'JogosParametros')]
  25.     private ?JogosRegras $JogosRegras = null;
  26.     #[ORM\Column(type: Types::TEXT, nullable: true)]
  27.     private ?string $historico = null;
  28.     #[ORM\Column(nullable: true)]
  29.     private ?int $nivel = null;
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getPontos(): ?int
  35.     {
  36.         return $this->pontos;
  37.     }
  38.     public function setPontos(?int $pontos): self
  39.     {
  40.         $this->pontos = $pontos;
  41.         return $this;
  42.     }
  43.     public function getMoedas(): ?int
  44.     {
  45.         return $this->moedas;
  46.     }
  47.     public function setMoedas(?int $moedas): self
  48.     {
  49.         $this->moedas = $moedas;
  50.         return $this;
  51.     }
  52.     public function getCreatedAt(): ?\DateTimeImmutable
  53.     {
  54.         return $this->created_at;
  55.     }
  56.     public function setCreatedAt(): self
  57.     {
  58.         $this->created_at = new \DateTimeImmutable('now');
  59.         
  60.         return $this;
  61.     }
  62.     public function getUpdatedAt(): ?\DateTimeImmutable
  63.     {
  64.         return $this->updated_at;
  65.     }
  66.     public function setUpdatedAt(): self
  67.     {
  68.         $this->updated_at = new \DateTimeImmutable('now');
  69.         return $this;
  70.     }
  71.     public function getJogos(): ?Jogos
  72.     {
  73.         return $this->Jogos;
  74.     }
  75.     public function setJogos(?Jogos $Jogos): self
  76.     {
  77.         $this->Jogos = $Jogos;
  78.         return $this;
  79.     }
  80.     public function getJogosRegras(): ?JogosRegras
  81.     {
  82.         return $this->JogosRegras;
  83.     }
  84.     public function setJogosRegras(?JogosRegras $JogosRegras): self
  85.     {
  86.         $this->JogosRegras = $JogosRegras;
  87.         return $this;
  88.     }
  89.     public function getHistorico()
  90.     {
  91.         return json_decode($this->historico, true);
  92.     }
  93.     public function setHistorico($historico): self
  94.     {
  95.         $this->historico = json_encode($historico);
  96.         return $this;
  97.     }
  98.     
  99.     public function getNivel(): ?int
  100.     {
  101.         return $this->nivel;
  102.     }
  103.     public function setNivel(int $nivel): self
  104.     {
  105.         if(!isset(self::TP_NIVEL[$nivel])){
  106.             throw new \Exception('Nível não encontrado');
  107.         }
  108.         
  109.         $this->nivel = $nivel;
  110.         
  111.         return $this;
  112.     }
  113.     
  114.     public function getNiveldesc()
  115.     {
  116.         
  117.         if(!isset(self::TP_NIVEL[$this->getNivel()])){
  118.             return '';
  119.         }
  120.         
  121.         return self::TP_NIVEL[$this->getNivel()]['label'];        
  122.     }
  123. }