|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Rottenwood\KingdomBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Rottenwood\KingdomBundle\Entity\Infrastructure\RoomType; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Игровая локация |
|
10
|
|
|
* @ORM\Table(name="rooms", uniqueConstraints={@ORM\UniqueConstraint(name="room_coordinates", columns={"x", "y", "z"})}) |
|
11
|
|
|
* @ORM\Entity(repositoryClass="Rottenwood\KingdomBundle\Entity\Infrastructure\RoomRepository") |
|
12
|
|
|
*/ |
|
13
|
|
|
class Room |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
const DEFAULT_Z = 0; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @ORM\Column(name="id", type="integer") |
|
20
|
|
|
* @ORM\Id |
|
21
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
22
|
|
|
* @var int |
|
23
|
|
|
*/ |
|
24
|
|
|
private $id; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Название |
|
28
|
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=true) |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
private $name; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Тип |
|
35
|
|
|
* @ORM\ManyToOne(targetEntity="Rottenwood\KingdomBundle\Entity\Infrastructure\RoomType") |
|
36
|
|
|
* @ORM\JoinColumn(name="type", referencedColumnName="id") |
|
37
|
|
|
* @var RoomType |
|
38
|
|
|
**/ |
|
39
|
|
|
private $type; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Описание |
|
43
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
private $description; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Положение на карте по оси Х |
|
50
|
|
|
* @ORM\Column(name="x", type="integer") |
|
51
|
|
|
* @var integer |
|
52
|
|
|
*/ |
|
53
|
|
|
private $x; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Положение на карте по оси Y |
|
57
|
|
|
* @ORM\Column(name="y", type="integer") |
|
58
|
|
|
* @var integer |
|
59
|
|
|
*/ |
|
60
|
|
|
private $y; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Положение на карте по оси Z |
|
64
|
|
|
* @ORM\Column(name="z", type="integer") |
|
65
|
|
|
* @var integer |
|
66
|
|
|
*/ |
|
67
|
|
|
private $z; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param int $x |
|
71
|
|
|
* @param int $y |
|
72
|
|
|
* @param RoomType $type |
|
73
|
|
|
* @param int $z |
|
74
|
|
|
*/ |
|
75
|
|
|
public function __construct($x, $y, RoomType $type, $z = self::DEFAULT_Z) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->x = $x; |
|
78
|
|
|
$this->y = $y; |
|
79
|
|
|
$this->type = $type; |
|
80
|
|
|
$this->z = $z; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return int |
|
85
|
|
|
*/ |
|
86
|
|
|
public function getId() |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->id; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getName() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->name ?: $this->getType()->getName(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return RoomType |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getType() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->type; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param RoomType $type |
|
109
|
|
|
*/ |
|
110
|
|
|
public function setType(RoomType $type) |
|
111
|
|
|
{ |
|
112
|
|
|
$this->type = $type; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return string |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getDescription() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->description ?: $this->getType()->getDescription(); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return int |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getX() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->x; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return int |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getY() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->y; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return int |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getZ() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->z; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
} |
|
148
|
|
|
|