|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Obblm\Core\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Obblm\Core\Entity\Traits\NameTrait; |
|
6
|
|
|
use Obblm\Core\Repository\PlayerRepository; |
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @ORM\Entity(repositoryClass=PlayerRepository::class) |
|
13
|
|
|
* @ORM\Table(name="obblm_team_player") |
|
14
|
|
|
*/ |
|
15
|
|
|
class Player |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @ORM\Id() |
|
19
|
|
|
* @ORM\GeneratedValue() |
|
20
|
|
|
* @ORM\Column(type="integer") |
|
21
|
|
|
*/ |
|
22
|
|
|
private $id; |
|
23
|
|
|
|
|
24
|
|
|
use NameTrait; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @ORM\ManyToOne(targetEntity=Team::class, inversedBy="players") |
|
28
|
|
|
* @ORM\JoinColumn(nullable=false) |
|
29
|
|
|
*/ |
|
30
|
|
|
private $team; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @ORM\Column(type="integer") |
|
34
|
|
|
*/ |
|
35
|
|
|
private $number; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @ORM\Column(type="string", length=50) |
|
39
|
|
|
*/ |
|
40
|
|
|
private $type; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @ORM\OneToMany(targetEntity=PlayerVersion::class, mappedBy="player", orphanRemoval=true, cascade={"remove"}) |
|
44
|
|
|
* @ORM\OrderBy({"id"="DESC"}) |
|
45
|
|
|
*/ |
|
46
|
|
|
private $versions; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @ORM\Column(type="boolean") |
|
50
|
|
|
*/ |
|
51
|
|
|
private $dead = false; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @ORM\Column(type="boolean") |
|
55
|
|
|
*/ |
|
56
|
|
|
private $fire = false; |
|
57
|
|
|
|
|
58
|
2 |
|
public function __construct() |
|
59
|
|
|
{ |
|
60
|
2 |
|
$this->versions = new ArrayCollection(); |
|
61
|
2 |
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getId(): ?int |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->id; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getTeam(): ?Team |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->team; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
2 |
|
public function setTeam(?Team $team): self |
|
74
|
|
|
{ |
|
75
|
2 |
|
$this->team = $team; |
|
76
|
|
|
|
|
77
|
2 |
|
return $this; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
1 |
|
public function getNumber(): ?int |
|
81
|
|
|
{ |
|
82
|
1 |
|
return $this->number; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function setNumber(int $number): self |
|
86
|
|
|
{ |
|
87
|
|
|
$this->number = $number; |
|
88
|
|
|
|
|
89
|
|
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
2 |
|
public function getType(): ?string |
|
93
|
|
|
{ |
|
94
|
2 |
|
return $this->type; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
2 |
|
public function setType(?string $type): self |
|
98
|
|
|
{ |
|
99
|
2 |
|
$this->type = $type; |
|
100
|
|
|
|
|
101
|
2 |
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return Collection|PlayerVersion[] |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function getVersions(): Collection |
|
108
|
|
|
{ |
|
109
|
1 |
|
return $this->versions; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
1 |
|
public function addVersion(PlayerVersion $version): self |
|
113
|
|
|
{ |
|
114
|
1 |
|
if (!$this->versions->contains($version)) { |
|
115
|
1 |
|
$this->versions[] = $version; |
|
116
|
1 |
|
$version->setPlayer($this); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
1 |
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function removeVersion(PlayerVersion $version): self |
|
123
|
|
|
{ |
|
124
|
|
|
if ($this->versions->contains($version)) { |
|
125
|
|
|
$this->versions->removeElement($version); |
|
126
|
|
|
// set the owning side to null (unless already changed) |
|
127
|
|
|
if ($version->getPlayer() === $this) { |
|
128
|
|
|
$version->setPlayer(null); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
return $this; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
1 |
|
public function getDead(): ?bool |
|
136
|
|
|
{ |
|
137
|
1 |
|
return $this->dead; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function setDead(bool $dead): self |
|
141
|
|
|
{ |
|
142
|
|
|
$this->dead = $dead; |
|
143
|
|
|
|
|
144
|
|
|
return $this; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
1 |
|
public function getFire(): ?bool |
|
148
|
|
|
{ |
|
149
|
1 |
|
return $this->fire; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setFire(bool $fire): self |
|
153
|
|
|
{ |
|
154
|
|
|
$this->fire = $fire; |
|
155
|
|
|
|
|
156
|
|
|
return $this; |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|