RoomType::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 8
nop 3
1
<?php
2
3
namespace Rottenwood\KingdomBundle\Entity\Infrastructure;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * Тип локации
9
 * @ORM\Table(name="room_types", uniqueConstraints={@ORM\UniqueConstraint(name="index_unique_name", columns={"name"})})
10
 * @ORM\Entity()
11
 * @ORM\InheritanceType("SINGLE_TABLE")
12
 * @ORM\DiscriminatorColumn(name="type", type="string")
13
 * @ORM\DiscriminatorMap({
14
 *      "forest" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Forest",
15
 *      "grass" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Grass",
16
 *      "river" = "Rottenwood\KingdomBundle\Entity\RoomTypes\River",
17
 *      "road" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Road",
18
 *      "street" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Street",
19
 *      "fence" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Fence",
20
 *      "gate" = "Rottenwood\KingdomBundle\Entity\RoomTypes\Gate",
21
 *      "stone_wall" = "Rottenwood\KingdomBundle\Entity\RoomTypes\StoneWall",
22
 * })
23
 */
24
abstract class RoomType
25
{
26
27
    /**
28
     * @ORM\Column(name="id", type="integer")
29
     * @ORM\Id
30
     * @ORM\GeneratedValue(strategy="AUTO")
31
     * @var int
32
     */
33
    protected $id;
34
35
    /**
36
     * Название
37
     * @ORM\Column(name="name", type="string", length=255, unique=true)
38
     * @var string
39
     */
40
    protected $name;
41
42
    /**
43
     * Описание
44
     * @ORM\Column(name="description", type="text", nullable=true)
45
     * @var string
46
     */
47
    protected $description;
48
49
    /**
50
     * Имя изображения на карте
51
     * @ORM\Column(name="picture", type="string", length=255)
52
     * @var string
53
     */
54
    protected $picture;
55
56
    /**
57
     * Может ли игрок перемещаться по комнате пешком
58
     * @var bool
59
     */
60
    protected $canWalk = true;
61
62
    /**
63
     * Может ли игрок летать в комнате
64
     * @var bool
65
     */
66
    protected $canFly = true;
67
68
    /**
69
     * @param string $name
70
     * @param string $description
71
     * @param string $picture
72
     */
73
    public function __construct($name = '', $description = '', $picture = '')
74
    {
75
        if ($name) {
76
            $this->name = $name;
77
        }
78
79
        if ($description) {
80
            $this->description = $description;
81
        }
82
83
        if ($picture) {
84
            $this->picture = $picture;
85
        }
86
    }
87
88
    /**
89
     * @return int
90
     */
91
    public function getId()
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getName()
100
    {
101
        return $this->name;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function getDescription()
108
    {
109
        return $this->description;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getPicture()
116
    {
117
        return $this->picture;
118
    }
119
120
    /**
121
     * @return boolean
122
     */
123
    public function userCanWalk()
124
    {
125
        return $this->canWalk;
126
    }
127
128
    /**
129
     * @return boolean
130
     */
131
    public function userCanFly()
132
    {
133
        return $this->canFly;
134
    }
135
}
136