|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
12
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
13
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
14
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
15
|
|
|
use Stu\Orm\Repository\NPCQuestUserRepository; |
|
16
|
|
|
use Stu\Component\Quest\QuestUserModeEnum; |
|
17
|
|
|
|
|
18
|
|
|
#[Table(name: 'stu_npc_quest_user')] |
|
19
|
|
|
#[Index(name: 'npc_quest_user_quest_idx', columns: ['quest_id'])] |
|
20
|
|
|
#[Index(name: 'npc_quest_user_user_idx', columns: ['user_id'])] |
|
21
|
|
|
#[Entity(repositoryClass: NPCQuestUserRepository::class)] |
|
22
|
|
|
class NPCQuestUser |
|
23
|
|
|
{ |
|
24
|
|
|
#[Id] |
|
25
|
|
|
#[Column(type: 'integer')] |
|
26
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
27
|
|
|
private int $id; |
|
28
|
|
|
|
|
29
|
|
|
#[Column(type: 'integer')] |
|
30
|
|
|
private int $quest_id = 0; |
|
31
|
|
|
|
|
32
|
|
|
#[Column(type: 'integer')] |
|
33
|
|
|
private int $user_id = 0; |
|
34
|
|
|
|
|
35
|
|
|
#[Column(type: 'integer', enumType: QuestUserModeEnum::class)] |
|
36
|
|
|
private QuestUserModeEnum $mode = QuestUserModeEnum::APPLICANT; |
|
37
|
|
|
|
|
38
|
|
|
#[Column(type: 'boolean', options: ['default' => false])] |
|
39
|
|
|
private bool $reward_received = false; |
|
40
|
|
|
|
|
41
|
|
|
#[ManyToOne(targetEntity: NPCQuest::class, inversedBy: 'questUsers')] |
|
42
|
|
|
#[JoinColumn(name: 'quest_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
43
|
|
|
private ?NPCQuest $quest = null; |
|
44
|
|
|
|
|
45
|
|
|
#[ManyToOne(targetEntity: User::class)] |
|
46
|
|
|
#[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
47
|
|
|
private ?User $user = null; |
|
48
|
|
|
|
|
49
|
|
|
public function getId(): int |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->id; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getQuestId(): int |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->quest_id; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setQuestId(int $questId): NPCQuestUser |
|
60
|
|
|
{ |
|
61
|
|
|
$this->quest_id = $questId; |
|
62
|
|
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function getQuest(): ?NPCQuest |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->quest; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function setQuest(?NPCQuest $quest): NPCQuestUser |
|
71
|
|
|
{ |
|
72
|
|
|
$this->quest = $quest; |
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getUserId(): int |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->user_id; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setUserId(int $userId): NPCQuestUser |
|
82
|
|
|
{ |
|
83
|
|
|
$this->user_id = $userId; |
|
84
|
|
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function getMode(): QuestUserModeEnum |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->mode; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function setMode(QuestUserModeEnum $mode): NPCQuestUser |
|
93
|
|
|
{ |
|
94
|
|
|
$this->mode = $mode; |
|
95
|
|
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function isRewardReceived(): bool |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->reward_received; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function setRewardReceived(bool $rewardReceived): NPCQuestUser |
|
104
|
|
|
{ |
|
105
|
|
|
$this->reward_received = $rewardReceived; |
|
106
|
|
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getUser(): ?User |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->user; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function setUser(?User $user): NPCQuestUser |
|
115
|
|
|
{ |
|
116
|
|
|
$this->user = $user; |
|
117
|
|
|
return $this; |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|