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